arri 0.48.2 → 0.49.0

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/dist/cli.cjs CHANGED
@@ -11,15 +11,18 @@ const esbuild = require('esbuild');
11
11
  const esbuildPluginReplace = require('esbuild-plugin-replace');
12
12
  const path = require('pathe');
13
13
  const prettier = require('prettier');
14
- const dev = require('./shared/arri.8832d51d.cjs');
14
+ const dev = require('./shared/arri.8421be96.cjs');
15
15
  const ofetch = require('ofetch');
16
16
  const Degit = require('degit');
17
17
  const enquirer = require('enquirer');
18
- const scule = require('scule');
18
+ const schema = require('@arrirpc/schema');
19
+ const consola = require('consola');
20
+ const promises = require('fs/promises');
21
+ const node_url = require('node:url');
19
22
  require('@joshmossas/listhen');
20
23
  require('h3');
21
- require('consola');
22
24
 
25
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
23
26
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
24
27
 
25
28
  const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs);
@@ -28,6 +31,7 @@ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
28
31
  const prettier__default = /*#__PURE__*/_interopDefaultCompat(prettier);
29
32
  const Degit__default = /*#__PURE__*/_interopDefaultCompat(Degit);
30
33
  const enquirer__default = /*#__PURE__*/_interopDefaultCompat(enquirer);
34
+ const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
31
35
 
32
36
  const build = citty.defineCommand({
33
37
  args: {
@@ -398,7 +402,7 @@ async function initApp(dir, force) {
398
402
  encoding: "utf-8"
399
403
  })
400
404
  );
401
- packageJson.name = scule.kebabCase(dir);
405
+ packageJson.name = codegenUtils.kebabCase(dir);
402
406
  packageJson.description = "An RPC server created with Arri RPC";
403
407
  packageJson.private = true;
404
408
  delete packageJson.license;
@@ -423,7 +427,7 @@ async function initApp(dir, force) {
423
427
  - pnpm run dev`);
424
428
  }
425
429
  async function initPlugin(dir, force) {
426
- const name = scule.kebabCase(dir);
430
+ const name = codegenUtils.kebabCase(dir);
427
431
  const degit = Degit__default("modiimedia/arri-starters/generator-starter", {
428
432
  force
429
433
  });
@@ -451,12 +455,227 @@ async function initPlugin(dir, force) {
451
455
  - pnpm install`);
452
456
  }
453
457
 
