arri 0.80.1 → 0.80.3
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/index.cjs +73 -72
- package/dist/index.mjs +73 -72
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -8,10 +8,11 @@ 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 node_process = require('node:process');
|
|
11
12
|
const chokidar = require('chokidar');
|
|
12
13
|
const path = require('pathe');
|
|
13
|
-
const fs$1 = require('node:fs/promises');
|
|
14
14
|
const os = require('node:os');
|
|
15
|
+
const fs$1 = require('node:fs/promises');
|
|
15
16
|
const codegenUtils = require('@arrirpc/codegen-utils');
|
|
16
17
|
const listhen = require('@joshmossas/listhen');
|
|
17
18
|
const esbuild = require('esbuild');
|
|
@@ -46,11 +47,33 @@ const typescriptCodegen__namespace = /*#__PURE__*/_interopNamespaceCompat(typesc
|
|
|
46
47
|
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
47
48
|
const chokidar__default = /*#__PURE__*/_interopDefaultCompat(chokidar);
|
|
48
49
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
49
|
-
const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs$1);
|
|
50
50
|
const os__default = /*#__PURE__*/_interopDefaultCompat(os);
|
|
51
|
+
const fs__namespace = /*#__PURE__*/_interopNamespaceCompat(fs$1);
|
|
51
52
|
const esbuild__default = /*#__PURE__*/_interopDefaultCompat(esbuild);
|
|
52
53
|
const prettier__default = /*#__PURE__*/_interopDefaultCompat(prettier);
|
|
53
54
|
|
|
55
|
+
function createWindowsCompatibleImportPath(input, prefixWithFile = true) {
|
|
56
|
+
let separator;
|
|
57
|
+
for (const char of input) {
|
|
58
|
+
if (char === "\\") {
|
|
59
|
+
separator = "\\";
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
if (char === "/") {
|
|
63
|
+
separator = "/";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const parts = input.split(separator ?? "/");
|
|
67
|
+
if (parts[0]?.endsWith(":") && prefixWithFile) {
|
|
68
|
+
parts.unshift("file:\\");
|
|
69
|
+
}
|
|
70
|
+
const newStr = parts.join("\\");
|
|
71
|
+
return newStr;
|
|
72
|
+
}
|
|
73
|
+
function isOnWindows() {
|
|
74
|
+
return os__default.type() === "Windows_NT";
|
|
75
|
+
}
|
|
76
|
+
|
|
54
77
|
function goServer(options = {}) {
|
|
55
78
|
const outDir = options.outputDir ?? ".output";
|
|
56
79
|
const resolvedOutDir = options.cwd ? path__default.resolve(options.cwd, outDir) : outDir;
|
|
@@ -78,14 +101,17 @@ function goServer(options = {}) {
|
|
|
78
101
|
cwd: options.cwd
|
|
79
102
|
});
|
|
80
103
|
let childProcess;
|
|
104
|
+
common.logger.info(`Starting server`);
|
|
105
|
+
const buildCmd = goBuildCommand(outDir);
|
|
106
|
+
const startCmd = goStartServerCommand(outDir);
|
|
81
107
|
async function spawnProcess() {
|
|
82
108
|
try {
|
|
83
|
-
node_child_process.execSync(
|
|
109
|
+
node_child_process.execSync(buildCmd, {
|
|
84
110
|
stdio: "inherit",
|
|
85
111
|
cwd: options.cwd
|
|
86
112
|
});
|
|
87
113
|
childProcess = node_child_process.spawn(
|
|
88
|
-
|
|
114
|
+
startCmd,
|
|
89
115
|
[`--def-out=${outDir}/__definition.json`],
|
|
90
116
|
{
|
|
91
117
|
stdio: "inherit",
|
|
@@ -182,15 +208,16 @@ function goServer(options = {}) {
|
|
|
182
208
|
if (!fs__default.existsSync(outDir)) {
|
|
183
209
|
fs__default.mkdirSync(outDir);
|
|
184
210
|
}
|
|
185
|
-
|
|
186
|
-
|
|
211
|
+
const buildCmd = goBuildCommand(outDir);
|
|
212
|
+
const startCmd = goStartServerCommand(outDir);
|
|
213
|
+
node_child_process.execSync(buildCmd, {
|
|
214
|
+
stdio: "inherit",
|
|
215
|
+
cwd: options.cwd
|
|
216
|
+
});
|
|
217
|
+
node_child_process.execSync(`${startCmd} def -output ${outDir}/__definition.json`, {
|
|
218
|
+
stdio: "inherit",
|
|
219
|
+
cwd: options.cwd ?? node_process.cwd()
|
|
187
220
|
});
|
|
188
|
-
node_child_process.execSync(
|
|
189
|
-
`${outDir}/server def -output ${outDir}/__definition.json`,
|
|
190
|
-
{
|
|
191
|
-
stdio: "inherit"
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
221
|
if (generators.length === 0) {
|
|
195
222
|
common.logger.warn(
|
|
196
223
|
"No generators specified in arri config. Skipping codegen."
|
|
@@ -211,6 +238,18 @@ function goServer(options = {}) {
|
|
|
211
238
|
}
|
|
212
239
|
});
|
|
213
240
|
}
|
|
241
|
+
function goBuildCommand(outDir) {
|
|
242
|
+
if (isOnWindows()) {
|
|
243
|
+
return `go build -o ${outDir}/server.exe`;
|
|
244
|
+
}
|
|
245
|
+
return `go build -o ${outDir}/server`;
|
|
246
|
+
}
|
|
247
|
+
function goStartServerCommand(outDir) {
|
|
248
|
+
if (isOnWindows()) {
|
|
249
|
+
return `.\\${outDir}\\server.exe`;
|
|
250
|
+
}
|
|
251
|
+
return `./${outDir}/server`;
|
|
252
|
+
}
|
|
214
253
|
|
|
215
254
|
function tsServer(serverConfig) {
|
|
216
255
|
return common.defineServerConfig({
|
|
@@ -298,31 +337,37 @@ async function startBuild(generators, serverConfig, skipCodeGen = false) {
|
|
|
298
337
|
await setupWorkingDir(serverConfig);
|
|
299
338
|
await Promise.all([
|
|
300
339
|
createAppWithRoutesModule(serverConfig),
|
|
301
|
-
createServerEntryFile(serverConfig)
|
|
302
|
-
createCodegenEntryFile(serverConfig)
|
|
340
|
+
createServerEntryFile(serverConfig)
|
|
341
|
+
// createCodegenEntryFile(serverConfig),
|
|
303
342
|
]);
|
|
304
343
|
await bundleAppEntry(serverConfig);
|
|
305
344
|
common.logger.log("Finished bundling");
|
|
306
345
|
const clientCount = generators.length ?? 0;
|
|
307
|
-
const codegenModule = path__default.resolve(
|
|
308
|
-
serverConfig.rootDir,
|
|
309
|
-
".output",
|
|
310
|
-
OUT_CODEGEN
|
|
311
|
-
);
|
|
312
346
|
if (!skipCodeGen) {
|
|
313
347
|
common.logger.log("Generating Arri app definition (__definition.json)");
|
|
314
|
-
|
|
315
|
-
const defJson = path__default.resolve(
|
|
348
|
+
let appImportPath = path__default.resolve(
|
|
316
349
|
serverConfig.rootDir,
|
|
317
350
|
".output",
|
|
318
|
-
|
|
351
|
+
OUT_APP_FILE
|
|
319
352
|
);
|
|
320
|
-
|
|
321
|
-
|
|
353
|
+
if (isOnWindows()) {
|
|
354
|
+
appImportPath = createWindowsCompatibleImportPath(appImportPath);
|
|
355
|
+
}
|
|
356
|
+
const app = (await import(appImportPath)).default;
|
|
357
|
+
const appDef = app.getAppDefinition();
|
|
358
|
+
if (codegenUtils.isAppDefinition(appDef) && clientCount > 0) {
|
|
359
|
+
fs__namespace.writeFile(
|
|
360
|
+
path__default.resolve(
|
|
361
|
+
serverConfig.rootDir,
|
|
362
|
+
".output",
|
|
363
|
+
"__definition.json"
|
|
364
|
+
),
|
|
365
|
+
JSON.stringify(appDef)
|
|
366
|
+
);
|
|
322
367
|
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
323
368
|
common.logger.log(`Generating ${clientCount} client(s)...`);
|
|
324
369
|
await Promise.all(
|
|
325
|
-
generators.map((generator) => generator.run(
|
|
370
|
+
generators.map((generator) => generator.run(appDef, false)) ?? []
|
|
326
371
|
);
|
|
327
372
|
common.logger.log(
|
|
328
373
|
`${clientCount} client(s) generated in ${(/* @__PURE__ */ new Date()).getTime() - startTime}ms`
|
|
@@ -335,11 +380,10 @@ async function startBuild(generators, serverConfig, skipCodeGen = false) {
|
|
|
335
380
|
} else {
|
|
336
381
|
common.logger.log("Skipping codegen");
|
|
337
382
|
}
|
|
338
|
-
common.logger.log("Cleaning up files");
|
|
339
|
-
await fs__namespace.rm(codegenModule);
|
|
340
383
|
common.logger.success(
|
|
341
384
|
`Build finished! You can start your server by running "node .output/${OUT_SERVER_ENTRY}"`
|
|
342
385
|
);
|
|
386
|
+
process.exit(0);
|
|
343
387
|
}
|
|
344
388
|
async function bundleAppEntry(config, _allowCodegen = true) {
|
|
345
389
|
const appEntry = path__default.resolve(
|
|
@@ -424,30 +468,6 @@ void listen(toNodeListener(app.h3App), {
|
|
|
424
468
|
virtualEntry
|
|
425
469
|
);
|
|
426
470
|
}
|
|
427
|
-
async function createCodegenEntryFile(config) {
|
|
428
|
-
const appModule = path__default.resolve(config.rootDir, config.srcDir, config.entry);
|
|
429
|
-
const appImportParts = path__default.relative(path__default.resolve(config.rootDir, config.srcDir), appModule).split(".");
|
|
430
|
-
appImportParts.pop();
|
|
431
|
-
const virtualModule = await prettier__default.format(
|
|
432
|
-
`
|
|
433
|
-
import { writeFileSync } from 'node:fs';
|
|
434
|
-
import path from 'node:path';
|
|
435
|
-
import app from './${OUT_APP_FILE}';
|
|
436
|
-
|
|
437
|
-
const __dirname = new URL(".", import.meta.url).pathname;
|
|
438
|
-
const def = app.getAppDefinition();
|
|
439
|
-
writeFileSync(
|
|
440
|
-
path.resolve(__dirname, "../.output", "__definition.json"),
|
|
441
|
-
JSON.stringify(def),
|
|
442
|
-
);
|
|
443
|
-
process.exit(0);`,
|
|
444
|
-
{ tabWidth: 4, parser: "typescript" }
|
|
445
|
-
);
|
|
446
|
-
await fs__namespace.writeFile(
|
|
447
|
-
path__default.resolve(config.rootDir, ".output", OUT_CODEGEN),
|
|
448
|
-
virtualModule
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
471
|
async function bundleFilesContext(config) {
|
|
452
472
|
return await esbuild__default.context({
|
|
453
473
|
...config.esbuild,
|
|
@@ -513,8 +533,8 @@ async function createDevServer(config) {
|
|
|
513
533
|
".output",
|
|
514
534
|
`${OUT_APP_FILE}?version=${Date.now()}`
|
|
515
535
|
);
|
|
516
|
-
if (
|
|
517
|
-
importPath =
|
|
536
|
+
if (isOnWindows()) {
|
|
537
|
+
importPath = createWindowsCompatibleImportPath(importPath);
|
|
518
538
|
}
|
|
519
539
|
const appEntry = (await import(importPath)).default;
|
|
520
540
|
dynamicHandler.set(h3.fromNodeMiddleware(appEntry.h3App.handler));
|
|
@@ -530,24 +550,6 @@ async function createDevServer(config) {
|
|
|
530
550
|
ws
|
|
531
551
|
};
|
|
532
552
|
}
|
|
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
|
-
}
|
|
551
553
|
async function startDevServer(config, generators) {
|
|
552
554
|
await setupWorkingDir(config);
|
|
553
555
|
const watcher = await import('chokidar');
|
|
@@ -663,7 +665,6 @@ async function generateClientsFromDefinition(appDef, generators, isDev) {
|
|
|
663
665
|
const GEN_APP_FILE = "__arri_app.ts";
|
|
664
666
|
const OUT_APP_FILE = "app.mjs";
|
|
665
667
|
const OUT_SERVER_ENTRY = "server.mjs";
|
|
666
|
-
const OUT_CODEGEN = "codegen.mjs";
|
|
667
668
|
async function setupWorkingDir(config) {
|
|
668
669
|
const arriDir = path__default.resolve(config.rootDir, config.buildDir);
|
|
669
670
|
const outDir = path__default.resolve(config.rootDir, ".output");
|
package/dist/index.mjs
CHANGED
|
@@ -6,11 +6,12 @@ import * as typescriptCodegen from '@arrirpc/codegen-ts';
|
|
|
6
6
|
import { d as defineServerConfig, l as logger, i as isInsideDir } from './shared/arri.CGlJ9Ywd.mjs';
|
|
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
|
-
import fs$1, { existsSync
|
|
9
|
+
import fs$1, { existsSync } from 'node:fs';
|
|
10
|
+
import { cwd } from 'node:process';
|
|
10
11
|
import chokidar from 'chokidar';
|
|
11
12
|
import path from 'pathe';
|
|
12
|
-
import * as fs from 'node:fs/promises';
|
|
13
13
|
import os from 'node:os';
|
|
14
|
+
import * as fs from 'node:fs/promises';
|
|
14
15
|
import { isAppDefinition, camelCase, removeDisallowedChars, kebabCase } from '@arrirpc/codegen-utils';
|
|
15
16
|
export { createAppDefinition } from '@arrirpc/codegen-utils';
|
|
16
17
|
import { listen } from '@joshmossas/listhen';
|
|
@@ -24,6 +25,28 @@ import '@arrirpc/schema';
|
|
|
24
25
|
import 'consola';
|
|
25
26
|
import 'ofetch';
|
|
26
27
|
|
|
28
|
+
function createWindowsCompatibleImportPath(input, prefixWithFile = true) {
|
|
29
|
+
let separator;
|
|
30
|
+
for (const char of input) {
|
|
31
|
+
if (char === "\\") {
|
|
32
|
+
separator = "\\";
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (char === "/") {
|
|
36
|
+
separator = "/";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const parts = input.split(separator ?? "/");
|
|
40
|
+
if (parts[0]?.endsWith(":") && prefixWithFile) {
|
|
41
|
+
parts.unshift("file:\\");
|
|
42
|
+
}
|
|
43
|
+
const newStr = parts.join("\\");
|
|
44
|
+
return newStr;
|
|
45
|
+
}
|
|
46
|
+
function isOnWindows() {
|
|
47
|
+
return os.type() === "Windows_NT";
|
|
48
|
+
}
|
|
49
|
+
|
|
27
50
|
function goServer(options = {}) {
|
|
28
51
|
const outDir = options.outputDir ?? ".output";
|
|
29
52
|
const resolvedOutDir = options.cwd ? path.resolve(options.cwd, outDir) : outDir;
|
|
@@ -51,14 +74,17 @@ function goServer(options = {}) {
|
|
|
51
74
|
cwd: options.cwd
|
|
52
75
|
});
|
|
53
76
|
let childProcess;
|
|
77
|
+
logger.info(`Starting server`);
|
|
78
|
+
const buildCmd = goBuildCommand(outDir);
|
|
79
|
+
const startCmd = goStartServerCommand(outDir);
|
|
54
80
|
async function spawnProcess() {
|
|
55
81
|
try {
|
|
56
|
-
execSync(
|
|
82
|
+
execSync(buildCmd, {
|
|
57
83
|
stdio: "inherit",
|
|
58
84
|
cwd: options.cwd
|
|
59
85
|
});
|
|
60
86
|
childProcess = spawn(
|
|
61
|
-
|
|
87
|
+
startCmd,
|
|
62
88
|
[`--def-out=${outDir}/__definition.json`],
|
|
63
89
|
{
|
|
64
90
|
stdio: "inherit",
|
|
@@ -155,15 +181,16 @@ function goServer(options = {}) {
|
|
|
155
181
|
if (!fs$1.existsSync(outDir)) {
|
|
156
182
|
fs$1.mkdirSync(outDir);
|
|
157
183
|
}
|
|
158
|
-
|
|
159
|
-
|
|
184
|
+
const buildCmd = goBuildCommand(outDir);
|
|
185
|
+
const startCmd = goStartServerCommand(outDir);
|
|
186
|
+
execSync(buildCmd, {
|
|
187
|
+
stdio: "inherit",
|
|
188
|
+
cwd: options.cwd
|
|
189
|
+
});
|
|
190
|
+
execSync(`${startCmd} def -output ${outDir}/__definition.json`, {
|
|
191
|
+
stdio: "inherit",
|
|
192
|
+
cwd: options.cwd ?? cwd()
|
|
160
193
|
});
|
|
161
|
-
execSync(
|
|
162
|
-
`${outDir}/server def -output ${outDir}/__definition.json`,
|
|
163
|
-
{
|
|
164
|
-
stdio: "inherit"
|
|
165
|
-
}
|
|
166
|
-
);
|
|
167
194
|
if (generators.length === 0) {
|
|
168
195
|
logger.warn(
|
|
169
196
|
"No generators specified in arri config. Skipping codegen."
|
|
@@ -184,6 +211,18 @@ function goServer(options = {}) {
|
|
|
184
211
|
}
|
|
185
212
|
});
|
|
186
213
|
}
|
|
214
|
+
function goBuildCommand(outDir) {
|
|
215
|
+
if (isOnWindows()) {
|
|
216
|
+
return `go build -o ${outDir}/server.exe`;
|
|
217
|
+
}
|
|
218
|
+
return `go build -o ${outDir}/server`;
|
|
219
|
+
}
|
|
220
|
+
function goStartServerCommand(outDir) {
|
|
221
|
+
if (isOnWindows()) {
|
|
222
|
+
return `.\\${outDir}\\server.exe`;
|
|
223
|
+
}
|
|
224
|
+
return `./${outDir}/server`;
|
|
225
|
+
}
|
|
187
226
|
|
|
188
227
|
function tsServer(serverConfig) {
|
|
189
228
|
return defineServerConfig({
|
|
@@ -271,31 +310,37 @@ async function startBuild(generators, serverConfig, skipCodeGen = false) {
|
|
|
271
310
|
await setupWorkingDir(serverConfig);
|
|
272
311
|
await Promise.all([
|
|
273
312
|
createAppWithRoutesModule(serverConfig),
|
|
274
|
-
createServerEntryFile(serverConfig)
|
|
275
|
-
createCodegenEntryFile(serverConfig)
|
|
313
|
+
createServerEntryFile(serverConfig)
|
|
314
|
+
// createCodegenEntryFile(serverConfig),
|
|
276
315
|
]);
|
|
277
316
|
await bundleAppEntry(serverConfig);
|
|
278
317
|
logger.log("Finished bundling");
|
|
279
318
|
const clientCount = generators.length ?? 0;
|
|
280
|
-
const codegenModule = path.resolve(
|
|
281
|
-
serverConfig.rootDir,
|
|
282
|
-
".output",
|
|
283
|
-
OUT_CODEGEN
|
|
284
|
-
);
|
|
285
319
|
if (!skipCodeGen) {
|
|
286
320
|
logger.log("Generating Arri app definition (__definition.json)");
|
|
287
|
-
|
|
288
|
-
const defJson = path.resolve(
|
|
321
|
+
let appImportPath = path.resolve(
|
|
289
322
|
serverConfig.rootDir,
|
|
290
323
|
".output",
|
|
291
|
-
|
|
324
|
+
OUT_APP_FILE
|
|
292
325
|
);
|
|
293
|
-
|
|
294
|
-
|
|
326
|
+
if (isOnWindows()) {
|
|
327
|
+
appImportPath = createWindowsCompatibleImportPath(appImportPath);
|
|
328
|
+
}
|
|
329
|
+
const app = (await import(appImportPath)).default;
|
|
330
|
+
const appDef = app.getAppDefinition();
|
|
331
|
+
if (isAppDefinition(appDef) && clientCount > 0) {
|
|
332
|
+
fs.writeFile(
|
|
333
|
+
path.resolve(
|
|
334
|
+
serverConfig.rootDir,
|
|
335
|
+
".output",
|
|
336
|
+
"__definition.json"
|
|
337
|
+
),
|
|
338
|
+
JSON.stringify(appDef)
|
|
339
|
+
);
|
|
295
340
|
const startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
296
341
|
logger.log(`Generating ${clientCount} client(s)...`);
|
|
297
342
|
await Promise.all(
|
|
298
|
-
generators.map((generator) => generator.run(
|
|
343
|
+
generators.map((generator) => generator.run(appDef, false)) ?? []
|
|
299
344
|
);
|
|
300
345
|
logger.log(
|
|
301
346
|
`${clientCount} client(s) generated in ${(/* @__PURE__ */ new Date()).getTime() - startTime}ms`
|
|
@@ -308,11 +353,10 @@ async function startBuild(generators, serverConfig, skipCodeGen = false) {
|
|
|
308
353
|
} else {
|
|
309
354
|
logger.log("Skipping codegen");
|
|
310
355
|
}
|
|
311
|
-
logger.log("Cleaning up files");
|
|
312
|
-
await fs.rm(codegenModule);
|
|
313
356
|
logger.success(
|
|
314
357
|
`Build finished! You can start your server by running "node .output/${OUT_SERVER_ENTRY}"`
|
|
315
358
|
);
|
|
359
|
+
process.exit(0);
|
|
316
360
|
}
|
|
317
361
|
async function bundleAppEntry(config, _allowCodegen = true) {
|
|
318
362
|
const appEntry = path.resolve(
|
|
@@ -397,30 +441,6 @@ void listen(toNodeListener(app.h3App), {
|
|
|
397
441
|
virtualEntry
|
|
398
442
|
);
|
|
399
443
|
}
|
|
400
|
-
async function createCodegenEntryFile(config) {
|
|
401
|
-
const appModule = path.resolve(config.rootDir, config.srcDir, config.entry);
|
|
402
|
-
const appImportParts = path.relative(path.resolve(config.rootDir, config.srcDir), appModule).split(".");
|
|
403
|
-
appImportParts.pop();
|
|
404
|
-
const virtualModule = await prettier.format(
|
|
405
|
-
`
|
|
406
|
-
import { writeFileSync } from 'node:fs';
|
|
407
|
-
import path from 'node:path';
|
|
408
|
-
import app from './${OUT_APP_FILE}';
|
|
409
|
-
|
|
410
|
-
const __dirname = new URL(".", import.meta.url).pathname;
|
|
411
|
-
const def = app.getAppDefinition();
|
|
412
|
-
writeFileSync(
|
|
413
|
-
path.resolve(__dirname, "../.output", "__definition.json"),
|
|
414
|
-
JSON.stringify(def),
|
|
415
|
-
);
|
|
416
|
-
process.exit(0);`,
|
|
417
|
-
{ tabWidth: 4, parser: "typescript" }
|
|
418
|
-
);
|
|
419
|
-
await fs.writeFile(
|
|
420
|
-
path.resolve(config.rootDir, ".output", OUT_CODEGEN),
|
|
421
|
-
virtualModule
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
444
|
async function bundleFilesContext(config) {
|
|
425
445
|
return await esbuild.context({
|
|
426
446
|
...config.esbuild,
|
|
@@ -486,8 +506,8 @@ async function createDevServer(config) {
|
|
|
486
506
|
".output",
|
|
487
507
|
`${OUT_APP_FILE}?version=${Date.now()}`
|
|
488
508
|
);
|
|
489
|
-
if (
|
|
490
|
-
importPath =
|
|
509
|
+
if (isOnWindows()) {
|
|
510
|
+
importPath = createWindowsCompatibleImportPath(importPath);
|
|
491
511
|
}
|
|
492
512
|
const appEntry = (await import(importPath)).default;
|
|
493
513
|
dynamicHandler.set(fromNodeMiddleware(appEntry.h3App.handler));
|
|
@@ -503,24 +523,6 @@ async function createDevServer(config) {
|
|
|
503
523
|
ws
|
|
504
524
|
};
|
|
505
525
|
}
|
|
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
|
-
}
|
|
524
526
|
async function startDevServer(config, generators) {
|
|
525
527
|
await setupWorkingDir(config);
|
|
526
528
|
const watcher = await import('chokidar');
|
|
@@ -636,7 +638,6 @@ async function generateClientsFromDefinition(appDef, generators, isDev) {
|
|
|
636
638
|
const GEN_APP_FILE = "__arri_app.ts";
|
|
637
639
|
const OUT_APP_FILE = "app.mjs";
|
|
638
640
|
const OUT_SERVER_ENTRY = "server.mjs";
|
|
639
|
-
const OUT_CODEGEN = "codegen.mjs";
|
|
640
641
|
async function setupWorkingDir(config) {
|
|
641
642
|
const arriDir = path.resolve(config.rootDir, config.buildDir);
|
|
642
643
|
const outDir = path.resolve(config.rootDir, ".output");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arri",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -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-
|
|
43
|
-
"@arrirpc/codegen-
|
|
44
|
-
"@arrirpc/codegen-
|
|
45
|
-
"@arrirpc/codegen-swift": "0.80.
|
|
46
|
-
"@arrirpc/codegen-ts": "0.80.
|
|
47
|
-
"@arrirpc/codegen-utils": "0.80.
|
|
48
|
-
"@arrirpc/schema": "0.80.
|
|
42
|
+
"@arrirpc/codegen-kotlin": "0.80.3",
|
|
43
|
+
"@arrirpc/codegen-rust": "0.80.3",
|
|
44
|
+
"@arrirpc/codegen-dart": "0.80.3",
|
|
45
|
+
"@arrirpc/codegen-swift": "0.80.3",
|
|
46
|
+
"@arrirpc/codegen-ts": "0.80.3",
|
|
47
|
+
"@arrirpc/codegen-utils": "0.80.3",
|
|
48
|
+
"@arrirpc/schema": "0.80.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/degit": "^2.8.6"
|