arri 0.58.1 → 0.60.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.
@@ -0,0 +1,177 @@
1
+ 'use strict';
2
+
3
+ const c12 = require('c12');
4
+ const citty = require('citty');
5
+ const path = require('pathe');
6
+ const schema = require('@arrirpc/schema');
7
+ const ofetch = require('@joshmossas/ofetch');
8
+ const consola = require('consola');
9
+
10
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
+
12
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
13
+
14
+ function isServerConfig(input) {
15
+ if (typeof input !== "object" || input === null) {
16
+ return false;
17
+ }
18
+ return "devFn" in input && typeof input.devFn === "function" && "buildFn" in input && typeof input.buildFn === "function";
19
+ }
20
+ function defineServerConfig(config) {
21
+ return config;
22
+ }
23
+
24
+ function isArriConfig(input) {
25
+ if (typeof input !== "object" || input === null) {
26
+ return false;
27
+ }
28
+ if ("server" in input) {
29
+ if (typeof input.server !== "undefined" && !isServerConfig(input.server)) {
30
+ return false;
31
+ }
32
+ }
33
+ return "generators" in input && Array.isArray(input.generators);
34
+ }
35
+ function defineConfig(config) {
36
+ return config;
37
+ }
38
+
39
+ const DEV_ENDPOINT_ROOT = `/__arri_dev__`;
40
+ const DEV_DEFINITION_ENDPOINT = `${DEV_ENDPOINT_ROOT}/__definition`;
41
+ const dev = citty.defineCommand({
42
+ meta: {
43
+ name: "dev",
44
+ description: "Start the arri dev server"
45
+ },
46
+ args: {
47
+ config: {
48
+ type: "string",
49
+ description: "Path to the arri config file",
50
+ alias: "c",
51
+ default: "./arri.config.ts"
52
+ }
53
+ },
54
+ async run({ args, rawArgs }) {
55
+ const { config } = await c12.loadConfig({
56
+ configFile: path__default.resolve(args.config)
57
+ });
58
+ if (!config) {
59
+ throw new Error(`Unable to find arri config at ${args.config}`);
60
+ }
61
+ if (!isArriConfig(config)) {
62
+ throw new Error(`Invalid config file at ${args.config}`);
63
+ }
64
+ if (!config.server) {
65
+ throw new Error(
66
+ `No server specified in ${args.config}. Cannot start dev server.`
67
+ );
68
+ }
69
+ const subCommand = citty.defineCommand({
70
+ args: config.server.devArgs,
71
+ async run({ args: args2 }) {
72
+ await config.server?.devFn(args2, config.generators);
73
+ }
74
+ });
75
+ await citty.runCommand(subCommand, { rawArgs });
76
+ }
77
+ });
78
+
79
+ const logger = consola.createConsola().withTag("arri");
80
+ function isInsideDir(dir, parentDir) {
81
+ if (path__default.resolve(dir).startsWith(path__default.resolve(parentDir))) {
82
+ return true;
83
+ }
84
+ return false;
85
+ }
86
+ async function getArriPackageMetadata() {
87
+ const npmPackageResponse = await ofetch.ofetch("https://registry.npmjs.com/arri");
88
+ const arriInfo = schema.a.safeParse(NpmRegistryPackage, npmPackageResponse);
89
+ if (!arriInfo.success) {
90
+ const errors = schema.a.errors(NpmRegistryPackage, npmPackageResponse);
91
+ console.warn(errors);
92
+ throw new schema.ValidationError({
93
+ message: "Arri parsing response from registry",
94
+ errors
95
+ });
96
+ }
97
+ return arriInfo.value;
98
+ }
99
+ const NpmPackageVersion = schema.a.partial(
100
+ schema.a.object({
101
+ name: schema.a.string(),
102
+ version: schema.a.string(),
103
+ _id: schema.a.string(),
104
+ maintainers: schema.a.array(
105
+ schema.a.object({
106
+ name: schema.a.string(),
107
+ email: schema.a.string()
108
+ })
109
+ ),
110
+ bin: schema.a.record(schema.a.string()),
111
+ dist: schema.a.any(),
112
+ main: schema.a.string(),
113
+ type: schema.a.string(),
114
+ types: schema.a.string(),
115
+ module: schema.a.string(),
116
+ gitHead: schema.a.string(),
117
+ _npmUser: schema.a.object({
118
+ name: schema.a.string(),
119
+ email: schema.a.string()
120
+ }),
121
+ description: schema.a.string(),
122
+ directories: schema.a.record(schema.a.any()),
123
+ _nodeVersion: schema.a.string(),
124
+ dependencies: schema.a.record(schema.a.string()),
125
+ _hasShrinkWrap: schema.a.boolean(),
126
+ _npmOperationalInternal: schema.a.any()
127
+ })
128
+ );
129
+ const NpmRegistryPackage = schema.a.object({
130
+ _id: schema.a.string(),
131
+ _rev: schema.a.string(),
132
+ name: schema.a.string(),
133
+ description: schema.a.string(),
134
+ "dist-tags": schema.a.record(schema.a.string()),
135
+ versions: schema.a.record(NpmPackageVersion),
136
+ time: schema.a.record(schema.a.string()),
137
+ maintainers: schema.a.array(
138
+ schema.a.object({
139
+ name: schema.a.string(),
140
+ email: schema.a.string()
141
+ })
142
+ ),
143
+ author: schema.a.object({
144
+ name: schema.a.string(),
145
+ url: schema.a.string()
146
+ }),
147
+ repository: schema.a.optional(
148
+ schema.a.partial(
149
+ schema.a.object({
150
+ type: schema.a.string(),
151
+ url: schema.a.string(),
152
+ directory: schema.a.string()
153
+ })
154
+ )
155
+ ),
156
+ license: schema.a.optional(schema.a.string()),
157
+ homepage: schema.a.optional(schema.a.string()),
158
+ bugs: schema.a.optional(
159
+ schema.a.partial(
160
+ schema.a.object({
161
+ url: schema.a.string()
162
+ })
163
+ )
164
+ ),
165
+ readme: schema.a.optional(schema.a.string()),
166
+ readmeFilename: schema.a.optional(schema.a.string())
167
+ });
168
+
169
+ exports.DEV_DEFINITION_ENDPOINT = DEV_DEFINITION_ENDPOINT;
170
+ exports.defineConfig = defineConfig;
171
+ exports.defineServerConfig = defineServerConfig;
172
+ exports.dev = dev;
173
+ exports.getArriPackageMetadata = getArriPackageMetadata;
174
+ exports.isArriConfig = isArriConfig;
175
+ exports.isInsideDir = isInsideDir;
176
+ exports.isServerConfig = isServerConfig;
177
+ exports.logger = logger;
@@ -0,0 +1,163 @@
1
+ import { loadConfig } from 'c12';
2
+ import { defineCommand, runCommand } from 'citty';
3
+ import path from 'pathe';
4
+ import { a, ValidationError } from '@arrirpc/schema';
5
+ import { ofetch } from '@joshmossas/ofetch';
6
+ import { createConsola } from 'consola';
7
+
8
+ function isServerConfig(input) {
9
+ if (typeof input !== "object" || input === null) {
10
+ return false;
11
+ }
12
+ return "devFn" in input && typeof input.devFn === "function" && "buildFn" in input && typeof input.buildFn === "function";
13
+ }
14
+ function defineServerConfig(config) {
15
+ return config;
16
+ }
17
+
18
+ function isArriConfig(input) {
19
+ if (typeof input !== "object" || input === null) {
20
+ return false;
21
+ }
22
+ if ("server" in input) {
23
+ if (typeof input.server !== "undefined" && !isServerConfig(input.server)) {
24
+ return false;
25
+ }
26
+ }
27
+ return "generators" in input && Array.isArray(input.generators);
28
+ }
29
+ function defineConfig(config) {
30
+ return config;
31
+ }
32
+
33
+ const DEV_ENDPOINT_ROOT = `/__arri_dev__`;
34
+ const DEV_DEFINITION_ENDPOINT = `${DEV_ENDPOINT_ROOT}/__definition`;
35
+ const dev = defineCommand({
36
+ meta: {
37
+ name: "dev",
38
+ description: "Start the arri dev server"
39
+ },
40
+ args: {
41
+ config: {
42
+ type: "string",
43
+ description: "Path to the arri config file",
44
+ alias: "c",
45
+ default: "./arri.config.ts"
46
+ }
47
+ },
48
+ async run({ args, rawArgs }) {
49
+ const { config } = await loadConfig({
50
+ configFile: path.resolve(args.config)
51
+ });
52
+ if (!config) {
53
+ throw new Error(`Unable to find arri config at ${args.config}`);
54
+ }
55
+ if (!isArriConfig(config)) {
56
+ throw new Error(`Invalid config file at ${args.config}`);
57
+ }
58
+ if (!config.server) {
59
+ throw new Error(
60
+ `No server specified in ${args.config}. Cannot start dev server.`
61
+ );
62
+ }
63
+ const subCommand = defineCommand({
64
+ args: config.server.devArgs,
65
+ async run({ args: args2 }) {
66
+ await config.server?.devFn(args2, config.generators);
67
+ }
68
+ });
69
+ await runCommand(subCommand, { rawArgs });
70
+ }
71
+ });
72
+
73
+ const logger = createConsola().withTag("arri");
74
+ function isInsideDir(dir, parentDir) {
75
+ if (path.resolve(dir).startsWith(path.resolve(parentDir))) {
76
+ return true;
77
+ }
78
+ return false;
79
+ }
80
+ async function getArriPackageMetadata() {
81
+ const npmPackageResponse = await ofetch("https://registry.npmjs.com/arri");
82
+ const arriInfo = a.safeParse(NpmRegistryPackage, npmPackageResponse);
83
+ if (!arriInfo.success) {
84
+ const errors = a.errors(NpmRegistryPackage, npmPackageResponse);
85
+ console.warn(errors);
86
+ throw new ValidationError({
87
+ message: "Arri parsing response from registry",
88
+ errors
89
+ });
90
+ }
91
+ return arriInfo.value;
92
+ }
93
+ const NpmPackageVersion = a.partial(
94
+ a.object({
95
+ name: a.string(),
96
+ version: a.string(),
97
+ _id: a.string(),
98
+ maintainers: a.array(
99
+ a.object({
100
+ name: a.string(),
101
+ email: a.string()
102
+ })
103
+ ),
104
+ bin: a.record(a.string()),
105
+ dist: a.any(),
106
+ main: a.string(),
107
+ type: a.string(),
108
+ types: a.string(),
109
+ module: a.string(),
110
+ gitHead: a.string(),
111
+ _npmUser: a.object({
112
+ name: a.string(),
113
+ email: a.string()
114
+ }),
115
+ description: a.string(),
116
+ directories: a.record(a.any()),
117
+ _nodeVersion: a.string(),
118
+ dependencies: a.record(a.string()),
119
+ _hasShrinkWrap: a.boolean(),
120
+ _npmOperationalInternal: a.any()
121
+ })
122
+ );
123
+ const NpmRegistryPackage = a.object({
124
+ _id: a.string(),
125
+ _rev: a.string(),
126
+ name: a.string(),
127
+ description: a.string(),
128
+ "dist-tags": a.record(a.string()),
129
+ versions: a.record(NpmPackageVersion),
130
+ time: a.record(a.string()),
131
+ maintainers: a.array(
132
+ a.object({
133
+ name: a.string(),
134
+ email: a.string()
135
+ })
136
+ ),
137
+ author: a.object({
138
+ name: a.string(),
139
+ url: a.string()
140
+ }),
141
+ repository: a.optional(
142
+ a.partial(
143
+ a.object({
144
+ type: a.string(),
145
+ url: a.string(),
146
+ directory: a.string()
147
+ })
148
+ )
149
+ ),
150
+ license: a.optional(a.string()),
151
+ homepage: a.optional(a.string()),
152
+ bugs: a.optional(
153
+ a.partial(
154
+ a.object({
155
+ url: a.string()
156
+ })
157
+ )
158
+ ),
159
+ readme: a.optional(a.string()),
160
+ readmeFilename: a.optional(a.string())
161
+ });
162
+
163
+ export { DEV_DEFINITION_ENDPOINT as D, isArriConfig as a, defineConfig as b, isServerConfig as c, defineServerConfig as d, dev as e, getArriPackageMetadata as g, isInsideDir as i, logger as l };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arri",
3
- "version": "0.58.1",
3
+ "version": "0.60.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,18 +33,19 @@
33
33
  "consola": "^3.2.3",