458
+ const list = citty.defineCommand({
459
+ meta: {
460
+ name: "List",
461
+ description: "List the available arri versions"
462
+ },
463
+ args: {
464
+ tags: {
465
+ type: "boolean",
466
+ default: false,
467
+ description: "List available tags"
468
+ }
469
+ },
470
+ async run({ args }) {
471
+ const arriInfo = await dev.getArriPackageMetadata();
472
+ if (args.tags) {
473
+ const output2 = Object.keys(arriInfo["dist-tags"]).map(
474
+ (tag) => `- ${tag} (${arriInfo["dist-tags"][tag]})`
475
+ );
476
+ dev.logger.log(output2.join("\n"));
477
+ return;
478
+ }
479
+ const tagMap = {};
480
+ for (const key of Object.keys(arriInfo["dist-tags"])) {
481
+ const version = arriInfo["dist-tags"][key];
482
+ tagMap[version] = key;
483
+ }
484
+ const output = Object.keys(arriInfo.versions).map((version) => {
485
+ const tag = tagMap[version];
486
+ if (tag) {
487
+ return `- ${version} (${tag})`;
488
+ }
489
+ return `- ${version}`;
490
+ });
491
+ dev.logger.log(output.join("\n"));
492
+ }
493
+ });
494
+
495
+ const use = citty.defineCommand({
496
+ meta: {
497
+ name: "use",
498
+ description: "Use a specific arri version"
499
+ },
500
+ args: {
501
+ version: {
502
+ type: "positional",
503
+ required: true,
504
+ description: 'The version you want to use. You can also specify a tag such as "latest".'
505
+ }
506
+ },
507
+ async run({ args }) {
508
+ const arriInfo = await dev.getArriPackageMetadata();
509
+ const version = arriInfo["dist-tags"][args.version] ?? args.version;
510
+ if (!arriInfo.versions[version]) {
511
+ throw new Error(
512
+ `Version ${args.version} doesn't exist. Run "arri list" to see available versions.`
513
+ );
514
+ }
515
+ const globby = (await import('globby')).globby;
516
+ consola__default.info(`Checking for TS/JS dependencies`);
517
+ const fileMap = {};
518
+ const pkgJsonFiles = await globby(
519
+ [
520
+ "package.json",
521
+ "**/package.json",
522
+ "package.jsonc",
523
+ "**/package.jsonc"
524
+ ],
525
+ {
526
+ ignore: ["node_modules", "**/node_modules", "**/dist", "dist"]
527
+ }
528
+ );
529
+ const jkgJsonFileTasks = [];
530
+ for (const file of pkgJsonFiles) {
531
+ jkgJsonFileTasks.push(
532
+ promises.readFile(path__default.resolve(file), "utf8").then((content) => {
533
+ fileMap[file] = updatePackageJson(content, version);
534
+ })
535
+ );
536
+ }
537
+ await Promise.all(jkgJsonFileTasks);
538
+ consola__default.info(`Checking for dart dependencies`);
539
+ const pubspecFiles = await globby(["pubspec.yaml", "**/pubspec.yaml"]);
540
+ const pubspecFileTasks = [];
541
+ if (pubspecFiles.length) {
542
+ const dartPackage = await getDartPackageMeta();
543
+ let hasVersion = false;
544
+ for (const item of dartPackage.versions) {
545
+ if (item.version == version) {
546
+ hasVersion = true;
547
+ break;
548
+ }
549
+ }
550
+ if (!hasVersion) {
551
+ throw new Error(
552
+ `Version ${version} does not have Dart support`
553
+ );
554
+ }
555
+ }
556
+ for (const file of pubspecFiles) {
557
+ pubspecFileTasks.push(
558
+ promises.readFile(path__default.resolve(file), "utf8").then((content) => {
559
+ fileMap[file] = updatePubspecYaml(content, version);
560
+ })
561
+ );
562
+ }
563
+ await Promise.all(pubspecFileTasks);
564
+ const updateTasks = [];
565
+ for (const key of Object.keys(fileMap)) {
566
+ updateTasks.push(
567
+ promises.writeFile(path__default.resolve(key), fileMap[key], "utf8").then(
568
+ () => consola__default.success(`Updated ${key}`)
569
+ )
570
+ );
571
+ }
572
+ await Promise.all(updateTasks);
573
+ consola__default.success(
574
+ `Updated to ${version}. Rerun your install commands to update your dependencies.`
575
+ );
576
+ }
577
+ });
578
+ function updatePackageJson(fileContent, targetVersion) {
579
+ const lines = fileContent.split("\n");
580
+ const output = [];
581
+ for (const line of lines) {
582
+ if (line.includes(`"arri"`)) {
583
+ output.push(updateLine(line));
584
+ continue;
585
+ }
586
+ if (line.includes(`"@arrirpc/`)) {
587
+ output.push(updateLine(line));
588
+ continue;
589
+ }
590
+ output.push(line);
591
+ }
592
+ function updateLine(line) {
593
+ const parts = line.split('":');
594
+ if (parts.length < 2) {
595
+ return line;
596
+ }
597
+ const targetParts = parts[1].split('"');
598
+ targetParts[1] = `^${targetVersion}`;
599
+ parts[1] = targetParts.join('"');
600
+ return parts.join('":');
601
+ }
602
+ return output.join("\n");
603
+ }
604
+ const PubPackageResponse = schema.a.object({
605
+ name: schema.a.string(),
606
+ versions: schema.a.array(
607
+ schema.a.object({
608
+ version: schema.a.string(),
609
+ pubspec: schema.a.object({
610
+ name: schema.a.string(),
611
+ description: schema.a.string(),
612
+ version: schema.a.string(),
613
+ repository: schema.a.string(),
614
+ environment: schema.a.object({
615
+ sdk: schema.a.string()
616
+ }),
617
+ dependencies: schema.a.record(schema.a.string()),
618
+ dev_dependencies: schema.a.record(schema.a.string())
619
+ }),
620
+ archive_url: schema.a.string(),
621
+ archive_sha256: schema.a.string(),
622
+ published: schema.a.string()
623
+ })
624
+ )
625
+ });
626
+ async function getDartPackageMeta() {
627
+ const response = await ofetch.ofetch("https://pub.dev/api/packages/arri_client");
628
+ const data = schema.a.parse(PubPackageResponse, response);
629
+ return data;
630
+ }
631
+ function updatePubspecYaml(fileContent, version) {
632
+ const lines = fileContent.split("\n");
633
+ const output = [];
634
+ for (const line of lines) {
635
+ if (line.includes("arri_client: ")) {
636
+ const parts = line.split(": ");
637
+ if (parts.length < 2) {
638
+ output.push(line);
639
+ continue;
640
+ }
641
+ const targetPart = parts[1];
642
+ const subParts = targetPart.split(" ");
643
+ subParts[0] = `^${version}`;
644
+ parts[1] = subParts.join(" ");
645
+ output.push(parts.join(": "));
646
+ continue;
647
+ }
648
+ output.push(line);
649
+ }
650
+ return output.join("\n");
651
+ }
652
+
653
+ const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
654
+ const __dirname$1 = path__default.dirname(__filename$1);
655
+ const version = citty.defineCommand({
656
+ meta: {
657
+ name: "Version",
658
+ description: "Get the current Arri CLI version"
659
+ },
660
+ run() {
661
+ const packageJson = JSON.parse(
662
+ fs.readFileSync(path__default.resolve(__dirname$1, "../package.json"), {
663
+ encoding: "utf8"
664
+ })
665
+ );
666
+ console.info(`${packageJson.version}`);
667
+ }
668
+ });
669
+
454
670
  const main = citty.defineCommand({
455
671
  subCommands: {
456
672
  build,
457
- dev: dev.dev,
458
673
  codegen,
459
- init
674
+ dev: dev.dev,
675
+ init,
676
+ list,
677
+ use,
678
+ version
460
679
  }
461
680
  });
