arri 0.57.3 → 0.57.5
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 +50 -7
- package/dist/cli.cjs +117 -50
- package/dist/cli.mjs +117 -50
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +1 -1
- package/dist/shared/{arri.976d7393.cjs → arri.09919c6d.cjs} +23 -0
- package/dist/shared/{arri.1de410ff.mjs → arri.339f2f92.mjs} +23 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -5,19 +5,62 @@ Command line interface for ARRI-RPC
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
7
|
- [Commands](#commands)
|
|
8
|
+
- [Running code generators](#running-code-generators)
|
|
8
9
|
- [Usage with @arrirpc/server](#usage-with-arrirpcserver)
|
|
9
10
|
|
|
10
11
|
## Commands
|
|
11
12
|
|
|
12
13
|
Run `arri --help` to get a full list of commands
|
|
13
14
|
|
|
14
|
-
| Cmd | Description
|
|
15
|
-
| -------------------- |
|
|
16
|
-
| codegen [input-file] | Run generate clients specified in the `arri.config.ts`. See [here](
|
|
17
|
-
| init [dir] | Scaffold an arri app/library
|
|
18
|
-
| list | List available arri versions
|
|
19
|
-
| use [version] | Update arri dependencies to a specific version (checks recursively for package.json, pubspec.yaml, cargo.toml, etc)
|
|
20
|
-
| version | Print current CLI version
|
|
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 |
|
|
22
|
+
|
|
23
|
+
## Running code generators
|
|
24
|
+
|
|
25
|
+
Before running codegen you need to setup a valid Arri Config
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// arri.config.ts
|
|
29
|
+
import { defineConfig, generators } from "arri";
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
generators: [
|
|
33
|
+
generators.dartClient({
|
|
34
|
+
clientName: "Client",
|
|
35
|
+
outputPath: "<some-output-file>",
|
|
36
|
+
}),
|
|
37
|
+
generators.typescriptClient({
|
|
38
|
+
clientName: "Client",
|
|
39
|
+
outputPath: "<some-output-file>",
|
|
40
|
+
}),
|
|
41
|
+
// etc...
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Run the codegen command
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# run generators from an app definition file
|
|
50
|
+
# app definition files can be TS, JS, or JSON
|
|
51
|
+
arri codegen AppDefinition.ts
|
|
52
|
+
arri codegen AppDefinition.json
|
|
53
|
+
|
|
54
|
+
# run generators from an app definition JSON http endpoint
|
|
55
|
+
arri codegen https://example.com/__definition
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Codegen Flags
|
|
59
|
+
|
|
60
|
+
| Flag | Aliases | Description |
|
|
61
|
+
| -------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
62
|
+
| --config | -c | Path to an arri config. Default is `arri.config.ts` |
|
|
63
|
+
| --watch | -w | Watch an app definition file for changes. Only works on files. It will throw an error if invoked against an HTTP endpoint |
|
|
21
64
|
|
|
22
65
|
## Usage with @arrirpc/server
|
|
23
66
|
|
package/dist/cli.cjs
CHANGED
|
@@ -11,7 +11,8 @@ 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.
|
|
14
|
+
const dev = require('./shared/arri.09919c6d.cjs');
|
|
15
|
+
const chokidar = require('chokidar');
|
|
15
16
|
const ofetch = require('ofetch');
|
|
16
17
|
const Degit = require('degit');
|
|
17
18
|
const enquirer = require('enquirer');
|
|
@@ -95,11 +96,14 @@ async function startBuild(config, skipCodeGen = false) {
|
|
|
95
96
|
);
|
|
96
97
|
const def = JSON.parse(fs.readFileSync(defJson, { encoding: "utf-8" }));
|
|
97
98
|
if (codegenUtils.isAppDefinition(def) && clientCount > 0) {
|
|
98
|
-
|
|
99
|
+
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
100
|
+
dev.logger.log(`Generating ${clientCount} client(s)...`);
|
|
99
101
|
await Promise.all(
|
|
100
102
|
config.generators.map((plugin) => plugin.generator(def))
|
|
101
103
|
);
|
|
102
|
-
dev.logger.log(
|
|
104
|
+
dev.logger.log(
|
|
105
|
+
`${clientCount} client(s) generated in ${( new Date()).getTime() - startTime}ms`
|
|
106
|
+
);
|
|
103
107
|
} else {
|
|
104
108
|
dev.logger.warn(
|
|
105
109
|
"No client generators specified. Skipping client codegen."
|
|
@@ -212,7 +216,8 @@ async function createCodegenEntryFile(config) {
|
|
|
212
216
|
writeFileSync(
|
|
213
217
|
path.resolve(__dirname, "../.output", "__definition.json"),
|
|
214
218
|
JSON.stringify(def),
|
|
215
|
-
)
|
|
219
|
+
);
|
|
220
|
+
process.exit(0);`,
|
|
216
221
|
{ tabWidth: 4, parser: "typescript" }
|
|
217
222
|
);
|
|
218
223
|
await fs__default.writeFile(
|
|
@@ -236,74 +241,136 @@ const codegen = citty.defineCommand({
|
|
|
236
241
|
type: "string",
|
|
237
242
|
alias: ["c"],
|
|
238
243
|
default: "arri.config.ts"
|
|
244
|
+
},
|
|
245
|
+
watch: {
|
|
246
|
+
type: "boolean",
|
|
247
|
+
alias: ["w"],
|
|
248
|
+
default: false
|
|
239
249
|
}
|
|
240
250
|
},
|
|
241
251
|
async run({ args }) {
|
|
252
|
+
if (!fs__default$1.existsSync(path__default.resolve(args.config))) {
|
|
253
|
+
dev.logger.error(
|
|
254
|
+
`Unable to load arri config at ${args.config}. Please specify a valid config path with --config`
|
|
255
|
+
);
|
|
256
|
+
process.exit(1);
|
|
257
|
+
}
|
|
258
|
+
const { config } = await c12.loadConfig({
|
|
259
|
+
configFile: path__default.resolve(args.config)
|
|
260
|
+
});
|
|
261
|
+
if (!dev.isArriConfig(config)) {
|
|
262
|
+
dev.logger.error(`Invalid arri config at ${args.config}`);
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
if (!config.generators?.length) {
|
|
266
|
+
dev.logger.error(`No generators specified in ${args.config}`);
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
242
269
|
const isUrl = args.schema.startsWith("http://") || args.schema.startsWith("https://");
|
|
243
|
-
const isTs = args.schema.endsWith(".ts");
|
|
244
|
-
const isJs = args.schema.endsWith(".js");
|
|
245
270
|
let def;
|
|
246
271
|
if (isUrl) {
|
|
272
|
+
if (args.watch)
|
|
273
|
+
throw new Error("Cannot watch a URL");
|
|
247
274
|
const result = await ofetch.ofetch(args.schema);
|
|
248
275
|
if (!codegenUtils.isAppDefinition(result)) {
|
|
249
276
|
throw new Error(`Invalid App Definition at ${args.schema}`);
|
|
250
277
|
}
|
|
251
278
|
def = result;
|
|
252
279
|
} else {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
configFile: args.schema
|
|
259
|
-
});
|
|
260
|
-
if (!codegenUtils.isAppDefinition(schemaResult.config)) {
|
|
261
|
-
throw new Error(`Invalid App Definition at ${args.schema}`);
|
|
280
|
+
try {
|
|
281
|
+
def = await getAppDefinitionFromFile(args.schema);
|
|
282
|
+
} catch (err) {
|
|
283
|
+
if (!args.watch) {
|
|
284
|
+
throw err;
|
|
262
285
|
}
|
|
263
|
-
|
|
264
|
-
} else {
|
|
265
|
-
const jsonString = JSON.parse(
|
|
266
|
-
fs__default$1.readFileSync(args.schema, { encoding: "utf-8" })
|
|
267
|
-
);
|
|
268
|
-
if (!codegenUtils.isAppDefinition(jsonString)) {
|
|
269
|
-
throw new Error(`Invalid App Definition at ${args.schema}`);
|
|
270
|
-
}
|
|
271
|
-
def = jsonString;
|
|
286
|
+
dev.logger.error(err);
|
|
272
287
|
}
|
|
273
288
|
}
|
|
274
|
-
if (!def) {
|
|
289
|
+
if (!def && !args.watch) {
|
|
275
290
|
throw new Error(`Unable to find App Definition at ${args.schema}`);
|
|
276
291
|
}
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
292
|
+
if (def) {
|
|
293
|
+
const initialStartTime = /* @__PURE__ */ new Date();
|
|
294
|
+
await runGenerators(def, config.generators ?? []);
|
|
295
|
+
dev.logger.success(
|
|
296
|
+
`Generators completed in ${( new Date()).getTime() - initialStartTime.getTime()}ms`
|
|
280
297
|
);
|
|
281
298
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
299
|
+
if (!args.watch)
|
|
300
|
+
process.exit(0);
|
|
301
|
+
const watcher = chokidar.watch(args.schema, { ignoreInitial: true });
|
|
302
|
+
dev.logger.info(`Watching ${args.schema} for changes...`);
|
|
303
|
+
watcher.on("add", async (_, __) => {
|
|
304
|
+
try {
|
|
305
|
+
dev.logger.info(`Change detected`);
|
|
306
|
+
const startTime = /* @__PURE__ */ new Date();
|
|
307
|
+
await runGenerators(
|
|
308
|
+
await getAppDefinitionFromFile(args.schema),
|
|
309
|
+
config.generators ?? []
|
|
310
|
+
);
|
|
311
|
+
dev.logger.success(
|
|
312
|
+
`Generators completed in ${( new Date()).getTime() - startTime.getTime()}ms`
|
|
313
|
+
);
|
|
314
|
+
} catch (err) {
|
|
315
|
+
dev.logger.error(err);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
watcher.on("change", async (_, __) => {
|
|
319
|
+
try {
|
|
320
|
+
dev.logger.info(`Change detected in AppDefinition file.`);
|
|
321
|
+
const startTime = /* @__PURE__ */ new Date();
|
|
322
|
+
await runGenerators(
|
|
323
|
+
await getAppDefinitionFromFile(args.schema),
|
|
324
|
+
config.generators ?? []
|
|
325
|
+
);
|
|
326
|
+
dev.logger.success(
|
|
327
|
+
`Generators completed in ${( new Date()).getTime() - startTime.getTime()}ms`
|
|
328
|
+
);
|
|
329
|
+
} catch (err) {
|
|
330
|
+
dev.logger.error(err);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
async function getAppDefinitionFromFile(file) {
|
|
336
|
+
if (!fs__default$1.existsSync(file)) {
|
|
337
|
+
throw new Error(`Unable to find ${file}`);
|
|
338
|
+
}
|
|
339
|
+
const isTs = file.endsWith(".ts");
|
|
340
|
+
const isJs = file.endsWith(".js");
|
|
341
|
+
if (isTs || isJs) {
|
|
342
|
+
const schemaResult = await c12.loadConfig({
|
|
343
|
+
configFile: file
|
|
344
|
+
});
|
|
345
|
+
if (!codegenUtils.isAppDefinition(schemaResult.config)) {
|
|
346
|
+
throw new Error(`Invalid App Definition at ${file}`);
|
|
290
347
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
(gen) => gen.generator(
|
|
296
|
-
def ?? {
|
|
297
|
-
schemaVersion: "0.0.6",
|
|
298
|
-
procedures: {},
|
|
299
|
-
definitions: {}
|
|
300
|
-
}
|
|
301
|
-
)
|
|
302
|
-
)
|
|
348
|
+
return schemaResult.config;
|
|
349
|
+
} else {
|
|
350
|
+
const parsingResult = JSON.parse(
|
|
351
|
+
fs__default$1.readFileSync(file, { encoding: "utf-8" })
|
|
303
352
|
);
|
|
304
|
-
|
|
353
|
+
if (!codegenUtils.isAppDefinition(parsingResult)) {
|
|
354
|
+
throw new Error(`Invalid App Definition at ${file}`);
|
|
355
|
+
}
|
|
356
|
+
return parsingResult;
|
|
305
357
|
}
|
|
306
|
-
}
|
|
358
|
+
}
|
|
359
|
+
async function runGenerators(def, generators) {
|
|
360
|
+
dev.logger.info(`Generating ${generators?.length} client(s)`);
|
|
361
|
+
await Promise.allSettled(
|
|
362
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
363
|
+
generators.map(
|
|
364
|
+
(gen) => gen.generator(
|
|
365
|
+
def ?? {
|
|
366
|
+
schemaVersion: "0.0.6",
|
|
367
|
+
procedures: {},
|
|
368
|
+
definitions: {}
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
)
|
|
372
|
+
);
|
|
373
|
+
}
|
|
307
374
|
|
|
308
375
|
const init = citty.defineCommand({
|
|
309
376
|
meta: {
|
package/dist/cli.mjs
CHANGED
|
@@ -9,7 +9,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 getArriPackageMetadata, h as dev } from './shared/arri.
|
|
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.339f2f92.mjs';
|
|
13
|
+
import { watch } from 'chokidar';
|
|
13
14
|
import { ofetch } from 'ofetch';
|
|
14
15
|
import Degit from 'degit';
|
|
15
16
|
import enquirer from 'enquirer';
|
|
@@ -82,11 +83,14 @@ async function startBuild(config, skipCodeGen = false) {
|
|
|
82
83
|
);
|
|
83
84
|
const def = JSON.parse(readFileSync(defJson, { encoding: "utf-8" }));
|
|
84
85
|
if (isAppDefinition(def) && clientCount > 0) {
|
|
85
|
-
|
|
86
|
+
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
87
|
+
logger.log(`Generating ${clientCount} client(s)...`);
|
|
86
88
|
await Promise.all(
|
|
87
89
|
config.generators.map((plugin) => plugin.generator(def))
|
|
88
90
|
);
|
|
89
|
-
logger.log(
|
|
91
|
+
logger.log(
|
|
92
|
+
`${clientCount} client(s) generated in ${( new Date()).getTime() - startTime}ms`
|
|
93
|
+
);
|
|
90
94
|
} else {
|
|
91
95
|
logger.warn(
|
|
92
96
|
"No client generators specified. Skipping client codegen."
|
|
@@ -199,7 +203,8 @@ async function createCodegenEntryFile(config) {
|
|
|
199
203
|
writeFileSync(
|
|
200
204
|
path.resolve(__dirname, "../.output", "__definition.json"),
|
|
201
205
|
JSON.stringify(def),
|
|
202
|
-
)
|
|
206
|
+
);
|
|
207
|
+
process.exit(0);`,
|
|
203
208
|
{ tabWidth: 4, parser: "typescript" }
|
|
204
209
|
);
|
|
205
210
|
await fs.writeFile(
|
|
@@ -223,74 +228,136 @@ const codegen = defineCommand({
|
|
|
223
228
|
type: "string",
|
|
224
229
|
alias: ["c"],
|
|
225
230
|
default: "arri.config.ts"
|
|
231
|
+
},
|
|
232
|
+
watch: {
|
|
233
|
+
type: "boolean",
|
|
234
|
+
alias: ["w"],
|
|
235
|
+
default: false
|
|
226
236
|
}
|
|
227
237
|
},
|
|
228
238
|
async run({ args }) {
|
|
239
|
+
if (!fs$1.existsSync(path.resolve(args.config))) {
|
|
240
|
+
logger.error(
|
|
241
|
+
`Unable to load arri config at ${args.config}. Please specify a valid config path with --config`
|
|
242
|
+
);
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
const { config } = await loadConfig({
|
|
246
|
+
configFile: path.resolve(args.config)
|
|
247
|
+
});
|
|
248
|
+
if (!isArriConfig(config)) {
|
|
249
|
+
logger.error(`Invalid arri config at ${args.config}`);
|
|
250
|
+
process.exit(1);
|
|
251
|
+
}
|
|
252
|
+
if (!config.generators?.length) {
|
|
253
|
+
logger.error(`No generators specified in ${args.config}`);
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
229
256
|
const isUrl = args.schema.startsWith("http://") || args.schema.startsWith("https://");
|
|
230
|
-
const isTs = args.schema.endsWith(".ts");
|
|
231
|
-
const isJs = args.schema.endsWith(".js");
|
|
232
257
|
let def;
|
|
233
258
|
if (isUrl) {
|
|
259
|
+
if (args.watch)
|
|
260
|
+
throw new Error("Cannot watch a URL");
|
|
234
261
|
const result = await ofetch(args.schema);
|
|
235
262
|
if (!isAppDefinition(result)) {
|
|
236
263
|
throw new Error(`Invalid App Definition at ${args.schema}`);
|
|
237
264
|
}
|
|
238
265
|
def = result;
|
|
239
266
|
} else {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
configFile: args.schema
|
|
246
|
-
});
|
|
247
|
-
if (!isAppDefinition(schemaResult.config)) {
|
|
248
|
-
throw new Error(`Invalid App Definition at ${args.schema}`);
|
|
267
|
+
try {
|
|
268
|
+
def = await getAppDefinitionFromFile(args.schema);
|
|
269
|
+
} catch (err) {
|
|
270
|
+
if (!args.watch) {
|
|
271
|
+
throw err;
|
|
249
272
|
}
|
|
250
|
-
|
|
251
|
-
} else {
|
|
252
|
-
const jsonString = JSON.parse(
|
|
253
|
-
fs$1.readFileSync(args.schema, { encoding: "utf-8" })
|
|
254
|
-
);
|
|
255
|
-
if (!isAppDefinition(jsonString)) {
|
|
256
|
-
throw new Error(`Invalid App Definition at ${args.schema}`);
|
|
257
|
-
}
|
|
258
|
-
def = jsonString;
|
|
273
|
+
logger.error(err);
|
|
259
274
|
}
|
|
260
275
|
}
|
|
261
|
-
if (!def) {
|
|
276
|
+
if (!def && !args.watch) {
|
|
262
277
|
throw new Error(`Unable to find App Definition at ${args.schema}`);
|
|
263
278
|
}
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
|
|
279
|
+
if (def) {
|
|
280
|
+
const initialStartTime = /* @__PURE__ */ new Date();
|
|
281
|
+
await runGenerators(def, config.generators ?? []);
|
|
282
|
+
logger.success(
|
|
283
|
+
`Generators completed in ${( new Date()).getTime() - initialStartTime.getTime()}ms`
|
|
267
284
|
);
|
|
268
285
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
if (!args.watch)
|
|
287
|
+
process.exit(0);
|
|
288
|
+
const watcher = watch(args.schema, { ignoreInitial: true });
|
|
289
|
+
logger.info(`Watching ${args.schema} for changes...`);
|
|
290
|
+
watcher.on("add", async (_, __) => {
|
|
291
|
+
try {
|
|
292
|
+
logger.info(`Change detected`);
|
|
293
|
+
const startTime = /* @__PURE__ */ new Date();
|
|
294
|
+
await runGenerators(
|
|
295
|
+
await getAppDefinitionFromFile(args.schema),
|
|
296
|
+
config.generators ?? []
|
|
297
|
+
);
|
|
298
|
+
logger.success(
|
|
299
|
+
`Generators completed in ${( new Date()).getTime() - startTime.getTime()}ms`
|
|
300
|
+
);
|
|
301
|
+
} catch (err) {
|
|
302
|
+
logger.error(err);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
watcher.on("change", async (_, __) => {
|
|
306
|
+
try {
|
|
307
|
+
logger.info(`Change detected in AppDefinition file.`);
|
|
308
|
+
const startTime = /* @__PURE__ */ new Date();
|
|
309
|
+
await runGenerators(
|
|
310
|
+
await getAppDefinitionFromFile(args.schema),
|
|
311
|
+
config.generators ?? []
|
|
312
|
+
);
|
|
313
|
+
logger.success(
|
|
314
|
+
`Generators completed in ${( new Date()).getTime() - startTime.getTime()}ms`
|
|
315
|
+
);
|
|
316
|
+
} catch (err) {
|
|
317
|
+
logger.error(err);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
async function getAppDefinitionFromFile(file) {
|
|
323
|
+
if (!fs$1.existsSync(file)) {
|
|
324
|
+
throw new Error(`Unable to find ${file}`);
|
|
325
|
+
}
|
|
326
|
+
const isTs = file.endsWith(".ts");
|
|
327
|
+
const isJs = file.endsWith(".js");
|
|
328
|
+
if (isTs || isJs) {
|
|
329
|
+
const schemaResult = await loadConfig({
|
|
330
|
+
configFile: file
|
|
331
|
+
});
|
|
332
|
+
if (!isAppDefinition(schemaResult.config)) {
|
|
333
|
+
throw new Error(`Invalid App Definition at ${file}`);
|
|
277
334
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
(gen) => gen.generator(
|
|
283
|
-
def ?? {
|
|
284
|
-
schemaVersion: "0.0.6",
|
|
285
|
-
procedures: {},
|
|
286
|
-
definitions: {}
|
|
287
|
-
}
|
|
288
|
-
)
|
|
289
|
-
)
|
|
335
|
+
return schemaResult.config;
|
|
336
|
+
} else {
|
|
337
|
+
const parsingResult = JSON.parse(
|
|
338
|
+
fs$1.readFileSync(file, { encoding: "utf-8" })
|
|
290
339
|
);
|
|
291
|
-
|
|
340
|
+
if (!isAppDefinition(parsingResult)) {
|
|
341
|
+
throw new Error(`Invalid App Definition at ${file}`);
|
|
342
|
+
}
|
|
343
|
+
return parsingResult;
|
|
292
344
|
}
|
|
293
|
-
}
|
|
345
|
+
}
|
|
346
|
+
async function runGenerators(def, generators) {
|
|
347
|
+
logger.info(`Generating ${generators?.length} client(s)`);
|
|
348
|
+
await Promise.allSettled(
|
|
349
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
350
|
+
generators.map(
|
|
351
|
+
(gen) => gen.generator(
|
|
352
|
+
def ?? {
|
|
353
|
+
schemaVersion: "0.0.6",
|
|
354
|
+
procedures: {},
|
|
355
|
+
definitions: {}
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
)
|
|
359
|
+
);
|
|
360
|
+
}
|
|
294
361
|
|
|
295
362
|
const init = defineCommand({
|
|
296
363
|
meta: {
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const codegenDart = require('@arrirpc/codegen-dart');
|
|
|
4
4
|
const codegenKotlin = require('@arrirpc/codegen-kotlin');
|
|
5
5
|
const codegenRust = require('@arrirpc/codegen-rust');
|
|
6
6
|
const codegenTs = require('@arrirpc/codegen-ts');
|
|
7
|
-
const dev = require('./shared/arri.
|
|
7
|
+
const dev = require('./shared/arri.09919c6d.cjs');
|
|
8
8
|
const codegenUtils = require('@arrirpc/codegen-utils');
|
|
9
9
|
require('node:fs');
|
|
10
10
|
require('@joshmossas/listhen');
|
package/dist/index.d.cts
CHANGED
|
@@ -34,6 +34,11 @@ interface ArriConfig {
|
|
|
34
34
|
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
35
35
|
*/
|
|
36
36
|
additionalWatchDirs?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* If you want to serve both https and http on the dev server
|
|
39
|
+
*/
|
|
40
|
+
httpWithHttps?: boolean;
|
|
41
|
+
httpWithHttpsPort?: number;
|
|
37
42
|
};
|
|
38
43
|
}
|
|
39
44
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
package/dist/index.d.mts
CHANGED
|
@@ -34,6 +34,11 @@ interface ArriConfig {
|
|
|
34
34
|
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
35
35
|
*/
|
|
36
36
|
additionalWatchDirs?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* If you want to serve both https and http on the dev server
|
|
39
|
+
*/
|
|
40
|
+
httpWithHttps?: boolean;
|
|
41
|
+
httpWithHttpsPort?: number;
|
|
37
42
|
};
|
|
38
43
|
}
|
|
39
44
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,11 @@ interface ArriConfig {
|
|
|
34
34
|
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
35
35
|
*/
|
|
36
36
|
additionalWatchDirs?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* If you want to serve both https and http on the dev server
|
|
39
|
+
*/
|
|
40
|
+
httpWithHttps?: boolean;
|
|
41
|
+
httpWithHttpsPort?: number;
|
|
37
42
|
};
|
|
38
43
|
}
|
|
39
44
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { dartClientGenerator } from '@arrirpc/codegen-dart';
|
|
|
2
2
|
import { kotlinClientGenerator } from '@arrirpc/codegen-kotlin';
|
|
3
3
|
import { rustClientGenerator } from '@arrirpc/codegen-rust';
|
|
4
4
|
import { typescriptClientGenerator } from '@arrirpc/codegen-ts';
|
|
5
|
-
export { D as DEV_DEFINITION_ENDPOINT, d as defaultConfig, b as defineConfig, i as isArriConfig, a as isResolvedArriConfig } from './shared/arri.
|
|
5
|
+
export { D as DEV_DEFINITION_ENDPOINT, d as defaultConfig, b as defineConfig, i as isArriConfig, a as isResolvedArriConfig } from './shared/arri.339f2f92.mjs';
|
|
6
6
|
export { createAppDefinition } from '@arrirpc/codegen-utils';
|
|
7
7
|
import 'node:fs';
|
|
8
8
|
import '@joshmossas/listhen';
|
|
@@ -364,6 +364,28 @@ async function createDevServer(config) {
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
});
|
|
367
|
+
let secondaryListener;
|
|
368
|
+
if (config.devServer.httpWithHttps) {
|
|
369
|
+
secondaryListener = await listhen.listen(h3.toNodeListener(app), {
|
|
370
|
+
port: config.devServer.httpWithHttpsPort ?? config.port + 1,
|
|
371
|
+
https: false,
|
|
372
|
+
http2: config.http2,
|
|
373
|
+
public: true,
|
|
374
|
+
ws: {
|
|
375
|
+
resolve(info) {
|
|
376
|
+
if (ws?.resolve) {
|
|
377
|
+
return ws.resolve(info);
|
|
378
|
+
}
|
|
379
|
+
return {};
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
qr: false,
|
|
383
|
+
showURL: false
|
|
384
|
+
});
|
|
385
|
+
logger.info(
|
|
386
|
+
`Serving unencrypted traffic from port ${secondaryListener.address.port}`
|
|
387
|
+
);
|
|
388
|
+
}
|
|
367
389
|
async function reload() {
|
|
368
390
|
const appEntry = (await import(path__default.resolve(
|
|
369
391
|
config.rootDir,
|
|
@@ -378,6 +400,7 @@ async function createDevServer(config) {
|
|
|
378
400
|
return {
|
|
379
401
|
h3App: app,
|
|
380
402
|
listener,
|
|
403
|
+
secondaryListener,
|
|
381
404
|
reload,
|
|
382
405
|
ws
|
|
383
406
|
};
|
|
@@ -343,6 +343,28 @@ async function createDevServer(config) {
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
});
|
|
346
|
+
let secondaryListener;
|
|
347
|
+
if (config.devServer.httpWithHttps) {
|
|
348
|
+
secondaryListener = await listen(toNodeListener(app), {
|
|
349
|
+
port: config.devServer.httpWithHttpsPort ?? config.port + 1,
|
|
350
|
+
https: false,
|
|
351
|
+
http2: config.http2,
|
|
352
|
+
public: true,
|
|
353
|
+
ws: {
|
|
354
|
+
resolve(info) {
|
|
355
|
+
if (ws?.resolve) {
|
|
356
|
+
return ws.resolve(info);
|
|
357
|
+
}
|
|
358
|
+
return {};
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
qr: false,
|
|
362
|
+
showURL: false
|
|
363
|
+
});
|
|
364
|
+
logger.info(
|
|
365
|
+
`Serving unencrypted traffic from port ${secondaryListener.address.port}`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
346
368
|
async function reload() {
|
|
347
369
|
const appEntry = (await import(path.resolve(
|
|
348
370
|
config.rootDir,
|
|
@@ -357,6 +379,7 @@ async function createDevServer(config) {
|
|
|
357
379
|
return {
|
|
358
380
|
h3App: app,
|
|
359
381
|
listener,
|
|
382
|
+
secondaryListener,
|
|
360
383
|
reload,
|
|
361
384
|
ws
|
|
362
385
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arri",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"ofetch": "^1.3.4",
|
|
40
40
|
"pathe": "^1.1.2",
|
|
41
41
|
"prettier": "^3.3.3",
|
|
42
|
-
"@arrirpc/codegen-dart": "0.57.
|
|
43
|
-
"@arrirpc/codegen-rust": "0.57.
|
|
44
|
-
"@arrirpc/codegen-
|
|
45
|
-
"@arrirpc/codegen-
|
|
46
|
-
"@arrirpc/schema": "0.57.
|
|
47
|
-
"@arrirpc/codegen-
|
|
42
|
+
"@arrirpc/codegen-dart": "0.57.5",
|
|
43
|
+
"@arrirpc/codegen-rust": "0.57.5",
|
|
44
|
+
"@arrirpc/codegen-ts": "0.57.5",
|
|
45
|
+
"@arrirpc/codegen-utils": "0.57.5",
|
|
46
|
+
"@arrirpc/schema": "0.57.5",
|
|
47
|
+
"@arrirpc/codegen-kotlin": "0.57.5"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/degit": "^2.8.6"
|