arri 0.76.4 → 0.77.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
@@ -4,39 +4,87 @@ Command line interface for ARRI-RPC
4
4
 
5
5
  ## Table of Contents
6
6
 
7
- - [Commands](#commands)
8
- - [Running code generators](#running-code-generators)
9
- - [Usage with @arrirpc/server](#usage-with-arrirpcserver)
7
+ - [Commands](#commands)
8
+ - [Usage with an Arri Server](#usage-with-an-arri-server)
9
+ - [Usage with an App Definition](#usage-with-an-app-definition)
10
10
 
11
11
  ## Commands
12
12
 
13
13
  Run `arri --help` to get a full list of commands
14
14
 
15
- | Cmd | Description |
16
- | -------------------- | ------------------------------------------------------------------------------------------------------------------- |
17
- | codegen [input-file] | Run generate clients specified in the `arri.config.ts`. See [here](#running-arri-codegen) for details. |
18
- | init [dir] | Scaffold an arri app/library |
19
- | list | List available arri versions |
20
- | use [version] | Update arri dependencies to a specific version (checks recursively for package.json, pubspec.yaml, cargo.toml, etc) |
21
- | version | Print current CLI version |
15
+ | Cmd | Description |
16
+ | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | build | Use the currently registered server plugin to build your arri server and run the code generators |
18
+ | dev | Run the currently registered server plugin in dev mode (basically watches for changes and rebuilds the server and reruns code generators as needed) |
19
+ | codegen [input-file] | Run generate clients specified in the `arri.config.ts`. See [here](#running-arri-codegen) for details. |
20
+ | init [dir] | Scaffold an arri app/library |
21
+ | list | List available arri versions |
22
+ | use [version] | Update arri dependencies to a specific version (checks recursively for package.json, pubspec.yaml, cargo.toml, etc) |
23
+ | version | Print current CLI version |
22
24
 
23
- ## Running code generators
25
+ ## Usage with an Arri server
26
+
27
+ The Arri CLI will automatically rerun code generators on hot-reload during development, and when building for production.
28
+
29
+ #### Register your server plugin
30
+
31
+ ```ts
32
+ // arri.config.ts
33
+ import { defineConfig, servers } from 'arri';
34
+
35
+ // registering the typescript server plugin
36
+ export default defineConfig({
37
+ server: servers.tsServer({
38
+ srcDir: 'src',
39
+ entry: 'app.ts',
40
+ port: 3000,
41
+ }),
42
+ generators: [
43
+ // client generators go here
44
+ ],
45
+ });
46
+
47
+ // registering the go server plugin
48
+ export default defineConfig({
49
+ server: servers.goServer({}),
50
+ generators: [
51
+ // client generators go here
52
+ ],
53
+ });
54
+ ```
55
+
56
+ #### Start developing your server
57
+
58
+ ```bash
59
+ arri dev
60
+ arri build
61
+ ```
62
+
63
+ You can also skip codegen during build
64
+
65
+ ```bash
66
+ arri build --skip-codegen
67
+ ```
68
+
69
+ ## Usage with an App Definition
70
+
71
+ `arri codegen` gives you the ability to run code generators against an already generated [Arri App Definition](/specifications/arri_app_definition.md). This is useful in cases where you don't have access to the backend but do have access to an App Definition file. So basically if you have multiple separate frontend teams, this allows you to distribute your `__definition.json` file to them and they will be able to generate type-safe client(s). (You could also make it available as an HTTP endpoint on the server if you are okay exposing that data publicly)
24
72
 
25
73
  Before running codegen you need to setup a valid Arri Config
26
74
 
27
75
  ```ts
28
76
  // arri.config.ts
29
- import { defineConfig, generators } from "arri";
77
+ import { defineConfig, generators } from 'arri';
30
78
 
31
79
  export default defineConfig({
32
80
  generators: [
33
81
  generators.dartClient({
34
- clientName: "Client",
35
- outputPath: "<some-output-file>",
82
+ clientName: 'Client',
83
+ outputPath: '<some-output-file>',
36
84
  }),
37
85
  generators.typescriptClient({
38
- clientName: "Client",
39
- outputPath: "<some-output-file>",
86
+ clientName: 'Client',
87
+ outputPath: '<some-output-file>',
40
88
  }),
41
89
  // etc...
42
90
  ],
@@ -61,33 +109,3 @@ arri codegen https://example.com/__definition
61
109
  | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
62
110
  | --config | -c | Path to an arri config. Default is `arri.config.ts` |
63
111
  | --watch | -w | Watch an app definition file for changes. Only works on files. It will throw an error if invoked against an HTTP endpoint |
64
-
65
- ## Usage with @arrirpc/server
66
-
67
- @arrirpc/server will automatically rerun code generators on hot-reload during development, and when building for production.
68
-
69
- For full details visit the [server docs](https://github.com/modiimedia/arri/blob/master/packages/arri/README.md)
70
-
71
- #### 1) Create an `arri.config.ts`
72
-
73
- ```ts
74
- import { defineConfig } from "arri";
75
-
76
- export default defineConfig({
77
- server: servers.tsServer({
78
- srcDir: "src",
79
- entry: "app.ts",
80
- port: 3000,
81
- }),
82
- generators: [
83
- // client generators go here (can be imported from arri)
84
- ],
85
- });
86
- ```
87
-
88
- #### 2) Develop your server
89
-
90
- ```bash
91
- arri dev
92
- arri build
93
- ```
package/dist/index.cjs CHANGED
@@ -8,9 +8,10 @@ const typescriptCodegen = require('@arrirpc/codegen-ts');
8
8
  const common = require('./shared/arri.pHQOQ5Wb.cjs');
9
9
  const node_child_process = require('node:child_process');
10
10
  const fs = require('node:fs');
11
- const path = require('node:path');
12
11
  const chokidar = require('chokidar');
12
+ const path = require('pathe');
13
13
  const fs$1 = require('node:fs/promises');
14
+ const os = require('node:os');
14
15
  const codegenUtils = require('@arrirpc/codegen-utils');
15
16
  const listhen = require('@joshmossas/listhen');
16
17
  const esbuild = require('esbuild');
@@ -19,7 +20,6 @@ const h3 = require('h3');
19
20
  const prettier = require('prettier');
20
21
  require('c12');
21
22
  require('citty');
22
- require('pathe');
23
23
  require('@arrirpc/schema');
24
24
  require('consola');
25
25
  require('ofetch');
@@ -44,9 +44,10 @@ const rustCodegen__namespace = /*#__PURE__*/_interopNamespaceCompat(rustCodegen)
44
44
  const swiftCodegen__namespace = /*#__PURE__*/_interopNamespaceCompat(swiftCodegen);
45
45
  const typescriptCodegen__namespace = /*#__PURE__*/_interopNamespaceCompat(typescriptCodegen);
46
46
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
47
- const path__default = /*#__PURE__*/_interopDefaultCompat(path);
48
47
  const chokidar__default = /*#__PURE__*/_interopDefaultCompat(chokidar);
48
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
49
49
  const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs$1);
50
+ const os__default = /*#__PURE__*/_interopDefaultCompat(os);
50
51
  const esbuild__default = /*#__PURE__*/_interopDefaultCompat(esbuild);
51
52
  const prettier__default = /*#__PURE__*/_interopDefaultCompat(prettier);
52
53
 
@@ -507,11 +508,15 @@ async function createDevServer(config) {
507
508
  );
508
509
  }
509
510
  async function reload() {
510
- const appEntry = (await import(path__default.resolve(
511
+ let importPath = path__default.resolve(
511
512
  config.rootDir,
512
513
  ".output",
513
514
  `${OUT_APP_FILE}?version=${Date.now()}`
514
- ))).default;
515
+ );
516
+ if (os__default.type() === "Windows_NT") {
517
+ importPath = createWindowsCompatibleAbsoluteImport(importPath);
518
+ }
519
+ const appEntry = (await import(importPath)).default;
515
520
  dynamicHandler.set(h3.fromNodeMiddleware(appEntry.h3App.handler));
516
521
  ws = appEntry.h3App.websocket;
517
522
  return appEntry.getAppDefinition();
@@ -525,6 +530,24 @@ async function createDevServer(config) {
525
530
  ws
526
531
  };
527
532
  }
533
+ function createWindowsCompatibleAbsoluteImport(input) {
534
+ let separator;
535
+ for (const char of input) {
536
+ if (char === "\\") {
537
+ separator = "\\";
538
+ break;
539
+ }
540
+ if (char === "/") {
541
+ separator = "/";
542
+ }
543
+ }
544
+ const parts = input.split(separator ?? "/");
545
+ if (parts[0]?.endsWith(":")) {
546
+ parts.unshift("file:\\");
547
+ }
548
+ const newStr = parts.join("\\");
549
+ return newStr;
550
+ }
528
551
  async function startDevServer(config, generators) {
529
552
  await setupWorkingDir(config);
530
553
  const watcher = await import('chokidar');
package/dist/index.d.cts CHANGED
@@ -88,4 +88,5 @@ declare const codegen: {
88
88
  ts: typeof typescriptCodegen;
89
89
  };
90
90
 
91
- export { type ArriConfig, DEV_DEFINITION_ENDPOINT, type ServerConfig, type TsServerConfig, codegen, defineConfig, defineServerConfig, generators, isArriConfig, isServerConfig, servers };
91
+ export { DEV_DEFINITION_ENDPOINT, codegen, defineConfig, defineServerConfig, generators, isArriConfig, isServerConfig, servers };
92
+ export type { ArriConfig, ServerConfig, TsServerConfig };
package/dist/index.d.mts CHANGED
@@ -88,4 +88,5 @@ declare const codegen: {
88
88
  ts: typeof typescriptCodegen;
89
89
  };
90
90
 
91
- export { type ArriConfig, DEV_DEFINITION_ENDPOINT, type ServerConfig, type TsServerConfig, codegen, defineConfig, defineServerConfig, generators, isArriConfig, isServerConfig, servers };
91
+ export { DEV_DEFINITION_ENDPOINT, codegen, defineConfig, defineServerConfig, generators, isArriConfig, isServerConfig, servers };
92
+ export type { ArriConfig, ServerConfig, TsServerConfig };
package/dist/index.d.ts CHANGED
@@ -88,4 +88,5 @@ declare const codegen: {
88
88
  ts: typeof typescriptCodegen;
89
89
  };
90
90
 
91
- export { type ArriConfig, DEV_DEFINITION_ENDPOINT, type ServerConfig, type TsServerConfig, codegen, defineConfig, defineServerConfig, generators, isArriConfig, isServerConfig, servers };
91
+ export { DEV_DEFINITION_ENDPOINT, codegen, defineConfig, defineServerConfig, generators, isArriConfig, isServerConfig, servers };
92
+ export type { ArriConfig, ServerConfig, TsServerConfig };
package/dist/index.mjs CHANGED
@@ -7,9 +7,10 @@ import { d as defineServerConfig, l as logger, i as isInsideDir } from './shared
7
7
  export { D as DEV_DEFINITION_ENDPOINT, b as defineConfig, a as isArriConfig, c as isServerConfig } from './shared/arri.CGlJ9Ywd.mjs';
8
8
  import { execSync, spawn } from 'node:child_process';
9
9
  import fs$1, { existsSync, readFileSync } from 'node:fs';
10
- import path from 'node:path';
11
10
  import chokidar from 'chokidar';
11
+ import path from 'pathe';
12
12
  import * as fs from 'node:fs/promises';
13
+ import os from 'node:os';
13
14
  import { isAppDefinition, camelCase, removeDisallowedChars, kebabCase } from '@arrirpc/codegen-utils';
14
15
  export { createAppDefinition } from '@arrirpc/codegen-utils';
15
16
  import { listen } from '@joshmossas/listhen';
@@ -19,7 +20,6 @@ import { dynamicEventHandler, toNodeListener, fromNodeMiddleware } from 'h3';
19
20
  import prettier from 'prettier';
20
21
  import 'c12';
21
22
  import 'citty';
22
- import 'pathe';
23
23
  import '@arrirpc/schema';
24
24
  import 'consola';
25
25
  import 'ofetch';
@@ -481,11 +481,15 @@ async function createDevServer(config) {
481
481
  );
482
482
  }
483
483
  async function reload() {
484
- const appEntry = (await import(path.resolve(
484
+ let importPath = path.resolve(
485
485
  config.rootDir,
486
486
  ".output",
487
487
  `${OUT_APP_FILE}?version=${Date.now()}`
488
- ))).default;
488
+ );
489
+ if (os.type() === "Windows_NT") {
490
+ importPath = createWindowsCompatibleAbsoluteImport(importPath);
491
+ }
492
+ const appEntry = (await import(importPath)).default;
489
493
  dynamicHandler.set(fromNodeMiddleware(appEntry.h3App.handler));
490
494
  ws = appEntry.h3App.websocket;
491
495
  return appEntry.getAppDefinition();
@@ -499,6 +503,24 @@ async function createDevServer(config) {
499
503
  ws
500
504
  };
501
505
  }
506
+ function createWindowsCompatibleAbsoluteImport(input) {
507
+ let separator;
508
+ for (const char of input) {
509
+ if (char === "\\") {
510
+ separator = "\\";
511
+ break;
512
+ }
513
+ if (char === "/") {
514
+ separator = "/";
515
+ }
516
+ }
517
+ const parts = input.split(separator ?? "/");
518
+ if (parts[0]?.endsWith(":")) {
519
+ parts.unshift("file:\\");
520
+ }
521
+ const newStr = parts.join("\\");
522
+ return newStr;
523
+ }
502
524
  async function startDevServer(config, generators) {
503
525
  await setupWorkingDir(config);
504
526
  const watcher = await import('chokidar');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.76.4",
3
+ "version": "0.77.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -29,7 +29,7 @@
29
29
  "c12": "^3.0.2",
30
30
  "chokidar": "^4.0.3",
31
31
  "citty": "^0.1.6",
32
- "consola": "^3.4.0",
32
+ "consola": "^3.4.2",
33
33
  "degit": "^2.8.4",
34
34
  "enquirer": "^2.4.1",
35
35
  "esbuild": "^0.25.1",
@@ -39,13 +39,13 @@
39
39
  "ofetch": "^1.4.1",
40
40
  "pathe": "^2.0.3",
41
41
  "prettier": "^3.5.3",
42
- "@arrirpc/codegen-dart": "0.76.4",
43
- "@arrirpc/codegen-kotlin": "0.76.4",
44
- "@arrirpc/codegen-rust": "0.76.4",
45
- "@arrirpc/codegen-swift": "0.76.4",
46
- "@arrirpc/codegen-ts": "0.76.4",
47
- "@arrirpc/codegen-utils": "0.76.4",
48
- "@arrirpc/schema": "0.76.4"
42
+ "@arrirpc/codegen-dart": "0.77.1",
43
+ "@arrirpc/codegen-rust": "0.77.1",
44
+ "@arrirpc/codegen-kotlin": "0.77.1",
45
+ "@arrirpc/codegen-swift": "0.77.1",
46
+ "@arrirpc/schema": "0.77.1",
47
+ "@arrirpc/codegen-ts": "0.77.1",
48
+ "@arrirpc/codegen-utils": "0.77.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/degit": "^2.8.6"