462
681
  void citty.runMain(main);
package/dist/cli.mjs CHANGED
@@ -3,20 +3,22 @@ import { defineCommand, runMain } from 'citty';
3
3
  import { execSync } from 'node:child_process';
4
4
  import fs$1, { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
5
5
  import fs from 'node:fs/promises';
6
- import { isAppDefinition } from '@arrirpc/codegen-utils';
6
+ import { isAppDefinition, kebabCase } from '@arrirpc/codegen-utils';
7
7
  import { loadConfig } from 'c12';
8
8
  import { build as build$1 } from 'esbuild';
9
9
  import { replace } from 'esbuild-plugin-replace';
10
10
  import path from 'pathe';
11
11
  import prettier from 'prettier';
12
- import { d as defaultConfig, l as logger, s as setupWorkingDir, c as createAppWithRoutesModule, O as OUT_CODEGEN, e as OUT_SERVER_ENTRY, G as GEN_APP_FILE, f as OUT_APP_FILE, i as isArriConfig, g as dev } from './shared/arri.69bdfa17.mjs';
12
+ import { d as defaultConfig, l as logger, s as setupWorkingDir, c as createAppWithRoutesModule, O as OUT_CODEGEN, e as OUT_SERVER_ENTRY, G as GEN_APP_FILE, f as OUT_APP_FILE, i as isArriConfig, g as getArriPackageMetadata, h as dev } from './shared/arri.1c716de9.mjs';
13
13
  import { ofetch } from 'ofetch';
14
14
  import Degit from 'degit';
15
15
  import enquirer from 'enquirer';
16
- import { kebabCase } from 'scule';
16
+ import { a } from '@arrirpc/schema';
17
+ import consola from 'consola';
18
+ import { readFile, writeFile } from 'fs/promises';
19
+ import { fileURLToPath } from 'node:url';
17
20
  import '@joshmossas/listhen';
18
21
  import 'h3';
19
- import 'consola';
20
22
 
21
23
  const build = defineCommand({
22
24
  args: {
@@ -440,12 +442,227 @@ async function initPlugin(dir, force) {
440
442
  - pnpm install`);
441
443
  }
442
444
 
445
+ const list = defineCommand({
446
+ meta: {
447
+ name: "List",
448
+ description: "List the available arri versions"
449
+ },
450
+ args: {
451
+ tags: {
452
+ type: "boolean",
453
+ default: false,
454
+ description: "List available tags"
455
+ }
456
+ },
457
+ async run({ args }) {
458
+ const arriInfo = await getArriPackageMetadata();
459
+ if (args.tags) {
460
+ const output2 = Object.keys(arriInfo["dist-tags"]).map(
461
+ (tag) => `- ${tag} (${arriInfo["dist-tags"][tag]})`
462
+ );
463
+ logger.log(output2.join("\n"));
464
+ return;
465
+ }
466
+ const tagMap = {};
467
+ for (const key of Object.keys(arriInfo["dist-tags"])) {
468
+ const version = arriInfo["dist-tags"][key];
469
+ tagMap[version] = key;
470
+ }
471
+ const output = Object.keys(arriInfo.versions).map((version) => {
472
+ const tag = tagMap[version];
473
+ if (tag) {
474
+ return `- ${version} (${tag})`;
475
+ }
476
+ return `- ${version}`;
477
+ });
478
+ logger.log(output.join("\n"));
479
+ }
480
+ });
481
+
482
+ const use = defineCommand({
483
+ meta: {
484
+ name: "use",
485
+ description: "Use a specific arri version"
486
+ },
487
+ args: {
488
+ version: {
489
+ type: "positional",
490
+ required: true,
491
+ description: 'The version you want to use. You can also specify a tag such as "latest".'
492
+ }
493
+ },
494
+ async run({ args }) {
495
+ const arriInfo = await getArriPackageMetadata();
496
+ const version = arriInfo["dist-tags"][args.version] ?? args.version;
497
+ if (!arriInfo.versions[version]) {
498
+ throw new Error(
499
+ `Version ${args.version} doesn't exist. Run "arri list" to see available versions.`
500
+ );
501
+ }
502
+ const globby = (await import('globby')).globby;
503
+ consola.info(`Checking for TS/JS dependencies`);
504
+ const fileMap = {};
505
+ const pkgJsonFiles = await globby(
506
+ [
507
+ "package.json",
508
+ "**/package.json",
509
+ "package.jsonc",
510
+ "**/package.jsonc"
511
+ ],
512
+ {
513
+ ignore: ["node_modules", "**/node_modules", "**/dist", "dist"]
514
+ }
515
+ );
516
+ const jkgJsonFileTasks = [];
517
+ for (const file of pkgJsonFiles) {
518
+ jkgJsonFileTasks.push(
519
+ readFile(path.resolve(file), "utf8").then((content) => {
520
+ fileMap[file] = updatePackageJson(content, version);
521
+ })
522
+ );
523
+ }
524
+ await Promise.all(jkgJsonFileTasks);
525
+ consola.info(`Checking for dart dependencies`);
526
+ const pubspecFiles = await globby(["pubspec.yaml", "**/pubspec.yaml"]);
527
+ const pubspecFileTasks = [];
528
+ if (pubspecFiles.length) {
529
+ const dartPackage = await getDartPackageMeta();
530
+ let hasVersion = false;
531
+ for (const item of dartPackage.versions) {
532
+ if (item.version == version) {
533
+ hasVersion = true;
534
+ break;
535
+ }
536
+ }
537
+ if (!hasVersion) {
538
+ throw new Error(
539
+ `Version ${version} does not have Dart support`
540
+ );
541
+ }
542
+ }
543
+ for (const file of pubspecFiles) {
544
+ pubspecFileTasks.push(
545
+ readFile(path.resolve(file), "utf8").then((content) => {
546
+ fileMap[file] = updatePubspecYaml(content, version);
547
+ })
548
+ );
549
+ }
550
+ await Promise.all(pubspecFileTasks);
551
+ const updateTasks = [];
552
+ for (const key of Object.keys(fileMap)) {
553
+ updateTasks.push(
554
+ writeFile(path.resolve(key), fileMap[key], "utf8").then(
555
+ () => consola.success(`Updated ${key}`)
556
+ )
557
+ );
558
+ }
559
+ await Promise.all(updateTasks);
560
+ consola.success(
561
+ `Updated to ${version}. Rerun your install commands to update your dependencies.`
562
+ );
563
+ }
564
+ });
565
+ function updatePackageJson(fileContent, targetVersion) {
566
+ const lines = fileContent.split("\n");
567
+ const output = [];
568
+ for (const line of lines) {
569
+ if (line.includes(`"arri"`)) {
570
+ output.push(updateLine(line));
571
+ continue;
572
+ }
573
+ if (line.includes(`"@arrirpc/`)) {
574
+ output.push(updateLine(line));
575
+ continue;
576
+ }
577
+ output.push(line);
578
+ }
579
+ function updateLine(line) {
580
+ const parts = line.split('":');
581
+ if (parts.length < 2) {
582
+ return line;
583
+ }
584
+ const targetParts = parts[1].split('"');
585
+ targetParts[1] = `^${targetVersion}`;
586
+ parts[1] = targetParts.join('"');
587
+ return parts.join('":');
588
+ }
589
+ return output.join("\n");
590
+ }
591
+ const PubPackageResponse = a.object({
592
+ name: a.string(),
593
+ versions: a.array(
594
+ a.object({
595
+ version: a.string(),
596
+ pubspec: a.object({
597
+ name: a.string(),
598
+ description: a.string(),
599
+ version: a.string(),
600
+ repository: a.string(),
601
+ environment: a.object({
602
+ sdk: a.string()
603
+ }),
604
+ dependencies: a.record(a.string()),
605
+ dev_dependencies: a.record(a.string())
606
+ }),
607
+ archive_url: a.string(),
608
+ archive_sha256: a.string(),
609
+ published: a.string()
610
+ })
611
+ )
612
+ });
613
+ async function getDartPackageMeta() {
614
+ const response = await ofetch("https://pub.dev/api/packages/arri_client");
615
+ const data = a.parse(PubPackageResponse, response);
616
+ return data;
617
+ }
618
+ function updatePubspecYaml(fileContent, version) {
619
+ const lines = fileContent.split("\n");
620
+ const output = [];
621
+ for (const line of lines) {
622
+ if (line.includes("arri_client: ")) {
623
+ const parts = line.split(": ");
624
+ if (parts.length < 2) {
625
+ output.push(line);
626
+ continue;
627
+ }
628
+ const targetPart = parts[1];
629
+ const subParts = targetPart.split(" ");
630
+ subParts[0] = `^${version}`;
631
+ parts[1] = subParts.join(" ");
632
+ output.push(parts.join(": "));
633
+ continue;
634
+ }
635
+ output.push(line);
636
+ }
637
+ return output.join("\n");
638
+ }
639
+
640
+ const __filename = fileURLToPath(import.meta.url);
641
+ const __dirname = path.dirname(__filename);
642
+ const version = defineCommand({
643
+ meta: {
644
+ name: "Version",
645
+ description: "Get the current Arri CLI version"
646
+ },
647
+ run() {
648
+ const packageJson = JSON.parse(
649
+ readFileSync(path.resolve(__dirname, "../package.json"), {
650
+ encoding: "utf8"
651
+ })
652
+ );
653
+ console.info(`${packageJson.version}`);
654
+ }
655
+ });
656
+
443
657
  const main = defineCommand({
444
658
  subCommands: {
445
659
  build,
446
- dev,
447
660
  codegen,
448
- init
661
+ dev,
662
+ init,
663
+ list,
664
+ use,
665
+ version
449
666
  }
450
667
  });
