@fluojs/cli 1.0.6 → 2.0.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.
Files changed (51) hide show
  1. package/README.ko.md +31 -10
  2. package/README.md +31 -10
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +4 -3
  5. package/dist/commands/generate.d.ts +1 -49
  6. package/dist/commands/generate.d.ts.map +1 -1
  7. package/dist/commands/generate.js +1 -214
  8. package/dist/commands/inspect.d.ts +0 -6
  9. package/dist/commands/inspect.d.ts.map +1 -1
  10. package/dist/commands/inspect.js +1 -48
  11. package/dist/commands/new.d.ts +0 -6
  12. package/dist/commands/new.d.ts.map +1 -1
  13. package/dist/commands/new.js +14 -88
  14. package/dist/commands/scripts.d.ts +1 -1
  15. package/dist/commands/scripts.d.ts.map +1 -1
  16. package/dist/commands/scripts.js +16 -7
  17. package/dist/dev-runner/node-restart-runner.d.ts +6 -0
  18. package/dist/dev-runner/node-restart-runner.d.ts.map +1 -1
  19. package/dist/dev-runner/node-restart-runner.js +43 -8
  20. package/dist/generate-command.d.ts +50 -0
  21. package/dist/generate-command.d.ts.map +1 -0
  22. package/dist/generate-command.js +214 -0
  23. package/dist/index.d.ts +4 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +4 -2
  26. package/dist/new/scaffold.d.ts.map +1 -1
  27. package/dist/new/scaffold.js +115 -23
  28. package/dist/new/types.d.ts +0 -2
  29. package/dist/new/types.d.ts.map +1 -1
  30. package/dist/public-generate.d.ts +2 -0
  31. package/dist/public-generate.d.ts.map +1 -0
  32. package/dist/public-generate.js +1 -0
  33. package/dist/public-inspect.d.ts +13 -0
  34. package/dist/public-inspect.d.ts.map +1 -0
  35. package/dist/public-inspect.js +16 -0
  36. package/dist/public-new.d.ts +13 -0
  37. package/dist/public-new.d.ts.map +1 -0
  38. package/dist/public-new.js +16 -0
  39. package/dist/run-cli.d.ts +16 -0
  40. package/dist/run-cli.d.ts.map +1 -0
  41. package/dist/run-cli.js +16 -0
  42. package/dist/studio/sidecar.d.ts.map +1 -1
  43. package/dist/studio/sidecar.js +113 -27
  44. package/dist/types.d.ts +6 -1
  45. package/dist/types.d.ts.map +1 -1
  46. package/dist/update-check.d.ts.map +1 -1
  47. package/dist/update-check.js +21 -4
  48. package/dist/usage.d.ts +13 -0
  49. package/dist/usage.d.ts.map +1 -0
  50. package/dist/usage.js +131 -0
  51. package/package.json +3 -3
