@alagoni97/cli 0.72.1
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 +201 -0
- package/README.md +336 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.mjs +3 -0
- package/bin/run.cmd +3 -0
- package/bin/run.mjs +4 -0
- package/dist/LoggingInterface.d.ts +123 -0
- package/dist/LoggingInterface.js +300 -0
- package/dist/PersistedConfig.d.ts +46 -0
- package/dist/PersistedConfig.js +94 -0
- package/dist/browser/adapters/output.d.ts +69 -0
- package/dist/browser/adapters/output.js +91 -0
- package/dist/browser/config.d.ts +18 -0
- package/dist/browser/config.js +59 -0
- package/dist/browser/generate.d.ts +20 -0
- package/dist/browser/generate.js +129 -0
- package/dist/browser/index.d.ts +17 -0
- package/dist/browser/index.js +26 -0
- package/dist/browser/parser.d.ts +9 -0
- package/dist/browser/parser.js +61 -0
- package/dist/browser/shims/asyncapi-parser.d.ts +30 -0
- package/dist/browser/shims/asyncapi-parser.js +52 -0
- package/dist/browser/shims/fs.d.ts +190 -0
- package/dist/browser/shims/fs.js +188 -0
- package/dist/browser/shims/json-schema-ref-parser.d.ts +73 -0
- package/dist/browser/shims/json-schema-ref-parser.js +246 -0
- package/dist/browser/shims/swagger-parser.d.ts +20 -0
- package/dist/browser/shims/swagger-parser.js +40 -0
- package/dist/codegen/configurationSchemaBuilder.d.ts +15 -0
- package/dist/codegen/configurationSchemaBuilder.js +48 -0
- package/dist/codegen/configurations.d.ts +29 -0
- package/dist/codegen/configurations.js +260 -0
- package/dist/codegen/detection.d.ts +19 -0
- package/dist/codegen/detection.js +174 -0
- package/dist/codegen/errors.d.ts +111 -0
- package/dist/codegen/errors.js +352 -0
- package/dist/codegen/generators/generic/custom.d.ts +75 -0
- package/dist/codegen/generators/generic/custom.js +66 -0
- package/dist/codegen/generators/index.d.ts +14 -0
- package/dist/codegen/generators/index.js +42 -0
- package/dist/codegen/generators/typescript/channels/asyncapi.d.ts +10 -0
- package/dist/codegen/generators/typescript/channels/asyncapi.js +131 -0
- package/dist/codegen/generators/typescript/channels/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/channels/index.js +142 -0
- package/dist/codegen/generators/typescript/channels/openapi.d.ts +9 -0
- package/dist/codegen/generators/typescript/channels/openapi.js +168 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/index.js +149 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishExchange.d.ts +5 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishExchange.js +106 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishQueue.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishQueue.js +102 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/subscribeQueue.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/subscribeQueue.js +133 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/express.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/express.js +100 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/fetch.d.ts +5 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/fetch.js +144 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/index.js +132 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/client.d.ts +10 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/client.js +224 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/common-types.d.ts +14 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/common-types.js +800 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/index.js +96 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/security.d.ts +48 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/security.js +491 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/index.js +127 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/publish.js +108 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/subscribe.js +154 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/utils.d.ts +11 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/utils.js +58 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/index.js +113 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/publish.js +99 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/subscribe.js +186 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/corePublish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/corePublish.js +90 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreReply.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreReply.js +142 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreRequest.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreRequest.js +100 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreSubscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreSubscribe.js +143 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/index.d.ts +11 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/index.js +224 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPublish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPublish.js +89 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPullSubscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPullSubscribe.js +146 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPushSubscription.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPushSubscription.js +149 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/utils.d.ts +35 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/utils.js +120 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/index.js +152 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/publish.js +64 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/register.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/register.js +115 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/subscribe.js +151 -0
- package/dist/codegen/generators/typescript/channels/types.d.ts +181 -0
- package/dist/codegen/generators/typescript/channels/types.js +131 -0
- package/dist/codegen/generators/typescript/channels/utils.d.ts +64 -0
- package/dist/codegen/generators/typescript/channels/utils.js +163 -0
- package/dist/codegen/generators/typescript/client/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/client/index.js +61 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/corePublish.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/corePublish.js +53 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/coreSubscribe.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/coreSubscribe.js +90 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetStreamPullSubscription.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetStreamPullSubscription.js +83 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPublish.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPublish.js +54 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPushSubscription.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPushSubscription.js +82 -0
- package/dist/codegen/generators/typescript/client/protocols/nats.d.ts +2 -0
- package/dist/codegen/generators/typescript/client/protocols/nats.js +182 -0
- package/dist/codegen/generators/typescript/client/types.d.ts +49 -0
- package/dist/codegen/generators/typescript/client/types.js +37 -0
- package/dist/codegen/generators/typescript/headers.d.ts +54 -0
- package/dist/codegen/generators/typescript/headers.js +138 -0
- package/dist/codegen/generators/typescript/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/index.js +38 -0
- package/dist/codegen/generators/typescript/models.d.ts +21761 -0
- package/dist/codegen/generators/typescript/models.js +64 -0
- package/dist/codegen/generators/typescript/parameters.d.ts +37 -0
- package/dist/codegen/generators/typescript/parameters.js +101 -0
- package/dist/codegen/generators/typescript/payloads.d.ts +73 -0
- package/dist/codegen/generators/typescript/payloads.js +250 -0
- package/dist/codegen/generators/typescript/types.d.ts +34 -0
- package/dist/codegen/generators/typescript/types.js +70 -0
- package/dist/codegen/generators/typescript/utils.d.ts +38 -0
- package/dist/codegen/generators/typescript/utils.js +195 -0
- package/dist/codegen/index.d.ts +7 -0
- package/dist/codegen/index.js +38 -0
- package/dist/codegen/inputs/asyncapi/generators/headers.d.ts +3 -0
- package/dist/codegen/inputs/asyncapi/generators/headers.js +41 -0
- package/dist/codegen/inputs/asyncapi/generators/parameters.d.ts +14 -0
- package/dist/codegen/inputs/asyncapi/generators/parameters.js +120 -0
- package/dist/codegen/inputs/asyncapi/generators/payloads.d.ts +16 -0
- package/dist/codegen/inputs/asyncapi/generators/payloads.js +124 -0
- package/dist/codegen/inputs/asyncapi/generators/types.d.ts +9 -0
- package/dist/codegen/inputs/asyncapi/generators/types.js +61 -0
- package/dist/codegen/inputs/asyncapi/index.d.ts +1 -0
- package/dist/codegen/inputs/asyncapi/index.js +7 -0
- package/dist/codegen/inputs/asyncapi/parser.d.ts +4 -0
- package/dist/codegen/inputs/asyncapi/parser.js +90 -0
- package/dist/codegen/inputs/index.d.ts +3 -0
- package/dist/codegen/inputs/index.js +19 -0
- package/dist/codegen/inputs/jsonschema/generators/index.d.ts +1 -0
- package/dist/codegen/inputs/jsonschema/generators/index.js +5 -0
- package/dist/codegen/inputs/jsonschema/generators/models.d.ts +7 -0
- package/dist/codegen/inputs/jsonschema/generators/models.js +26 -0
- package/dist/codegen/inputs/jsonschema/index.d.ts +1 -0
- package/dist/codegen/inputs/jsonschema/index.js +7 -0
- package/dist/codegen/inputs/jsonschema/parser.d.ts +31 -0
- package/dist/codegen/inputs/jsonschema/parser.js +128 -0
- package/dist/codegen/inputs/openapi/generators/headers.d.ts +3 -0
- package/dist/codegen/inputs/openapi/generators/headers.js +101 -0
- package/dist/codegen/inputs/openapi/generators/parameters.d.ts +10 -0
- package/dist/codegen/inputs/openapi/generators/parameters.js +852 -0
- package/dist/codegen/inputs/openapi/generators/payloads.d.ts +3 -0
- package/dist/codegen/inputs/openapi/generators/payloads.js +231 -0
- package/dist/codegen/inputs/openapi/generators/types.d.ts +9 -0
- package/dist/codegen/inputs/openapi/generators/types.js +86 -0
- package/dist/codegen/inputs/openapi/index.d.ts +2 -0
- package/dist/codegen/inputs/openapi/index.js +8 -0
- package/dist/codegen/inputs/openapi/parser.d.ts +4 -0
- package/dist/codegen/inputs/openapi/parser.js +115 -0
- package/dist/codegen/inputs/openapi/security.d.ts +56 -0
- package/dist/codegen/inputs/openapi/security.js +193 -0
- package/dist/codegen/modelina/index.d.ts +2 -0
- package/dist/codegen/modelina/index.js +20 -0
- package/dist/codegen/modelina/presets/index.d.ts +3 -0
- package/dist/codegen/modelina/presets/index.js +14 -0
- package/dist/codegen/modelina/presets/primitives.d.ts +34 -0
- package/dist/codegen/modelina/presets/primitives.js +211 -0
- package/dist/codegen/modelina/presets/union.d.ts +33 -0
- package/dist/codegen/modelina/presets/union.js +197 -0
- package/dist/codegen/modelina/presets/validation.d.ts +66 -0
- package/dist/codegen/modelina/presets/validation.js +183 -0
- package/dist/codegen/modelina/types.d.ts +61845 -0
- package/dist/codegen/modelina/types.js +412 -0
- package/dist/codegen/output/filesystem.d.ts +30 -0
- package/dist/codegen/output/filesystem.js +61 -0
- package/dist/codegen/output/index.d.ts +16 -0
- package/dist/codegen/output/index.js +57 -0
- package/dist/codegen/output/memory.d.ts +54 -0
- package/dist/codegen/output/memory.js +81 -0
- package/dist/codegen/output/modelina.d.ts +30 -0
- package/dist/codegen/output/modelina.js +30 -0
- package/dist/codegen/output/types.d.ts +47 -0
- package/dist/codegen/output/types.js +6 -0
- package/dist/codegen/renderer.d.ts +13 -0
- package/dist/codegen/renderer.js +309 -0
- package/dist/codegen/schemaPostProcess.d.ts +25 -0
- package/dist/codegen/schemaPostProcess.js +38 -0
- package/dist/codegen/types.d.ts +285187 -0
- package/dist/codegen/types.js +177 -0
- package/dist/codegen/utils.d.ts +126 -0
- package/dist/codegen/utils.js +373 -0
- package/dist/commands/base.d.ts +18 -0
- package/dist/commands/base.js +59 -0
- package/dist/commands/generate.d.ts +46 -0
- package/dist/commands/generate.js +305 -0
- package/dist/commands/init.d.ts +55 -0
- package/dist/commands/init.js +544 -0
- package/dist/commands/telemetry.d.ts +25 -0
- package/dist/commands/telemetry.js +115 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +35 -0
- package/dist/telemetry/anonymize.d.ts +19 -0
- package/dist/telemetry/anonymize.js +73 -0
- package/dist/telemetry/collector.d.ts +26 -0
- package/dist/telemetry/collector.js +57 -0
- package/dist/telemetry/config.d.ts +32 -0
- package/dist/telemetry/config.js +97 -0
- package/dist/telemetry/events.d.ts +72 -0
- package/dist/telemetry/events.js +5 -0
- package/dist/telemetry/index.d.ts +46 -0
- package/dist/telemetry/index.js +91 -0
- package/dist/telemetry/notice.d.ts +8 -0
- package/dist/telemetry/notice.js +50 -0
- package/dist/telemetry/sender.d.ts +14 -0
- package/dist/telemetry/sender.js +125 -0
- package/dist/utils/gitignore.d.ts +66 -0
- package/dist/utils/gitignore.js +111 -0
- package/dist/utils/inputSource.d.ts +3 -0
- package/dist/utils/inputSource.js +26 -0
- package/dist/utils/refResolvers.d.ts +29 -0
- package/dist/utils/refResolvers.js +83 -0
- package/dist/utils/remoteFetch.d.ts +18 -0
- package/dist/utils/remoteFetch.js +64 -0
- package/oclif.manifest.json +510 -0
- package/package.json +155 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base command class with shared flags for verbosity and output control
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from '@oclif/core';
|
|
5
|
+
export declare abstract class BaseCommand extends Command {
|
|
6
|
+
static baseFlags: {
|
|
7
|
+
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'no-color': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Configure the logger based on parsed flags
|
|
16
|
+
*/
|
|
17
|
+
protected setupLogger(flags: Record<string, unknown>): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCommand = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base command class with shared flags for verbosity and output control
|
|
6
|
+
*/
|
|
7
|
+
const core_1 = require("@oclif/core");
|
|
8
|
+
const LoggingInterface_1 = require("../LoggingInterface");
|
|
9
|
+
class BaseCommand extends core_1.Command {
|
|
10
|
+
static baseFlags = {
|
|
11
|
+
verbose: core_1.Flags.boolean({
|
|
12
|
+
char: 'v',
|
|
13
|
+
description: 'Show detailed output'
|
|
14
|
+
}),
|
|
15
|
+
quiet: core_1.Flags.boolean({
|
|
16
|
+
char: 'q',
|
|
17
|
+
description: 'Only show errors and warnings',
|
|
18
|
+
exclusive: ['verbose', 'silent']
|
|
19
|
+
}),
|
|
20
|
+
silent: core_1.Flags.boolean({
|
|
21
|
+
description: 'Suppress all output except fatal errors',
|
|
22
|
+
exclusive: ['verbose', 'quiet']
|
|
23
|
+
}),
|
|
24
|
+
json: core_1.Flags.boolean({
|
|
25
|
+
description: 'Output results as JSON for scripting'
|
|
26
|
+
}),
|
|
27
|
+
'no-color': core_1.Flags.boolean({
|
|
28
|
+
description: 'Disable colored output'
|
|
29
|
+
}),
|
|
30
|
+
debug: core_1.Flags.boolean({
|
|
31
|
+
description: 'Show debug information',
|
|
32
|
+
exclusive: ['quiet', 'silent']
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Configure the logger based on parsed flags
|
|
37
|
+
*/
|
|
38
|
+
setupLogger(flags) {
|
|
39
|
+
// Reset logger to default state first to ensure clean state between commands
|
|
40
|
+
LoggingInterface_1.Logger.reset();
|
|
41
|
+
let logLevel = 'info';
|
|
42
|
+
if (flags.debug) {
|
|
43
|
+
logLevel = 'debug';
|
|
44
|
+
}
|
|
45
|
+
else if (flags.verbose) {
|
|
46
|
+
logLevel = 'verbose';
|
|
47
|
+
}
|
|
48
|
+
else if (flags.quiet) {
|
|
49
|
+
logLevel = 'warn';
|
|
50
|
+
}
|
|
51
|
+
else if (flags.silent) {
|
|
52
|
+
logLevel = 'silent';
|
|
53
|
+
}
|
|
54
|
+
LoggingInterface_1.Logger.setLevel(logLevel);
|
|
55
|
+
LoggingInterface_1.Logger.setJsonMode(!!flags.json);
|
|
56
|
+
LoggingInterface_1.Logger.setColors(!flags['no-color']);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.BaseCommand = BaseCommand;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RunGeneratorContext } from '../codegen';
|
|
2
|
+
import { BaseCommand } from './base';
|
|
3
|
+
export default class Generate extends BaseCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static args: {
|
|
6
|
+
file: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
'no-color': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
16
|
+
watch: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
watchPath: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Handle successful generation output based on flags
|
|
22
|
+
*/
|
|
23
|
+
private handleSuccessOutput;
|
|
24
|
+
private runWithWatch;
|
|
25
|
+
handleWatchModeStartedTelemetry({ context, inputSource }: {
|
|
26
|
+
context: RunGeneratorContext;
|
|
27
|
+
inputSource: 'remote_url' | 'local_relative' | 'local_absolute' | undefined;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
handleGeneratorUsageTelemetry({ context, inputSource }: {
|
|
30
|
+
context: RunGeneratorContext;
|
|
31
|
+
inputSource: 'remote_url' | 'local_relative' | 'local_absolute' | undefined;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
handleSuccessfulGenerateTelemetry({ context, flags, inputSource, startTime }: {
|
|
34
|
+
context: RunGeneratorContext;
|
|
35
|
+
flags: any;
|
|
36
|
+
inputSource: 'remote_url' | 'local_relative' | 'local_absolute' | undefined;
|
|
37
|
+
startTime: number;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
handleFailedGenerateTelemetry({ error, context, flags, inputSource, startTime }: {
|
|
40
|
+
error: unknown;
|
|
41
|
+
context: RunGeneratorContext;
|
|
42
|
+
flags: any;
|
|
43
|
+
inputSource: 'remote_url' | 'local_relative' | 'local_absolute' | undefined;
|
|
44
|
+
startTime: number;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/* eslint-disable no-undef, sonarjs/cognitive-complexity */
|
|
7
|
+
const core_1 = require("@oclif/core");
|
|
8
|
+
const LoggingInterface_1 = require("../LoggingInterface");
|
|
9
|
+
const generators_1 = require("../codegen/generators");
|
|
10
|
+
const output_1 = require("../codegen/output");
|
|
11
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const configurations_1 = require("../codegen/configurations");
|
|
14
|
+
const errors_1 = require("../codegen/errors");
|
|
15
|
+
const telemetry_1 = require("../telemetry");
|
|
16
|
+
const anonymize_1 = require("../telemetry/anonymize");
|
|
17
|
+
const inputSource_1 = require("../utils/inputSource");
|
|
18
|
+
const base_1 = require("./base");
|
|
19
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
20
|
+
/**
|
|
21
|
+
* Converts any error to a CodegenError for consistent error handling.
|
|
22
|
+
* If error is already a CodegenError, returns it directly.
|
|
23
|
+
* Otherwise wraps it in a generic generator error.
|
|
24
|
+
*/
|
|
25
|
+
function toCodegenError(error) {
|
|
26
|
+
if (error instanceof errors_1.CodegenError) {
|
|
27
|
+
return error;
|
|
28
|
+
}
|
|
29
|
+
return (0, errors_1.createGeneratorError)({
|
|
30
|
+
generatorId: 'generate',
|
|
31
|
+
originalError: error instanceof Error ? error : new Error(String(error))
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
class Generate extends base_1.BaseCommand {
|
|
35
|
+
static description = 'Generate code based on your configuration, use `init` to get started, `generate` to generate code from the configuration.';
|
|
36
|
+
static args = {
|
|
37
|
+
file: core_1.Args.string({
|
|
38
|
+
description: 'Path or URL to the configuration file, defaults to root of where the command is run'
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
static flags = {
|
|
42
|
+
help: core_1.Flags.help(),
|
|
43
|
+
watch: core_1.Flags.boolean({
|
|
44
|
+
char: 'w',
|
|
45
|
+
description: 'Watch for file changes and regenerate code automatically'
|
|
46
|
+
}),
|
|
47
|
+
watchPath: core_1.Flags.string({
|
|
48
|
+
char: 'p',
|
|
49
|
+
description: 'Optional path to watch for changes when --watch flag is used. If not provided, watches the input file from configuration'
|
|
50
|
+
}),
|
|
51
|
+
...base_1.BaseCommand.baseFlags
|
|
52
|
+
};
|
|
53
|
+
async run() {
|
|
54
|
+
const startTime = Date.now();
|
|
55
|
+
const { args, flags } = await this.parse(Generate);
|
|
56
|
+
// Configure logger based on flags
|
|
57
|
+
this.setupLogger(flags);
|
|
58
|
+
const { file } = args;
|
|
59
|
+
const { watch, watchPath } = flags;
|
|
60
|
+
// Determine input source type if file is provided
|
|
61
|
+
let inputSource;
|
|
62
|
+
if (file) {
|
|
63
|
+
inputSource = (0, anonymize_1.getInputSourceType)(file);
|
|
64
|
+
}
|
|
65
|
+
let context;
|
|
66
|
+
try {
|
|
67
|
+
context = await (0, configurations_1.realizeGeneratorContext)(file);
|
|
68
|
+
}
|
|
69
|
+
catch (configError) {
|
|
70
|
+
const codegenError = toCodegenError(configError);
|
|
71
|
+
LoggingInterface_1.Logger.error(codegenError.format(!flags['no-color']));
|
|
72
|
+
// Use error message that includes details for better test assertions
|
|
73
|
+
const errorMessage = codegenError.details
|
|
74
|
+
? `${codegenError.message}: ${codegenError.details}`
|
|
75
|
+
: codegenError.message;
|
|
76
|
+
this.error(errorMessage, { exit: 1 });
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
let result;
|
|
80
|
+
if (watch) {
|
|
81
|
+
await this.handleWatchModeStartedTelemetry({ context, inputSource });
|
|
82
|
+
await this.runWithWatch({ configFile: file, watchPath, flags, context });
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
LoggingInterface_1.Logger.startSpinner('Generating code...');
|
|
86
|
+
result = await (0, generators_1.generateWithConfig)(context);
|
|
87
|
+
// Write files to disk (pure core returns files, CLI writes)
|
|
88
|
+
const basePath = path_1.default.dirname(context.configFilePath);
|
|
89
|
+
await (0, output_1.writeGeneratedFiles)(result.files, basePath);
|
|
90
|
+
this.handleSuccessOutput(result, flags);
|
|
91
|
+
}
|
|
92
|
+
await this.handleGeneratorUsageTelemetry({ context, inputSource });
|
|
93
|
+
await this.handleSuccessfulGenerateTelemetry({
|
|
94
|
+
context,
|
|
95
|
+
flags,
|
|
96
|
+
inputSource,
|
|
97
|
+
startTime
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
LoggingInterface_1.Logger.failSpinner('Generation failed');
|
|
102
|
+
const codegenError = toCodegenError(error);
|
|
103
|
+
LoggingInterface_1.Logger.error(codegenError.format(!flags['no-color']));
|
|
104
|
+
await this.handleFailedGenerateTelemetry({
|
|
105
|
+
error,
|
|
106
|
+
context,
|
|
107
|
+
flags,
|
|
108
|
+
inputSource,
|
|
109
|
+
startTime
|
|
110
|
+
});
|
|
111
|
+
// Use error message that includes details for better test assertions
|
|
112
|
+
const errorMessage = codegenError.details
|
|
113
|
+
? `${codegenError.message}: ${codegenError.details}`
|
|
114
|
+
: codegenError.message;
|
|
115
|
+
this.error(errorMessage, { exit: 1 });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Handle successful generation output based on flags
|
|
120
|
+
*/
|
|
121
|
+
handleSuccessOutput(result, flags) {
|
|
122
|
+
const totalFiles = result.files.length;
|
|
123
|
+
LoggingInterface_1.Logger.succeedSpinner(`Generated ${totalFiles} file${totalFiles !== 1 ? 's' : ''} in ${result.totalDuration}ms`);
|
|
124
|
+
// Verbose: show file list
|
|
125
|
+
if (flags.verbose && !flags.json) {
|
|
126
|
+
for (const file of result.files) {
|
|
127
|
+
const relativePath = path_1.default.relative(process.cwd(), file.path);
|
|
128
|
+
LoggingInterface_1.Logger.verbose(` -> ${relativePath}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// JSON output
|
|
132
|
+
if (flags.json) {
|
|
133
|
+
LoggingInterface_1.Logger.json({
|
|
134
|
+
success: true,
|
|
135
|
+
files: result.files.map((file) => path_1.default.relative(process.cwd(), file.path)),
|
|
136
|
+
generators: result.generators.map((gen) => ({
|
|
137
|
+
id: gen.id,
|
|
138
|
+
preset: gen.preset,
|
|
139
|
+
files: gen.files.map((file) => path_1.default.relative(process.cwd(), file.path)),
|
|
140
|
+
duration: gen.duration
|
|
141
|
+
})),
|
|
142
|
+
totalFiles,
|
|
143
|
+
duration: result.totalDuration
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async runWithWatch({ configFile, watchPath, flags, context }) {
|
|
148
|
+
const basePath = path_1.default.dirname(context.configFilePath);
|
|
149
|
+
// Initial generation
|
|
150
|
+
LoggingInterface_1.Logger.startSpinner('Generating initial code...');
|
|
151
|
+
const initialResult = await (0, generators_1.generateWithConfig)(configFile);
|
|
152
|
+
await (0, output_1.writeGeneratedFiles)(initialResult.files, basePath);
|
|
153
|
+
const totalFiles = initialResult.files.length;
|
|
154
|
+
LoggingInterface_1.Logger.succeedSpinner(`Initial generation complete (${totalFiles} file${totalFiles !== 1 ? 's' : ''})`);
|
|
155
|
+
// Determine what to watch
|
|
156
|
+
let pathToWatch;
|
|
157
|
+
if (watchPath) {
|
|
158
|
+
pathToWatch = path_1.default.resolve(watchPath);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// Get the input file path from configuration
|
|
162
|
+
const watchContext = await (0, configurations_1.realizeGeneratorContext)(configFile);
|
|
163
|
+
pathToWatch = watchContext.documentPath;
|
|
164
|
+
}
|
|
165
|
+
const useColors = !flags['no-color'];
|
|
166
|
+
// Watch mode degrades gracefully for URL inputs: chokidar can only
|
|
167
|
+
// observe the local filesystem, so skip it and warn the user.
|
|
168
|
+
if ((0, inputSource_1.isRemoteUrl)(pathToWatch)) {
|
|
169
|
+
LoggingInterface_1.Logger.warn(`Watch mode: input is a remote URL — skipping input watcher. Use --watchPath to trigger regeneration on local file changes.`);
|
|
170
|
+
// Keep the process alive so users can still ^C cleanly.
|
|
171
|
+
return new Promise(() => undefined);
|
|
172
|
+
}
|
|
173
|
+
LoggingInterface_1.Logger.info(`\nWatching for changes in: ${useColors ? picocolors_1.default.cyan(pathToWatch) : pathToWatch}`);
|
|
174
|
+
LoggingInterface_1.Logger.info(useColors
|
|
175
|
+
? picocolors_1.default.dim('Press Ctrl+C to stop watching...')
|
|
176
|
+
: 'Press Ctrl+C to stop watching...');
|
|
177
|
+
// Set up file watcher
|
|
178
|
+
const watcher = chokidar_1.default.watch(pathToWatch, {
|
|
179
|
+
ignored: /(^|[/\\])\../, // ignore dotfiles
|
|
180
|
+
persistent: true,
|
|
181
|
+
ignoreInitial: true
|
|
182
|
+
});
|
|
183
|
+
let isGenerating = false;
|
|
184
|
+
watcher.on('change', async (changedPath) => {
|
|
185
|
+
if (isGenerating) {
|
|
186
|
+
LoggingInterface_1.Logger.debug('Generation already in progress, skipping...');
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
isGenerating = true;
|
|
190
|
+
LoggingInterface_1.Logger.startSpinner(`Regenerating (${path_1.default.basename(changedPath)} changed)...`);
|
|
191
|
+
try {
|
|
192
|
+
const result = await (0, generators_1.generateWithConfig)(configFile);
|
|
193
|
+
await (0, output_1.writeGeneratedFiles)(result.files, basePath);
|
|
194
|
+
const regenTotalFiles = result.files.length;
|
|
195
|
+
LoggingInterface_1.Logger.succeedSpinner(`Regenerated ${regenTotalFiles} file${regenTotalFiles !== 1 ? 's' : ''} in ${result.totalDuration}ms`);
|
|
196
|
+
// Verbose: show file list
|
|
197
|
+
if (flags.verbose && !flags.json) {
|
|
198
|
+
for (const file of result.files) {
|
|
199
|
+
const relativePath = path_1.default.relative(process.cwd(), file.path);
|
|
200
|
+
LoggingInterface_1.Logger.verbose(` -> ${relativePath}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
const codegenError = toCodegenError(error);
|
|
206
|
+
LoggingInterface_1.Logger.failSpinner('Regeneration failed');
|
|
207
|
+
LoggingInterface_1.Logger.error(codegenError.format(!flags['no-color']));
|
|
208
|
+
}
|
|
209
|
+
finally {
|
|
210
|
+
isGenerating = false;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
watcher.on('error', (error) => {
|
|
214
|
+
const codegenError = toCodegenError(error);
|
|
215
|
+
LoggingInterface_1.Logger.error(codegenError.format(!flags['no-color']));
|
|
216
|
+
});
|
|
217
|
+
// Set up graceful shutdown handlers
|
|
218
|
+
const cleanup = () => {
|
|
219
|
+
LoggingInterface_1.Logger.info('\nStopping file watcher...');
|
|
220
|
+
watcher.close();
|
|
221
|
+
};
|
|
222
|
+
// Handle process signals for graceful shutdown
|
|
223
|
+
// eslint-disable-next-line no-undef
|
|
224
|
+
process.on('SIGINT', cleanup);
|
|
225
|
+
// eslint-disable-next-line no-undef
|
|
226
|
+
process.on('SIGTERM', cleanup);
|
|
227
|
+
// Keep the process alive by waiting indefinitely
|
|
228
|
+
return new Promise(() => {
|
|
229
|
+
// This promise never resolves, keeping the process alive
|
|
230
|
+
// The process will exit when SIGINT/SIGTERM is received
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
async handleWatchModeStartedTelemetry({ context, inputSource }) {
|
|
234
|
+
const projectTelemetryConfig = context.configuration.telemetry;
|
|
235
|
+
// Track watch mode started (fire and forget, never throws)
|
|
236
|
+
(0, telemetry_1.trackEvent)({
|
|
237
|
+
event: 'watch_mode_started',
|
|
238
|
+
command: 'generate',
|
|
239
|
+
input_source: inputSource
|
|
240
|
+
}, projectTelemetryConfig);
|
|
241
|
+
}
|
|
242
|
+
async handleGeneratorUsageTelemetry({ context, inputSource }) {
|
|
243
|
+
const projectTelemetryConfig = context.configuration.telemetry;
|
|
244
|
+
// Track each generator usage (fire and forget, never throws)
|
|
245
|
+
for (const generator of context.configuration.generators) {
|
|
246
|
+
const generatorStartTime = Date.now();
|
|
247
|
+
const language = generator.language ||
|
|
248
|
+
context.configuration.language ||
|
|
249
|
+
'typescript';
|
|
250
|
+
// Sanitize options - remove sensitive data like paths
|
|
251
|
+
const { id, preset, outputPath, dependencies, ...sanitizedOptions } = generator;
|
|
252
|
+
(0, telemetry_1.trackEvent)({
|
|
253
|
+
event: 'generator_used',
|
|
254
|
+
generator_type: generator.preset,
|
|
255
|
+
input_type: context.configuration.inputType,
|
|
256
|
+
input_source: inputSource,
|
|
257
|
+
language,
|
|
258
|
+
options: JSON.stringify(sanitizedOptions),
|
|
259
|
+
duration: Date.now() - generatorStartTime,
|
|
260
|
+
success: true
|
|
261
|
+
}, projectTelemetryConfig);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
async handleSuccessfulGenerateTelemetry({ context, flags, inputSource, startTime }) {
|
|
265
|
+
const projectTelemetryConfig = context.configuration.telemetry;
|
|
266
|
+
// Track successful execution with generator combination (fire and forget, never throws)
|
|
267
|
+
const activeFlags = Object.keys(flags).filter((f) => flags[f]);
|
|
268
|
+
const generatorPresets = context.configuration.generators.map((g) => g.preset);
|
|
269
|
+
(0, telemetry_1.trackEvent)({
|
|
270
|
+
event: 'command_executed',
|
|
271
|
+
command: 'generate',
|
|
272
|
+
flags: activeFlags.length > 0 ? activeFlags.join(',') : 'none',
|
|
273
|
+
input_source: inputSource || 'unknown',
|
|
274
|
+
input_type: context.configuration.inputType,
|
|
275
|
+
generators: generatorPresets.join(','),
|
|
276
|
+
generator_count: context.configuration.generators.length,
|
|
277
|
+
duration: Date.now() - startTime,
|
|
278
|
+
success: true
|
|
279
|
+
}, projectTelemetryConfig);
|
|
280
|
+
}
|
|
281
|
+
async handleFailedGenerateTelemetry({ error, context, flags, inputSource, startTime }) {
|
|
282
|
+
// Try to get project config for telemetry, but don't fail if we can't
|
|
283
|
+
const projectTelemetryConfig = context.configuration.telemetry;
|
|
284
|
+
const generators = context.configuration.generators.map((g) => g.preset);
|
|
285
|
+
const generatorCount = context.configuration.generators.length;
|
|
286
|
+
const inputType = context.configuration.inputType;
|
|
287
|
+
// Track failed execution (fire and forget, never throws)
|
|
288
|
+
const activeFlags = Object.keys(flags).filter((f) => flags[f]);
|
|
289
|
+
(0, telemetry_1.trackEvent)({
|
|
290
|
+
event: 'command_executed',
|
|
291
|
+
command: 'generate',
|
|
292
|
+
flags: activeFlags.length > 0 ? activeFlags.join(',') : 'none',
|
|
293
|
+
input_source: inputSource || 'unknown',
|
|
294
|
+
input_type: inputType,
|
|
295
|
+
generators: Array.isArray(generators)
|
|
296
|
+
? generators.join(',')
|
|
297
|
+
: String(generators),
|
|
298
|
+
generator_count: generatorCount,
|
|
299
|
+
duration: Date.now() - startTime,
|
|
300
|
+
success: false,
|
|
301
|
+
error_type: (0, anonymize_1.categorizeError)(error)
|
|
302
|
+
}, projectTelemetryConfig);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.default = Generate;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BaseCommand } from './base';
|
|
2
|
+
declare const ConfigOptions: readonly ["esm", "json", "yaml", "ts"];
|
|
3
|
+
declare const LanguageOptions: readonly ["typescript"];
|
|
4
|
+
interface FlagTypes {
|
|
5
|
+
inputFile: string;
|
|
6
|
+
inputType: string;
|
|
7
|
+
configName: string;
|
|
8
|
+
configType: (typeof ConfigOptions)[number];
|
|
9
|
+
outputDirectory: string;
|
|
10
|
+
includePayloads: boolean;
|
|
11
|
+
includeParameters: boolean;
|
|
12
|
+
includeChannels: boolean;
|
|
13
|
+
includeClient: boolean;
|
|
14
|
+
includeHeaders: boolean;
|
|
15
|
+
languages: (typeof LanguageOptions)[number];
|
|
16
|
+
noOutput: boolean;
|
|
17
|
+
gitignoreGenerated: boolean;
|
|
18
|
+
}
|
|
19
|
+
export default class Init extends BaseCommand {
|
|
20
|
+
static description: string;
|
|
21
|
+
static args: {};
|
|
22
|
+
static flags: {
|
|
23
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
24
|
+
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
25
|
+
quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
26
|
+
'no-color': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
27
|
+
'input-file': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
28
|
+
'config-name': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
29
|
+
'input-type': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
30
|
+
'output-directory': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
31
|
+
'config-type': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
32
|
+
languages: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
33
|
+
'no-tty': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
34
|
+
'include-payloads': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
35
|
+
'include-headers': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
36
|
+
'include-client': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
37
|
+
'include-parameters': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
38
|
+
'include-channels': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
39
|
+
'no-output': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
40
|
+
'gitignore-generated': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
41
|
+
};
|
|
42
|
+
run(): Promise<void>;
|
|
43
|
+
realizeConfigFile(flags: FlagTypes): string;
|
|
44
|
+
realizeFlags(flags: any): FlagTypes;
|
|
45
|
+
/**
|
|
46
|
+
* Interactively ask the user for which configuration to create
|
|
47
|
+
*/
|
|
48
|
+
runInteractive(flags: FlagTypes): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Based on the flags, create the appropriate configuration file
|
|
51
|
+
*/
|
|
52
|
+
createConfiguration(flags: FlagTypes): Promise<void>;
|
|
53
|
+
handleSuccessfulInitTelemetry(flags: FlagTypes): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export {};
|