451
668
  void runMain(main);
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const dev = require('./shared/arri.8832d51d.cjs');
3
+ const dev = require('./shared/arri.8421be96.cjs');
4
4
  const codegenDart = require('@arrirpc/codegen-dart');
5
5
  const codegenKotlin = require('@arrirpc/codegen-kotlin');
6
6
  const codegenTs = require('@arrirpc/codegen-ts');
@@ -14,9 +14,9 @@ require('esbuild');
14
14
  require('h3');
15
15
  require('ofetch');
16
16
  require('pathe');
17
+ require('@arrirpc/schema');
17
18
  require('consola');
18
19
  require('prettier');
19
- require('scule');
20
20
 
21
21
 
22
22
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { D as DEV_DEFINITION_ENDPOINT, d as defaultConfig, b as defineConfig, i as isArriConfig, a as isResolvedArriConfig } from './shared/arri.69bdfa17.mjs';
1
+ export { D as DEV_DEFINITION_ENDPOINT, d as defaultConfig, b as defineConfig, i as isArriConfig, a as isResolvedArriConfig } from './shared/arri.1c716de9.mjs';
2
2
  export { dartClientGenerator } from '@arrirpc/codegen-dart';
3
3
  export { kotlinClientGenerator } from '@arrirpc/codegen-kotlin';