34
34
  "degit": "^2.8.4",
35
35
  "enquirer": "^2.4.1",
36
- "esbuild": "^0.23.0",
36
+ "esbuild": "^0.23.1",
37
37
  "esbuild-plugin-replace": "^1.4.0",
38
38
  "globby": "^14.0.2",
39
39
  "h3": "^1.12.0",
40
40
  "pathe": "^1.1.2",
41
41
  "prettier": "^3.3.3",
42
- "@arrirpc/codegen-dart": "0.58.1",
43
- "@arrirpc/codegen-rust": "0.58.1",
44
- "@arrirpc/codegen-kotlin": "0.58.1",
45
- "@arrirpc/codegen-utils": "0.58.1",
46
- "@arrirpc/codegen-ts": "0.58.1",
47
- "@arrirpc/schema": "0.58.1"
42
+ "@arrirpc/codegen-dart": "0.60.1",
43
+ "@arrirpc/codegen-rust": "0.60.1",
44
+ "@arrirpc/codegen-utils": "0.60.1",
45
+ "@arrirpc/codegen-swift": "0.60.1",
46
+ "@arrirpc/schema": "0.60.1",
47
+ "@arrirpc/codegen-ts": "0.60.1",
48
+ "@arrirpc/codegen-kotlin": "0.60.1"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@types/degit": "^2.8.6"