@@ -0,0 +1,214 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { basename, dirname, join, normalize, relative, resolve, sep } from 'node:path';
3
+ import { findGeneratorDefinition } from './generators/manifest.js';
4
+ import { ensureModuleImport, generateModuleFiles, registerInModule } from './generators/module.js';
5
+ import { toKebabCase, toPascalCase, toPlural } from './generators/utils.js';
6
+ function writeFileIfChanged(filePath, content) {
7
+ if (existsSync(filePath) && readFileSync(filePath, 'utf8') === content) {
8
+ return false;
9
+ }
10
+ writeFileSync(filePath, content, 'utf8');
11
+ return true;
12
+ }
13
+
14
+ /** Describes how one generated artifact would interact with the workspace. */
15
+
16
+ /** One path-level action reported by generate dry-run previews and structured results. */
17
+
18
+ function planFileWrite(filePath, content, options) {
19
+ if (!existsSync(filePath)) {
20
+ return {
21
+ action: 'create',
22
+ path: filePath
23
+ };
24
+ }
25
+ if (!options.force) {
26
+ return {
27
+ action: 'skip',
28
+ path: filePath
29
+ };
30
+ }
31
+ if (readFileSync(filePath, 'utf8') === content) {
32
+ return {
33
+ action: 'unchanged',
34
+ path: filePath
35
+ };
36
+ }
37
+ return {
38
+ action: 'overwrite',
39
+ path: filePath
40
+ };
41
+ }
42
+ function planModuleWrite(modulePath, content) {
43
+ if (!existsSync(modulePath)) {
44
+ return {
45
+ action: 'module-create',
46
+ path: modulePath
47
+ };
48
+ }
49
+ if (readFileSync(modulePath, 'utf8') === content) {
50
+ return {
51
+ action: 'module-unchanged',
52
+ path: modulePath
53
+ };
54
+ }
55
+ return {
56
+ action: 'module-update',
57
+ path: modulePath
58
+ };
59
+ }
60
+ function createGeneratorOptions(kind, domainDirectory, kebab, options, resolvedBase) {
61
+ return {
62
+ ...options,
63
+ e2eRootModuleImport: options.e2eRootModuleImport ?? (kind === 'e2e' ? resolveE2eRootModuleImport(domainDirectory, resolvedBase) : undefined),
64
+ hasRepo: options.hasRepo ?? (kind === 'service' ? existsSync(join(domainDirectory, `${kebab}.repo.ts`)) : undefined),
65
+ hasService: options.hasService ?? (kind === 'controller' ? existsSync(join(domainDirectory, `${kebab}.service.ts`)) : undefined)
66
+ };
67
+ }
68
+ function toImportSpecifier(path) {
69
+ const normalized = path.split(sep).join('/');
70
+ return normalized.startsWith('.') ? normalized : `./${normalized}`;
71
+ }
72
+ function resolveE2eRootModuleImport(domainDirectory, resolvedBase) {
73
+ return toImportSpecifier(relative(domainDirectory, join(resolvedBase, 'app')));
74
+ }
75
+ function resolveDomainDirectory(kind, resolvedBase, kebab, options) {
76
+ if (kind === 'e2e') {
77
+ return basename(resolvedBase) === 'src' ? join(dirname(resolvedBase), 'test') : join(resolvedBase, 'test');
78
+ }
79
+ if (kind === 'request-dto' && options.targetFeature !== undefined) {
80
+ const normalizedFeature = options.targetFeature.trim();
81
+ const featureKebab = assertValidResourceName(normalizedFeature);
82
+ const featureDirectory = /^[A-Z]/u.test(normalizedFeature) ? toPlural(featureKebab) : featureKebab;
83
+ return join(resolvedBase, featureDirectory);
84
+ }
85
+ return join(resolvedBase, toPlural(kebab));
86
+ }
87
+ function assertValidResourceName(name) {
88
+ const kebab = toKebabCase(name);
89
+ if (name.trim().length === 0) {
90
+ throw new Error('Invalid resource name: name must not be empty.');
91
+ }
92
+ if (kebab !== normalize(kebab) || kebab.includes('/') || kebab.includes('\\') || kebab.includes('..')) {
93
+ throw new Error(`Invalid resource name "${name}": must not contain path separators or traversal sequences.`);
94
+ }
95
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(kebab)) {
96
+ throw new Error(`Invalid resource name "${name}": use letters, numbers, spaces, underscores, or hyphens only.`);
97
+ }
98
+ return kebab;
99
+ }
100
+ function resolveModulePath(domainDirectory, name) {
101
+ const kebab = toKebabCase(name);
102
+ return join(domainDirectory, `${kebab}.module.ts`);
103
+ }
104
+ function readOrCreateModuleSource(modulePath, name) {
105
+ if (existsSync(modulePath)) {
106
+ return readFileSync(modulePath, 'utf8');
107
+ }
108
+ const [moduleFile] = generateModuleFiles(name);
109
+ if (!moduleFile) {
110
+ throw new Error(`Unable to generate module file for resource "${name}".`);
111
+ }
112
+ return moduleFile.content;
113
+ }
114
+ function buildUpdatedModuleSource(moduleSource, arrayKey, className, importPath) {
115
+ let source = moduleSource;
116
+ source = ensureModuleImport(source, className, importPath);
117
+ source = registerInModule(source, arrayKey, className);
118
+ return source;
119
+ }
120
+ function prepareModuleUpdate(domainDirectory, normalizedName, kind, classSuffix, arrayKey) {
121
+ const kebab = toKebabCase(normalizedName);
122
+ const modulePath = resolveModulePath(domainDirectory, normalizedName);
123
+ const className = `${toPascalCase(normalizedName)}${classSuffix}`;
124
+ const importPath = `${kebab}.${kind}`;
125
+ const moduleSource = readOrCreateModuleSource(modulePath, normalizedName);
126
+ return {
127
+ modulePath,
128
+ source: buildUpdatedModuleSource(moduleSource, arrayKey, className, importPath)
129
+ };
130
+ }
131
+
132
+ /**
133
+ * Structured result returned by {@link runGenerateCommand} for tooling-friendly automation.
134
+ *
135
+ * `generatedFiles` only includes files whose on-disk content changed during the command.
136
+ * `moduleRegistered` reports whether the target schematic participates in automatic module wiring,
137
+ * even when the target module file was already up to date.
138
+ */
139
+
140
+ /**
141
+ * Generates one CLI schematic into a source directory and returns structured wiring metadata.
142
+ *
143
+ * The command keeps generation idempotent where possible: unchanged files are not rewritten, and
144
+ * auto-registered schematics reuse an existing module file when it already contains the required import
145
+ * and registration entry.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * const result = runGenerateCommand('service', 'Post', './src');
150
+ *
151
+ * console.log(result.wiringBehavior);
152
+ * console.log(result.nextStepHint);
153
+ * ```
154
+ *
155
+ * @param kind Generator kind to execute.
156
+ * @param name Resource name supplied by the caller before normalization.
157
+ * @param baseDirectory Source directory that should receive the generated domain folder.
158
+ * @param options Optional generation flags that control overwrites, request DTO feature placement, and sibling-aware templates.
159
+ * @returns Structured file and wiring metadata for the completed generation run.
160
+ * @throws {Error} When the resource name is invalid, the generator kind is unknown, or the target module source cannot be updated safely.
161
+ */
162
+ export function runGenerateCommand(kind, name, baseDirectory, options = {}) {
163
+ const normalizedName = name.trim();
164
+ const kebab = assertValidResourceName(normalizedName);
165
+ const generator = findGeneratorDefinition(kind);
166
+ const resolvedBase = resolve(baseDirectory);
167
+ const domainDirectory = resolveDomainDirectory(kind, resolvedBase, kebab, options);
168
+ const generatorOptions = createGeneratorOptions(kind, domainDirectory, kebab, options, resolvedBase);
169
+ const files = generator.factory(normalizedName, generatorOptions);
170
+ const moduleRegistration = 'moduleRegistration' in generator ? generator.moduleRegistration : undefined;
171
+ const moduleUpdate = moduleRegistration ? prepareModuleUpdate(domainDirectory, normalizedName, kind, moduleRegistration.classSuffix, moduleRegistration.arrayKey) : undefined;
172
+ const plannedFiles = files.map(file => planFileWrite(join(domainDirectory, file.path), file.content, options));
173
+ const modulePlan = moduleUpdate ? planModuleWrite(moduleUpdate.modulePath, moduleUpdate.source) : undefined;
174
+ if (options.dryRun) {
175
+ return {
176
+ generatedFiles: [],
177
+ moduleRegistered: moduleUpdate !== undefined,
178
+ modulePath: moduleUpdate?.modulePath,
179
+ nextStepHint: generator.nextStepHint,
180
+ plannedFiles: modulePlan ? [...plannedFiles, modulePlan] : plannedFiles,
181
+ wiringBehavior: generator.wiringBehavior
182
+ };
183
+ }
184
+ mkdirSync(domainDirectory, {
185
+ recursive: true
186
+ });
187
+ const writtenPaths = files.map(file => {
188
+ const filePath = join(domainDirectory, file.path);
189
+ if (!options.force && existsSync(filePath)) {
190
+ return null;
191
+ }
192
+ return writeFileIfChanged(filePath, file.content) ? filePath : null;
193
+ }).filter(filePath => filePath !== null);
194
+ let moduleRegistered = false;
195
+ let resolvedModulePath;
196
+ if (moduleUpdate && writeFileIfChanged(moduleUpdate.modulePath, moduleUpdate.source)) {
197
+ moduleRegistered = true;
198
+ resolvedModulePath = moduleUpdate.modulePath;
199
+ if (!writtenPaths.includes(moduleUpdate.modulePath)) {
200
+ writtenPaths.push(moduleUpdate.modulePath);
201
+ }
202
+ } else if (moduleUpdate) {
203
+ moduleRegistered = true;
204
+ resolvedModulePath = moduleUpdate.modulePath;
205
+ }
206
+ return {
207
+ generatedFiles: writtenPaths,
208
+ moduleRegistered: moduleRegistered,
209
+ modulePath: resolvedModulePath,
210
+ nextStepHint: generator.nextStepHint,
211
+ plannedFiles: modulePlan ? [...plannedFiles, modulePlan] : plannedFiles,
212
+ wiringBehavior: generator.wiringBehavior
213
+ };
214
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export { runCli, type CliRuntimeOptions } from './cli.js';
2
- export { newUsage, runNewCommand, type NewCommandRuntimeOptions } from './commands/new.js';
1
+ export { runCli, type CliRuntimeOptions } from './run-cli.js';
2
+ export { runGenerateCommand, type GeneratePlanAction, type GeneratePlanEntry, type GenerateResult } from './public-generate.js';
3
+ export { inspectUsage, runInspectCommand, type InspectCommandRuntimeOptions } from './public-inspect.js';
4
+ export { newUsage, runNewCommand, type NewCommandRuntimeOptions } from './public-new.js';
3
5
  export { CliPromptCancelledError } from './prompt-cancel.js';
4
6
  export type { GenerateOptions, GeneratedFile, GeneratorKind, ModuleRegistration } from './types.js';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChI,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,KAAK,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACzG,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
- export { runCli } from './cli.js';
2
- export { newUsage, runNewCommand } from './commands/new.js';
1
+ export { runCli } from './run-cli.js';
2
+ export { runGenerateCommand } from './public-generate.js';
3
+ export { inspectUsage, runInspectCommand } from './public-inspect.js';
4
+ export { newUsage, runNewCommand } from './public-new.js';
3
5
  export { CliPromptCancelledError } from './prompt-cancel.js';
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/new/scaffold.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AA8xEnE;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,gBAAgB,EACzB,aAAa,SAAkB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,6BAAuB,CAAC"}
1
+ {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/new/scaffold.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AA03EnE;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,gBAAgB,EACzB,aAAa,SAAkB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,6BAAuB,CAAC"}
@@ -1050,13 +1050,36 @@ const codec = JSONCodec();
1050
1050
 
1051
1051
  class LazyNatsTransport implements MicroserviceTransport {
1052
1052
  private connection: NatsConnection | undefined;
1053
+ private initializing: Promise<NatsMicroserviceTransport> | undefined;
1053
1054
  private transport: NatsMicroserviceTransport | undefined;
1054
1055
 
1055
1056
  async close() {
1056
- await this.transport?.close();
1057
- await this.connection?.close();
1058
- this.transport = undefined;
1059
- this.connection = undefined;
1057
+ const transport = this.initializing ? await this.initializing.catch(() => undefined) : this.transport;
1058
+ let closeError: unknown;
1059
+ let closeFailed = false;
1060
+ try {
1061
+ await transport?.close();
1062
+ } catch (error) {
1063
+ closeError = error;
1064
+ closeFailed = true;
1065
+ } finally {
1066
+ try {
1067
+ await this.connection?.close();
1068
+ } catch (error) {
1069
+ if (!closeFailed) {
1070
+ closeError = error;
1071
+ closeFailed = true;
1072
+ }
1073
+ } finally {
1074
+ this.initializing = undefined;
1075
+ this.transport = undefined;
1076
+ this.connection = undefined;
1077
+ }
1078
+ }
1079
+
1080
+ if (closeFailed) {
1081
+ throw closeError;
1082
+ }
1060
1083
  }
1061
1084
 
1062
1085
  async emit(pattern: string, payload: unknown) {
@@ -1076,6 +1099,19 @@ class LazyNatsTransport implements MicroserviceTransport {
1076
1099
  return this.transport;
1077
1100
  }
1078
1101
 
1102
+ this.initializing ??= this.createTransport();
1103
+ try {
1104
+ return await this.initializing;
1105
+ } finally {
1106
+ this.initializing = undefined;
1107
+ }
1108
+ }
1109
+
1110
+ private async createTransport() {
1111
+ if (this.transport) {
1112
+ return this.transport;
1113
+ }
1114
+
1079
1115
  const connection = await connect({
1080
1116
  name: 'fluo-microservice-starter',
1081
1117
  servers,
@@ -1149,18 +1185,24 @@ const responseTopic = process.env.KAFKA_RESPONSE_TOPIC ?? 'fluo.microservices.re
1149
1185
 
1150
1186
  class LazyKafkaTransport implements MicroserviceTransport {
1151
1187
  private consumer: Consumer | undefined;
1188
+ private initializing: Promise<KafkaMicroserviceTransport> | undefined;
1152
1189
  private producer: Producer | undefined;
1153
1190
  private transport: KafkaMicroserviceTransport | undefined;
1154
1191
 
1155
1192
  async close() {
1156
- await this.transport?.close();
1157
- await Promise.all([
1158
- this.consumer?.disconnect().catch(() => undefined),
1159
- this.producer?.disconnect().catch(() => undefined),
1160
- ]);
1161
- this.consumer = undefined;
1162
- this.producer = undefined;
1163
- this.transport = undefined;
1193
+ const transport = this.initializing ? await this.initializing.catch(() => undefined) : this.transport;
1194
+ try {
1195
+ await transport?.close();
1196
+ } finally {
1197
+ await Promise.all([
1198
+ this.consumer?.disconnect().catch(() => undefined),
1199
+ this.producer?.disconnect().catch(() => undefined),
1200
+ ]);
1201
+ this.initializing = undefined;
1202
+ this.consumer = undefined;
1203
+ this.producer = undefined;
1204
+ this.transport = undefined;
1205
+ }
1164
1206
  }
1165
1207
 
1166
1208
  async emit(pattern: string, payload: unknown) {
@@ -1180,6 +1222,19 @@ class LazyKafkaTransport implements MicroserviceTransport {
1180
1222
  return this.transport;
1181
1223
  }
1182
1224
 
1225
+ this.initializing ??= this.createTransport();
1226
+ try {
1227
+ return await this.initializing;
1228
+ } finally {
1229
+ this.initializing = undefined;
1230
+ }
1231
+ }
1232
+
1233
+ private async createTransport() {
1234
+ if (this.transport) {
1235
+ return this.transport;
1236
+ }
1237
+
1183
1238
  const kafka = new Kafka({
1184
1239
  brokers,
1185
1240
  clientId,
@@ -1187,13 +1242,24 @@ class LazyKafkaTransport implements MicroserviceTransport {
1187
1242
  });
1188
1243
  const producer = kafka.producer();
1189
1244
  const consumer = kafka.consumer({ groupId: consumerGroup });
1190
- await Promise.all([producer.connect(), consumer.connect()]);
1245
+ this.producer = producer;
1246
+ this.consumer = consumer;
1247
+ try {
1248
+ await producer.connect();
1249
+ await consumer.connect();
1250
+ } catch (error) {
1251
+ await Promise.all([
1252
+ consumer.disconnect().catch(() => undefined),
1253
+ producer.disconnect().catch(() => undefined),
1254
+ ]);
1255
+ this.consumer = undefined;
1256
+ this.producer = undefined;
1257
+ throw error;
1258
+ }
1191
1259
 
1192
1260
  const handlers = new Map<string, (message: string) => Promise<void> | void>();
1193
1261
  let consumerRunning = false;
1194
1262
 
1195
- this.producer = producer;
1196
- this.consumer = consumer;
1197
1263
  this.transport = new KafkaMicroserviceTransport({
1198
1264
  consumer: {
1199
1265
  async subscribe(topic: string, handler: (message: string) => Promise<void> | void) {
@@ -1277,15 +1343,21 @@ const responseQueue = process.env.RABBITMQ_RESPONSE_QUEUE ?? 'fluo.microservices
1277
1343
  class LazyRabbitMqTransport implements MicroserviceTransport {
1278
1344
  private channel: Awaited<ReturnType<Awaited<ReturnType<typeof connect>>['createConfirmChannel']>> | undefined;
1279
1345
  private connection: Awaited<ReturnType<typeof connect>> | undefined;
1346
+ private initializing: Promise<RabbitMqMicroserviceTransport> | undefined;
1280
1347
  private transport: RabbitMqMicroserviceTransport | undefined;
1281
1348
 
1282
1349
  async close() {
1283
- await this.transport?.close();
1284
- await this.channel?.close().catch(() => undefined);
1285
- await this.connection?.close().catch(() => undefined);
1286
- this.channel = undefined;
1287
- this.connection = undefined;
1288
- this.transport = undefined;
1350
+ const transport = this.initializing ? await this.initializing.catch(() => undefined) : this.transport;
1351
+ try {
1352
+ await transport?.close();
1353
+ } finally {
1354
+ await this.channel?.close().catch(() => undefined);
1355
+ await this.connection?.close().catch(() => undefined);
1356
+ this.initializing = undefined;
1357
+ this.channel = undefined;
1358
+ this.connection = undefined;
1359
+ this.transport = undefined;
1360
+ }
1289
1361
  }
1290
1362
 
1291
1363
  async emit(pattern: string, payload: unknown) {
@@ -1305,11 +1377,31 @@ class LazyRabbitMqTransport implements MicroserviceTransport {
1305
1377
  return this.transport;
1306
1378
  }
1307
1379
 
1380
+ this.initializing ??= this.createTransport();
1381
+ try {
1382
+ return await this.initializing;
1383
+ } finally {
1384
+ this.initializing = undefined;
1385
+ }
1386
+ }
1387
+
1388
+ private async createTransport() {
1389
+ if (this.transport) {
1390
+ return this.transport;
1391
+ }
1392
+
1308
1393
  const connection = await connect(url);
1309
- const channel = await connection.createConfirmChannel();
1394
+ this.connection = connection;
1395
+ let channel: Awaited<ReturnType<typeof connection.createConfirmChannel>>;
1396
+ try {
1397
+ channel = await connection.createConfirmChannel();
1398
+ } catch (error) {
1399
+ await connection.close().catch(() => undefined);
1400
+ this.connection = undefined;
1401
+ throw error;
1402
+ }
1310
1403
  const consumerTags = new Map<string, string>();
1311
1404
 
1312
- this.connection = connection;
1313
1405
  this.channel = channel;
1314
1406
  this.transport = new RabbitMqMicroserviceTransport({
1315
1407
  consumer: {
@@ -53,11 +53,9 @@ export interface BootstrapAnswers extends BootstrapSchema {
53
53
  }
54
54
  /** Programmatic overrides for `runNewCommand(...)`. */
55
55
  export interface NewCommandOptions {
56
- dependencySource?: DependencySource;
57
56
  force?: boolean;
58
57
  initializeGit?: boolean;
59
58
  installDependencies?: boolean;
60
- repoRoot?: string;
61
59
  skipInstall?: boolean;
62
60
  }
63
61
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/new/types.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAC7D,yDAAyD;AACzD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,WAAW,CAAC;AACrD,+CAA+C;AAC/C,MAAM,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,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export { type GeneratePlanAction, type GeneratePlanEntry, type GenerateResult, runGenerateCommand } from './generate-command.js';
2
+ //# sourceMappingURL=public-generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-generate.d.ts","sourceRoot":"","sources":["../src/public-generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ export { runGenerateCommand } from './generate-command.js';
@@ -0,0 +1,13 @@
1
+ import type { InspectCommandRuntimeOptions } from './commands/inspect.js';
2
+ import { inspectUsage } from './usage.js';
3
+ export type { InspectCommandRuntimeOptions } from './commands/inspect.js';
4
+ export { inspectUsage };
5
+ /**
6
+ * Runs the inspect command through a lazy implementation import.
7
+ *
8
+ * @param argv Command arguments after `inspect`.
9
+ * @param runtime Runtime overrides for programmatic callers.
10
+ * @returns Process-style exit code from the inspect command.
11
+ */
12
+ export declare function runInspectCommand(argv: string[], runtime?: InspectCommandRuntimeOptions): Promise<number>;
13
+ //# sourceMappingURL=public-inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-inspect.d.ts","sourceRoot":"","sources":["../src/public-inspect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,YAAY,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,4BAAiC,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnH"}
@@ -0,0 +1,16 @@
1
+ import { inspectUsage } from './usage.js';
2
+ export { inspectUsage };
3
+
4
+ /**
5
+ * Runs the inspect command through a lazy implementation import.
6
+ *
7
+ * @param argv Command arguments after `inspect`.
8
+ * @param runtime Runtime overrides for programmatic callers.
9
+ * @returns Process-style exit code from the inspect command.
10
+ */
11
+ export async function runInspectCommand(argv, runtime = {}) {
12
+ const {
13
+ runInspectCommand: runInspectCommandImplementation
14
+ } = await import('./commands/inspect.js');
15
+ return runInspectCommandImplementation(argv, runtime);
16
+ }
@@ -0,0 +1,13 @@
1
+ import type { NewCommandRuntimeOptions } from './commands/new.js';
2
+ import { newUsage } from './usage.js';
3
+ export type { NewCommandRuntimeOptions } from './commands/new.js';
4
+ export { newUsage };
5
+ /**
6
+ * Runs the new command through a lazy implementation import.
7
+ *
8
+ * @param argv Command arguments after `new` or `create`.
9
+ * @param runtime Runtime overrides for programmatic callers.
10
+ * @returns Process-style exit code from the new command.
11
+ */
12
+ export declare function runNewCommand(argv: string[], runtime?: NewCommandRuntimeOptions): Promise<number>;
13
+ //# sourceMappingURL=public-new.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-new.d.ts","sourceRoot":"","sources":["../src/public-new.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAG3G"}
@@ -0,0 +1,16 @@
1
+ import { newUsage } from './usage.js';
2
+ export { newUsage };
3
+
4
+ /**
5
+ * Runs the new command through a lazy implementation import.
6
+ *
7
+ * @param argv Command arguments after `new` or `create`.
8
+ * @param runtime Runtime overrides for programmatic callers.
9
+ * @returns Process-style exit code from the new command.
10
+ */
11
+ export async function runNewCommand(argv, runtime = {}) {
12
+ const {
13
+ runNewCommand: runNewCommandImplementation
14
+ } = await import('./commands/new.js');
15
+ return runNewCommandImplementation(argv, runtime);
16
+ }
@@ -0,0 +1,16 @@
1
+ import type { CliRuntimeOptions } from './cli.js';
2
+ import type { InspectCommandRuntimeOptions } from './commands/inspect.js';
3
+ import type { NewCommandRuntimeOptions } from './commands/new.js';
4
+ export type { CliRuntimeOptions } from './cli.js';
5
+ /**
6
+ * Runs the top-level CLI command dispatcher through a lazy implementation import.
7
+ *
8
+ * This keeps the package root embeddable for tools that only need lightweight helpers while preserving
9
+ * the same `runCli(...)` behavior as the published `fluo` binary when callers execute it.
10
+ *
11
+ * @param argv Argument vector to execute. Defaults to the current process arguments inside the dispatcher.
12
+ * @param runtime Optional runtime overrides shared by the top-level dispatcher and delegated commands.
13
+ * @returns `0` when the command completes successfully, otherwise the delegated command exit code.
14
+ */
15
+ export declare function runCli(argv?: string[], runtime?: CliRuntimeOptions & NewCommandRuntimeOptions & InspectCommandRuntimeOptions): Promise<number>;
16
+ //# sourceMappingURL=run-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-cli.d.ts","sourceRoot":"","sources":["../src/run-cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;;;GASG;AACH,wBAAsB,MAAM,CAC1B,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,OAAO,GAAE,iBAAiB,GAAG,wBAAwB,GAAG,4BAAiC,GACxF,OAAO,CAAC,MAAM,CAAC,CAGjB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Runs the top-level CLI command dispatcher through a lazy implementation import.
3
+ *
4
+ * This keeps the package root embeddable for tools that only need lightweight helpers while preserving
5
+ * the same `runCli(...)` behavior as the published `fluo` binary when callers execute it.
6
+ *
7
+ * @param argv Argument vector to execute. Defaults to the current process arguments inside the dispatcher.
8
+ * @param runtime Optional runtime overrides shared by the top-level dispatcher and delegated commands.
9
+ * @returns `0` when the command completes successfully, otherwise the delegated command exit code.
10
+ */
11
+ export async function runCli(argv, runtime = {}) {
12
+ const {
13
+ runCli: runCliImplementation
14
+ } = await import('./cli.js');
15
+ return runCliImplementation(argv, runtime);
16
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"sidecar.d.ts","sourceRoot":"","sources":["../../src/studio/sidecar.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB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