4
4
  export { typescriptClientGenerator } from '@arrirpc/codegen-ts';
@@ -12,6 +12,6 @@ import 'esbuild';
12
12
  import 'h3';
13
13
  import 'ofetch';
14
14
  import 'pathe';
15
+ import '@arrirpc/schema';
15
16
  import 'consola';
16
17
  import 'prettier';
17
- import 'scule';
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import fs from 'node:fs/promises';
3
- import { removeDisallowedChars, isAppDefinition } from '@arrirpc/codegen-utils';
3
+ import { camelCase, removeDisallowedChars, kebabCase, isAppDefinition } from '@arrirpc/codegen-utils';
4
4
  import { listenAndWatch } from '@joshmossas/listhen';
5
5
  import { loadConfig } from 'c12';
6
6
  import { defineCommand } from 'citty';
@@ -8,9 +8,9 @@ import * as esbuild from 'esbuild';
8
8
  import 'h3';
9
9
  import { ofetch } from 'ofetch';
10
10
  import path from 'pathe';
11
+ import { a, ValidationError } from '@arrirpc/schema';
11
12
  import { createConsola } from 'consola';
12
13
  import prettier from 'prettier';
13
- import { camelCase, kebabCase } from 'scule';
14
14
 
15
15
  const logger = createConsola().withTag("arri");
