@arrirpc/codegen-dart 0.86.0 → 0.86.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/README.md CHANGED
@@ -20,13 +20,14 @@ export default defineConfig({
20
20
 
21
21
  **Options:**
22
22
 
23
- | Name | Description |
24
- | --------------------- | ------------------------------------------------------------- |
25
- | outputFile (required) | Path to the file that will be created by the generator |
26
- | clientName | The name of the generated client class (Defaults to "Client") |
27
- | format | Run `dart format` on the generated file (Defaults to `true`) |
28
- | typePrefix | Add a prefix to the generated class names |
29
- | rootService | The root service of the generated client |
23
+ | Name | Description |
24
+ | --------------------- | ------------------------------------------------------------------------------------------------------------- |
25
+ | outputFile (required) | Path to the file that will be created by the generator |
26
+ | clientName | The name of the generated client class (Defaults to "Client") |
27
+ | format | Run `dart format` on the generated file (Defaults to `true`) |
28
+ | formatLanguageVersion | Language version passed to `dart format`. When unset, `dart format` infers it from the nearest package config |
29
+ | typePrefix | Add a prefix to the generated class names |
30
+ | rootService | The root service of the generated client |
30
31
 
31
32
  ### 2) Install the Dart client library
32
33
 
package/dist/index.cjs CHANGED
@@ -1303,7 +1303,12 @@ function dartRefFromSchema(schema, context) {
1303
1303
  };
1304
1304
  }
1305
1305
 
1306
- const dartFormatLanguageVersion = "3.7";
1306
+ function dartFormatCommand(destination, options) {
1307
+ if (options.formatLanguageVersion) {
1308
+ return `dart format --language-version=${options.formatLanguageVersion} ${destination}`;
1309
+ }
1310
+ return `dart format ${destination}`;
1311
+ }
1307
1312
  const dartClientGenerator = codegenUtils.defineGeneratorPlugin(
1308
1313
  (options) => {
1309
1314
  return {
@@ -1319,9 +1324,7 @@ const dartClientGenerator = codegenUtils.defineGeneratorPlugin(
1319
1324
  const destination = path__default.resolve(options.outputFile);
1320
1325
  await fs__default.writeFile(destination, result);
1321
1326
  if (options.format !== false) {
1322
- node_child_process.execSync(
1323
- `dart format --language-version=${dartFormatLanguageVersion} ${destination}`
1324
- );
1327
+ node_child_process.execSync(dartFormatCommand(destination, options));
1325
1328
  }
1326
1329
  } catch (err) {
1327
1330
  console.error(err);
@@ -1497,4 +1500,5 @@ function dartTypeFromSchema(schema, context) {
1497
1500
 
1498
1501
  exports.createDartClient = createDartClient;
1499
1502
  exports.dartClientGenerator = dartClientGenerator;
1503
+ exports.dartFormatCommand = dartFormatCommand;
1500
1504
  exports.dartTypeFromSchema = dartTypeFromSchema;
package/dist/index.d.cts CHANGED
@@ -31,11 +31,16 @@ interface DartClientGeneratorOptions {
31
31
  */
32
32
  typePrefix?: string;
33
33
  format?: boolean;
34
+ /**
35
+ * The language version passed to `dart format`. When unset, `dart format` infers it from the nearest package config.
36
+ */
37
+ formatLanguageVersion?: string;
34
38
  rootService?: string;
35
39
  }
40
+ declare function dartFormatCommand(destination: string, options: Pick<DartClientGeneratorOptions, 'formatLanguageVersion'>): string;
36
41
  declare const dartClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<DartClientGeneratorOptions>;
37
42
  declare function createDartClient(def: AppDefinition, options: DartClientGeneratorOptions): string;
38
43
  declare function dartTypeFromSchema(schema: Schema, context: CodegenContext): DartProperty;
39
44
 
40
- export { createDartClient, dartClientGenerator, dartTypeFromSchema };
45
+ export { createDartClient, dartClientGenerator, dartFormatCommand, dartTypeFromSchema };
41
46
  export type { DartClientGeneratorOptions };
package/dist/index.d.mts CHANGED
@@ -31,11 +31,16 @@ interface DartClientGeneratorOptions {
31
31
  */
32
32
  typePrefix?: string;
33
33
  format?: boolean;
34
+ /**
35
+ * The language version passed to `dart format`. When unset, `dart format` infers it from the nearest package config.
36
+ */
37
+ formatLanguageVersion?: string;
34
38
  rootService?: string;
35
39
  }
40
+ declare function dartFormatCommand(destination: string, options: Pick<DartClientGeneratorOptions, 'formatLanguageVersion'>): string;
36
41
  declare const dartClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<DartClientGeneratorOptions>;
37
42
  declare function createDartClient(def: AppDefinition, options: DartClientGeneratorOptions): string;
38
43
  declare function dartTypeFromSchema(schema: Schema, context: CodegenContext): DartProperty;
39
44
 
40
- export { createDartClient, dartClientGenerator, dartTypeFromSchema };
45
+ export { createDartClient, dartClientGenerator, dartFormatCommand, dartTypeFromSchema };
41
46
  export type { DartClientGeneratorOptions };
package/dist/index.d.ts CHANGED
@@ -31,11 +31,16 @@ interface DartClientGeneratorOptions {
31
31
  */
32
32
  typePrefix?: string;
33
33
  format?: boolean;
34
+ /**
35
+ * The language version passed to `dart format`. When unset, `dart format` infers it from the nearest package config.
36
+ */
37
+ formatLanguageVersion?: string;
34
38
  rootService?: string;
35
39
  }
40
+ declare function dartFormatCommand(destination: string, options: Pick<DartClientGeneratorOptions, 'formatLanguageVersion'>): string;
36
41
  declare const dartClientGenerator: _arrirpc_codegen_utils.GeneratorPlugin<DartClientGeneratorOptions>;
37
42
  declare function createDartClient(def: AppDefinition, options: DartClientGeneratorOptions): string;
38
43
  declare function dartTypeFromSchema(schema: Schema, context: CodegenContext): DartProperty;
39
44
 
40
- export { createDartClient, dartClientGenerator, dartTypeFromSchema };
45
+ export { createDartClient, dartClientGenerator, dartFormatCommand, dartTypeFromSchema };
41
46
  export type { DartClientGeneratorOptions };
package/dist/index.mjs CHANGED
@@ -1296,7 +1296,12 @@ function dartRefFromSchema(schema, context) {
1296
1296
  };
1297
1297
  }
1298
1298
 
1299
- const dartFormatLanguageVersion = "3.7";
1299
+ function dartFormatCommand(destination, options) {
1300
+ if (options.formatLanguageVersion) {
1301
+ return `dart format --language-version=${options.formatLanguageVersion} ${destination}`;
1302
+ }
1303
+ return `dart format ${destination}`;
1304
+ }
1300
1305
  const dartClientGenerator = defineGeneratorPlugin(
1301
1306
  (options) => {
1302
1307
  return {
@@ -1312,9 +1317,7 @@ const dartClientGenerator = defineGeneratorPlugin(
1312
1317
  const destination = path.resolve(options.outputFile);
1313
1318
  await fs.writeFile(destination, result);
1314
1319
  if (options.format !== false) {
1315
- execSync(
1316
- `dart format --language-version=${dartFormatLanguageVersion} ${destination}`
1317
- );
1320
+ execSync(dartFormatCommand(destination, options));
1318
1321
  }
1319
1322
  } catch (err) {
1320
1323
  console.error(err);
@@ -1488,4 +1491,4 @@ function dartTypeFromSchema(schema, context) {
1488
1491
  return dartAnyFromSchema(schema, context);
1489
1492
  }
1490
1493
 
1491
- export { createDartClient, dartClientGenerator, dartTypeFromSchema };
1494
+ export { createDartClient, dartClientGenerator, dartFormatCommand, dartTypeFromSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/codegen-dart",
3
- "version": "0.86.0",
3
+ "version": "0.86.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -23,6 +23,6 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "pathe": "^2.0.3",
26
- "@arrirpc/codegen-utils": "0.86.0"
26
+ "@arrirpc/codegen-utils": "0.86.1"
27
27
  }
28
28
  }