16
16
  const GEN_APP_FILE = "__arri_app.ts";
@@ -48,7 +48,7 @@ async function createAppWithRoutesModule(config) {
48
48
  }
49
49
  })
50
50
  );
51
- routes.sort((a, b) => a.name < b.name ? -1 : 1);
51
+ routes.sort((a2, b) => a2.name < b.name ? -1 : 1);
52
52
  const module = await prettier.format(
53
53
  `import sourceMapSupport from 'source-map-support';
54
54
  sourceMapSupport.install();
@@ -147,6 +147,88 @@ function isInsideDir(dir, parentDir) {
147
147
  }
148
148
  return false;
149
149
  }
150
+ async function getArriPackageMetadata() {
151
+ const npmPackageResponse = await ofetch("https://registry.npmjs.com/arri");
152
+ const arriInfo = a.safeParse(NpmRegistryPackage, npmPackageResponse);
153
+ if (!arriInfo.success) {
154
+ const errors = a.errors(NpmRegistryPackage, npmPackageResponse);
155
+ console.warn(errors);
156
+ throw new ValidationError({
157
+ message: "Arri parsing response from registry",
158
+ errors
159
+ });
160
+ }
161
+ return arriInfo.value;
162
+ }
163
+ const NpmPackageVersion = a.partial(
164
+ a.object({
165
+ name: a.string(),
166
+ version: a.string(),
167
+ _id: a.string(),
168
+ maintainers: a.array(
169
+ a.object({
170
+ name: a.string(),
171
+ email: a.string()
172
+ })
173
+ ),
174
+ bin: a.record(a.string()),
175
+ dist: a.any(),
176
+ main: a.string(),
177
+ type: a.string(),
178
+ types: a.string(),
179
+ module: a.string(),
180
+ gitHead: a.string(),
181
+ _npmUser: a.object({
182
+ name: a.string(),
183
+ email: a.string()
184
+ }),
185
+ description: a.string(),
186
+ directories: a.record(a.any()),
187
+ _nodeVersion: a.string(),
188
+ dependencies: a.record(a.string()),
189
+ _hasShrinkWrap: a.boolean(),
190
+ _npmOperationalInternal: a.any()
191
+ })
192
+ );
193
+ const NpmRegistryPackage = a.object({
194
+ _id: a.string(),
195
+ _rev: a.string(),
196
+ name: a.string(),
197
+ description: a.string(),
198
+ "dist-tags": a.record(a.string()),
199
+ versions: a.record(NpmPackageVersion),
200
+ time: a.record(a.string()),
201
+ maintainers: a.array(
202
+ a.object({
203
+ name: a.string(),
204
+ email: a.string()
205
+ })
206
+ ),
207
+ author: a.object({
208
+ name: a.string(),
209
+ url: a.string()
210
+ }),
211
+ repository: a.optional(
212
+ a.partial(
213
+ a.object({
214
+ type: a.string(),
215
+ url: a.string(),
216
+ directory: a.string()
217
+ })
218
+ )
219
+ ),
220
+ license: a.optional(a.string()),
221
+ homepage: a.optional(a.string()),
222
+ bugs: a.optional(
223
+ a.partial(
224
+ a.object({
225
+ url: a.string()
226
+ })
227
+ )
228
+ ),
229
+ readme: a.optional(a.string()),
230
+ readmeFilename: a.optional(a.string())
231
+ });
150
232
 
151
233
  function isArriConfig(input) {
152
234
  if (typeof input !== "object" || input === null) {
@@ -400,4 +482,4 @@ export default app.h3App;`;
400
482
  );
401
483
  }
402
484
 
403
- export { DEV_DEFINITION_ENDPOINT as D, GEN_APP_FILE as G, OUT_CODEGEN as O, isResolvedArriConfig as a, defineConfig as b, createAppWithRoutesModule as c, defaultConfig as d, OUT_SERVER_ENTRY as e, OUT_APP_FILE as f, dev as g, isArriConfig as i, logger as l, setupWorkingDir as s };
485
+ export { DEV_DEFINITION_ENDPOINT as D, GEN_APP_FILE as G, OUT_CODEGEN as O, isResolvedArriConfig as a, defineConfig as b, createAppWithRoutesModule as c, defaultConfig as d, OUT_SERVER_ENTRY as e, OUT_APP_FILE as f, getArriPackageMetadata as g, dev as h, isArriConfig as i, logger as l, setupWorkingDir as s };
@@ -10,9 +10,9 @@ const esbuild = require('esbuild');
10
10
  require('h3');
11
11
  const ofetch = require('ofetch');
12
12
  const path = require('pathe');
13
+ const schema = require('@arrirpc/schema');
13
14
  const consola = require('consola');
14
15
  const prettier = require('prettier');
15
- const scule = require('scule');
16
16
 
17
17
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
18
18
 
@@ -69,7 +69,7 @@ async function createAppWithRoutesModule(config) {
69
69
  }
70
70
  })
71
71
  );
72
- routes.sort((a, b) => a.name < b.name ? -1 : 1);
72
+ routes.sort((a2, b) => a2.name < b.name ? -1 : 1);
73
73
  const module = await prettier__default.format(
74
74
  `import sourceMapSupport from 'source-map-support';
75
75
  sourceMapSupport.install();
@@ -121,7 +121,7 @@ async function getFsRouteBatch(glob, globPattern, config) {
121
121
  importParts.pop();
122
122
  routes.push({
123
123
  name: meta.id,
124
- importName: scule.camelCase(meta.id.split(".").join("_")),
124
+ importName: codegenUtils.camelCase(meta.id.split(".").join("_")),
125
125
  importPath: `./${importParts.join(".")}`
126
126
  });
127
127
  }
@@ -154,8 +154,8 @@ const getRpcMetaFromPath = (config, filePath) => {
154
154
  disallowedNameChars
155
155
  );
156
156
  const httpParts = [
157
- ...serviceParts.map((part) => scule.kebabCase(part)),
158
- scule.kebabCase(rpcName)
157
+ ...serviceParts.map((part) => codegenUtils.kebabCase(part)),
158
+ codegenUtils.kebabCase(rpcName)
159
159
  ];
160
160
  return {
161
161
  id: [...serviceParts, rpcName].join("."),
@@ -168,6 +168,88 @@ function isInsideDir(dir, parentDir) {
168
168
  }
169
169
  return false;
170
170
  }
171
+ async function getArriPackageMetadata() {
172
+ const npmPackageResponse = await ofetch.ofetch("https://registry.npmjs.com/arri");
173
+ const arriInfo = schema.a.safeParse(NpmRegistryPackage, npmPackageResponse);
174
+ if (!arriInfo.success) {
175
+ const errors = schema.a.errors(NpmRegistryPackage, npmPackageResponse);
176
+ console.warn(errors);
177
+ throw new schema.ValidationError({
178
+ message: "Arri parsing response from registry",
179
+ errors
180
+ });
181
+ }
182
+ return arriInfo.value;
183
+ }
184
+ const NpmPackageVersion = schema.a.partial(
185
+ schema.a.object({
186
+ name: schema.a.string(),
187
+ version: schema.a.string(),
188
+ _id: schema.a.string(),
189
+ maintainers: schema.a.array(
190
+ schema.a.object({
191
+ name: schema.a.string(),
192
+ email: schema.a.string()
193
+ })
194
+ ),
195
+ bin: schema.a.record(schema.a.string()),
196
+ dist: schema.a.any(),
197
+ main: schema.a.string(),
198
+ type: schema.a.string(),
199
+ types: schema.a.string(),
200
+ module: schema.a.string(),
201
+ gitHead: schema.a.string(),
202
+ _npmUser: schema.a.object({
203
+ name: schema.a.string(),
204
+ email: schema.a.string()
205
+ }),
206
+ description: schema.a.string(),
207
+ directories: schema.a.record(schema.a.any()),
208
+ _nodeVersion: schema.a.string(),
209
+ dependencies: schema.a.record(schema.a.string()),
210
+ _hasShrinkWrap: schema.a.boolean(),
211
+ _npmOperationalInternal: schema.a.any()
212
+ })
213
+ );
214
+ const NpmRegistryPackage = schema.a.object({
215
+ _id: schema.a.string(),
216
+ _rev: schema.a.string(),
217
+ name: schema.a.string(),
218
+ description: schema.a.string(),
219
+ "dist-tags": schema.a.record(schema.a.string()),
220
+ versions: schema.a.record(NpmPackageVersion),
221
+ time: schema.a.record(schema.a.string()),
222
+ maintainers: schema.a.array(
223
+ schema.a.object({
224
+ name: schema.a.string(),
225
+ email: schema.a.string()
226
+ })
227
+ ),
228
+ author: schema.a.object({
229
+ name: schema.a.string(),
230
+ url: schema.a.string()
231
+ }),
232
+ repository: schema.a.optional(
233
+ schema.a.partial(
234
+ schema.a.object({
235
+ type: schema.a.string(),
236
+ url: schema.a.string(),
237
+ directory: schema.a.string()
238
+ })
239
+ )
240
+ ),
241
+ license: schema.a.optional(schema.a.string()),
242
+ homepage: schema.a.optional(schema.a.string()),
243
+ bugs: schema.a.optional(
244
+ schema.a.partial(
245
+ schema.a.object({
246
+ url: schema.a.string()
247
+ })
248
+ )
249
+ ),
250
+ readme: schema.a.optional(schema.a.string()),
251
+ readmeFilename: schema.a.optional(schema.a.string())
252
+ });
171
253
 
172
254
  function isArriConfig(input) {
173
255
  if (typeof input !== "object" || input === null) {
@@ -430,6 +512,7 @@ exports.createAppWithRoutesModule = createAppWithRoutesModule;
430
512
  exports.defaultConfig = defaultConfig;
431
513
  exports.defineConfig = defineConfig;
432
514
  exports.dev = dev;
515
+ exports.getArriPackageMetadata = getArriPackageMetadata;
433
516
  exports.isArriConfig = isArriConfig;
434
517
  exports.isResolvedArriConfig = isResolvedArriConfig;
435
518
  exports.logger = logger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.48.2",
3
+ "version": "0.49.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -39,11 +39,11 @@
39
39
  "ofetch": "^1.3.4",
40
40
  "pathe": "^1.1.2",
41
41
  "prettier": "^3.3.0",
42
- "scule": "^1.3.0",
43
- "@arrirpc/codegen-kotlin": "0.48.2",
44
- "@arrirpc/codegen-dart": "0.48.2",
45
- "@arrirpc/codegen-utils": "0.48.2",
46
- "@arrirpc/codegen-ts": "0.48.2"
42
+ "@arrirpc/codegen-kotlin": "0.49.0",
43
+ "@arrirpc/codegen-ts": "0.49.0",
44
+ "@arrirpc/codegen-dart": "0.49.0",
45
+ "@arrirpc/codegen-utils": "0.49.0",
46
+ "@arrirpc/schema": "0.49.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/degit": "^2.8.6"