arri 0.39.2 → 0.41.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 +84 -76
- package/dist/cli.mjs +84 -75
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +1 -1
- package/dist/shared/{arri.ebe44c73.cjs → arri.0628c07d.cjs} +4 -2
- package/dist/shared/{arri.1fc3f099.mjs → arri.c3a553fc.mjs} +4 -2
- package/package.json +10 -7
package/dist/cli.cjs
CHANGED
|
@@ -11,13 +11,12 @@ 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 config = require('./shared/arri.
|
|
14
|
+
const config = require('./shared/arri.0628c07d.cjs');
|
|
15
15
|
const consola = require('consola');
|
|
16
16
|
const globby = require('globby');
|
|
17
17
|
const scule = require('scule');
|
|
18
18
|
const ofetch = require('ofetch');
|
|
19
19
|
const listhen = require('@joshmossas/listhen');
|
|
20
|
-
const chokidar = require('chokidar');
|
|
21
20
|
const Degit = require('degit');
|
|
22
21
|
const enquirer = require('enquirer');
|
|
23
22
|
require('h3');
|
|
@@ -43,13 +42,12 @@ const fs__default = /*#__PURE__*/_interopDefaultCompat(fs$1);
|
|
|
43
42
|
const esbuild__namespace = /*#__PURE__*/_interopNamespaceCompat(esbuild);
|
|
44
43
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
45
44
|
const prettier__default = /*#__PURE__*/_interopDefaultCompat(prettier);
|
|
46
|
-
const chokidar__default = /*#__PURE__*/_interopDefaultCompat(chokidar);
|
|
47
45
|
const Degit__default = /*#__PURE__*/_interopDefaultCompat(Degit);
|
|
48
46
|
const enquirer__default = /*#__PURE__*/_interopDefaultCompat(enquirer);
|
|
49
47
|
|
|
50
48
|
const logger = consola.createConsola().withTag("arri");
|
|
51
|
-
const GEN_APP_FILE = "__arri_app.
|
|
52
|
-
const GEN_SERVER_ENTRY_FILE = "__arri_server.
|
|
49
|
+
const GEN_APP_FILE = "__arri_app.ts";
|
|
50
|
+
const GEN_SERVER_ENTRY_FILE = "__arri_server.ts";
|
|
53
51
|
const OUT_APP_FILE = "app.mjs";
|
|
54
52
|
const OUT_SERVER_ENTRY = "server.mjs";
|
|
55
53
|
const OUT_CODEGEN = "codegen.mjs";
|
|
@@ -67,7 +65,7 @@ async function setupWorkingDir(config) {
|
|
|
67
65
|
}
|
|
68
66
|
async function createAppWithRoutesModule(config) {
|
|
69
67
|
const appModule = path__default.resolve(config.rootDir, config.srcDir, config.entry);
|
|
70
|
-
const appImportParts = path__default.relative(path__default.resolve(config.rootDir, config.
|
|
68
|
+
const appImportParts = path__default.relative(path__default.resolve(config.rootDir, config.buildDir), appModule).split(".");
|
|
71
69
|
appImportParts.pop();
|
|
72
70
|
const routes = [];
|
|
73
71
|
const existingRoutes = [];
|
|
@@ -84,11 +82,13 @@ async function createAppWithRoutesModule(config) {
|
|
|
84
82
|
);
|
|
85
83
|
routes.sort((a, b) => a.name < b.name ? -1 : 1);
|
|
86
84
|
const module = await prettier__default.format(
|
|
87
|
-
`import
|
|
85
|
+
`import sourceMapSupport from 'source-map-support';
|
|
86
|
+
sourceMapSupport.install();
|
|
87
|
+
import app from '${appImportParts.join(".")}';
|
|
88
88
|
${routes.map(
|
|
89
89
|
(route) => `import ${route.importName} from '${route.importPath}';`
|
|
90
90
|
).join("\n")}
|
|
91
|
-
const routes = [${routes.map(
|
|
91
|
+
const routes: {id: string; route: any}[] = [${routes.map(
|
|
92
92
|
(route) => `{ id: '${route.name}', route: ${route.importName} }`
|
|
93
93
|
).join(",\n")}
|
|
94
94
|
];
|
|
@@ -98,11 +98,14 @@ async function createAppWithRoutesModule(config) {
|
|
|
98
98
|
name: route.id,
|
|
99
99
|
...route.route,
|
|
100
100
|
});
|
|
101
|
-
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (route.route.transport === 'ws') {
|
|
102
104
|
app.wsRpc({
|
|
103
105
|
name: route.id,
|
|
104
106
|
...route.route,
|
|
105
107
|
});
|
|
108
|
+
continue;
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
export default app`,
|
|
@@ -125,7 +128,7 @@ async function getFsRouteBatch(globPattern, config) {
|
|
|
125
128
|
for (const file of files) {
|
|
126
129
|
const meta = getRpcMetaFromPath(config, file);
|
|
127
130
|
if (meta) {
|
|
128
|
-
const importParts = path__default.relative(path__default.resolve(config.rootDir, config.
|
|
131
|
+
const importParts = path__default.relative(path__default.resolve(config.rootDir, config.buildDir), file).split(".");
|
|
129
132
|
importParts.pop();
|
|
130
133
|
importParts.push("js");
|
|
131
134
|
routes.push({
|
|
@@ -171,23 +174,11 @@ const getRpcMetaFromPath = (config, filePath) => {
|
|
|
171
174
|
httpPath: `/${httpParts.join("/")}`
|
|
172
175
|
};
|
|
173
176
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
await esbuild__namespace.build({
|
|
180
|
-
entryPoints: [
|
|
181
|
-
...files.map(
|
|
182
|
-
(file) => path__default.resolve(config.rootDir, config.srcDir, file)
|
|
183
|
-
)
|
|
184
|
-
],
|
|
185
|
-
outdir: outDir,
|
|
186
|
-
bundle: false,
|
|
187
|
-
format: "esm",
|
|
188
|
-
target: "node20",
|
|
189
|
-
platform: "node"
|
|
190
|
-
});
|
|
177
|
+
function isInsideDir(dir, parentDir) {
|
|
178
|
+
if (path__default.resolve(dir).startsWith(path__default.resolve(parentDir))) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
return false;
|
|
191
182
|
}
|
|
192
183
|
|
|
193
184
|
const build = citty.defineCommand({
|
|
@@ -211,6 +202,14 @@ const build = citty.defineCommand({
|
|
|
211
202
|
if (!config$1) {
|
|
212
203
|
throw new Error("Unable to find arri config");
|
|
213
204
|
}
|
|
205
|
+
const appEntry = path__default.resolve(
|
|
206
|
+
config$1.rootDir,
|
|
207
|
+
config$1.srcDir,
|
|
208
|
+
config$1.entry
|
|
209
|
+
);
|
|
210
|
+
if (!fs.existsSync(appEntry)) {
|
|
211
|
+
throw new Error(`Unable to find entry at ${appEntry}`);
|
|
212
|
+
}
|
|
214
213
|
await startBuild(config$1, args.skipCodegen);
|
|
215
214
|
}
|
|
216
215
|
});
|
|
@@ -225,8 +224,7 @@ async function startBuild(config, skipCodeGen = false) {
|
|
|
225
224
|
await Promise.all([
|
|
226
225
|
createAppWithRoutesModule(config),
|
|
227
226
|
createServerEntryFile(config),
|
|
228
|
-
createCodegenEntryFile(config)
|
|
229
|
-
transpileFiles(config)
|
|
227
|
+
createCodegenEntryFile(config)
|
|
230
228
|
]);
|
|
231
229
|
await bundleAppEntry(config);
|
|
232
230
|
logger.log("Finished bundling");
|
|
@@ -506,21 +504,21 @@ export default app.h3App;`;
|
|
|
506
504
|
format: "esm",
|
|
507
505
|
bundle: true,
|
|
508
506
|
sourcemap: true,
|
|
509
|
-
target: "
|
|
507
|
+
target: "node20",
|
|
510
508
|
platform: "node",
|
|
511
509
|
packages: "external"
|
|
512
510
|
});
|
|
513
511
|
}
|
|
514
512
|
async function startDevServer(config) {
|
|
515
513
|
await setupWorkingDir(config);
|
|
514
|
+
const watcher = await import('chokidar');
|
|
516
515
|
let fileWatcher;
|
|
517
516
|
await Promise.all([
|
|
518
517
|
createEntryModule(config),
|
|
519
|
-
createAppWithRoutesModule(config)
|
|
520
|
-
transpileFiles(config)
|
|
518
|
+
createAppWithRoutesModule(config)
|
|
521
519
|
]);
|
|
522
|
-
const
|
|
523
|
-
await
|
|
520
|
+
const context = await bundleFilesContext(config);
|
|
521
|
+
await context.rebuild();
|
|
524
522
|
const listener = await startListener(config, true);
|
|
525
523
|
setTimeout(async () => {
|
|
526
524
|
await generateClients(config);
|
|
@@ -532,58 +530,68 @@ async function startDevServer(config) {
|
|
|
532
530
|
await Promise.allSettled([
|
|
533
531
|
listener.close(),
|
|
534
532
|
fileWatcher?.close(),
|
|
535
|
-
|
|
533
|
+
context.dispose()
|
|
536
534
|
]);
|
|
537
535
|
});
|
|
538
536
|
process.on("SIGINT", cleanExit);
|
|
539
537
|
process.on("SIGTERM", cleanExit);
|
|
540
538
|
async function load(isRestart, reason) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
if (alias) {
|
|
539
|
+
if (fileWatcher) {
|
|
540
|
+
await fileWatcher.close();
|
|
541
|
+
}
|
|
542
|
+
const srcDir = path__default.resolve(config.rootDir ?? "", config.srcDir);
|
|
543
|
+
const dirsToWatch = [srcDir];
|
|
544
|
+
if (config.esbuild.alias) {
|
|
545
|
+
for (const key of Object.keys(config.esbuild.alias)) {
|
|
546
|
+
const alias = config.esbuild.alias[key];
|
|
547
|
+
if (alias) {
|
|
548
|
+
if (!isInsideDir(alias, srcDir)) {
|
|
551
549
|
dirsToWatch.push(alias);
|
|
552
550
|
}
|
|
553
551
|
}
|
|
554
552
|
}
|
|
555
|
-
const buildDir = path__default.resolve(config.rootDir, config.buildDir);
|
|
556
|
-
const outDir = path__default.resolve(config.rootDir, ".output");
|
|
557
|
-
fileWatcher = chokidar__default.watch(dirsToWatch, {
|
|
558
|
-
ignored: [buildDir, outDir],
|
|
559
|
-
ignoreInitial: true
|
|
560
|
-
});
|
|
561
|
-
fileWatcher.on("all", async (event, file) => {
|
|
562
|
-
if (event === "add" || event === "addDir") {
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
await createAppWithRoutesModule(config);
|
|
566
|
-
let bundleCreated = false;
|
|
567
|
-
try {
|
|
568
|
-
logger.log(
|
|
569
|
-
"Change detected. Bundling files and restarting server...."
|
|
570
|
-
);
|
|
571
|
-
await transpileFiles(config);
|
|
572
|
-
await bundleFiles.rebuild();
|
|
573
|
-
bundleCreated = true;
|
|
574
|
-
} catch (err) {
|
|
575
|
-
logger.error("ERROR", err);
|
|
576
|
-
bundleCreated = false;
|
|
577
|
-
}
|
|
578
|
-
if (bundleCreated && config.generators.length) {
|
|
579
|
-
setTimeout(async () => {
|
|
580
|
-
await generateClients(config);
|
|
581
|
-
bundleCreated = false;
|
|
582
|
-
}, 1e3);
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
} catch (err) {
|
|
586
553
|
}
|
|
554
|
+
if (config.devServer.additionalWatchDirs?.length) {
|
|
555
|
+
for (const dir of config.devServer.additionalWatchDirs) {
|
|
556
|
+
dirsToWatch.push(dir);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
const buildDir = path__default.resolve(config.rootDir, config.buildDir);
|
|
560
|
+
const outDir = path__default.resolve(config.rootDir, ".output");
|
|
561
|
+
fileWatcher = watcher.watch(dirsToWatch, {
|
|
562
|
+
ignoreInitial: true,
|
|
563
|
+
ignored: [
|
|
564
|
+
buildDir,
|
|
565
|
+
outDir,
|
|
566
|
+
"**/.output",
|
|
567
|
+
"**/dist/**",
|
|
568
|
+
"**/node_modules/**",
|
|
569
|
+
"**/.git/**"
|
|
570
|
+
]
|
|
571
|
+
});
|
|
572
|
+
fileWatcher.on("all", async (eventName, path2) => {
|
|
573
|
+
if (eventName === "addDir" || eventName === "add") {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
await createAppWithRoutesModule(config);
|
|
577
|
+
let bundleCreated = false;
|
|
578
|
+
try {
|
|
579
|
+
logger.log(
|
|
580
|
+
"Change detected. Bundling files and restarting server...."
|
|
581
|
+
);
|
|
582
|
+
await context.rebuild();
|
|
583
|
+
bundleCreated = true;
|
|
584
|
+
} catch (err) {
|
|
585
|
+
logger.error("ERROR", err);
|
|
586
|
+
bundleCreated = false;
|
|
587
|
+
}
|
|
588
|
+
if (bundleCreated && config.generators.length) {
|
|
589
|
+
setTimeout(async () => {
|
|
590
|
+
await generateClients(config);
|
|
591
|
+
bundleCreated = false;
|
|
592
|
+
}, 1e3);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
587
595
|
}
|
|
588
596
|
await load();
|
|
589
597
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -10,13 +10,12 @@ import { build as build$1 } from 'esbuild';
|
|
|
10
10
|
import { replace } from 'esbuild-plugin-replace';
|
|
11
11
|
import path from 'pathe';
|
|
12
12
|
import prettier from 'prettier';
|
|
13
|
-
import { q as defaultConfig, o as isArriConfig, p as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.
|
|
13
|
+
import { q as defaultConfig, o as isArriConfig, p as isResolvedArriConfig, a as DEV_DEFINITION_ENDPOINT } from './shared/arri.c3a553fc.mjs';
|
|
14
14
|
import { createConsola } from 'consola';
|
|
15
15
|
import { globby } from 'globby';
|
|
16
16
|
import { camelCase, kebabCase } from 'scule';
|
|
17
17
|
import { ofetch } from 'ofetch';
|
|
18
18
|
import { listenAndWatch } from '@joshmossas/listhen';
|
|
19
|
-
import chokidar from 'chokidar';
|
|
20
19
|
import Degit from 'degit';
|
|
21
20
|
import enquirer from 'enquirer';
|
|
22
21
|
import 'h3';
|
|
@@ -24,8 +23,8 @@ import 'arri-validate';
|
|
|
24
23
|
import 'h3-sse';
|
|
25
24
|
|
|
26
25
|
const logger = createConsola().withTag("arri");
|
|
27
|
-
const GEN_APP_FILE = "__arri_app.
|
|
28
|
-
const GEN_SERVER_ENTRY_FILE = "__arri_server.
|
|
26
|
+
const GEN_APP_FILE = "__arri_app.ts";
|
|
27
|
+
const GEN_SERVER_ENTRY_FILE = "__arri_server.ts";
|
|
29
28
|
const OUT_APP_FILE = "app.mjs";
|
|
30
29
|
const OUT_SERVER_ENTRY = "server.mjs";
|
|
31
30
|
const OUT_CODEGEN = "codegen.mjs";
|
|
@@ -43,7 +42,7 @@ async function setupWorkingDir(config) {
|
|
|
43
42
|
}
|
|
44
43
|
async function createAppWithRoutesModule(config) {
|
|
45
44
|
const appModule = path.resolve(config.rootDir, config.srcDir, config.entry);
|
|
46
|
-
const appImportParts = path.relative(path.resolve(config.rootDir, config.
|
|
45
|
+
const appImportParts = path.relative(path.resolve(config.rootDir, config.buildDir), appModule).split(".");
|
|
47
46
|
appImportParts.pop();
|
|
48
47
|
const routes = [];
|
|
49
48
|
const existingRoutes = [];
|
|
@@ -60,11 +59,13 @@ async function createAppWithRoutesModule(config) {
|
|
|
60
59
|
);
|
|
61
60
|
routes.sort((a, b) => a.name < b.name ? -1 : 1);
|
|
62
61
|
const module = await prettier.format(
|
|
63
|
-
`import
|
|
62
|
+
`import sourceMapSupport from 'source-map-support';
|
|
63
|
+
sourceMapSupport.install();
|
|
64
|
+
import app from '${appImportParts.join(".")}';
|
|
64
65
|
${routes.map(
|
|
65
66
|
(route) => `import ${route.importName} from '${route.importPath}';`
|
|
66
67
|
).join("\n")}
|
|
67
|
-
const routes = [${routes.map(
|
|
68
|
+
const routes: {id: string; route: any}[] = [${routes.map(
|
|
68
69
|
(route) => `{ id: '${route.name}', route: ${route.importName} }`
|
|
69
70
|
).join(",\n")}
|
|
70
71
|
];
|
|
@@ -74,11 +75,14 @@ async function createAppWithRoutesModule(config) {
|
|
|
74
75
|
name: route.id,
|
|
75
76
|
...route.route,
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (route.route.transport === 'ws') {
|
|
78
81
|
app.wsRpc({
|
|
79
82
|
name: route.id,
|
|
80
83
|
...route.route,
|
|
81
84
|
});
|
|
85
|
+
continue;
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
export default app`,
|
|
@@ -101,7 +105,7 @@ async function getFsRouteBatch(globPattern, config) {
|
|
|
101
105
|
for (const file of files) {
|
|
102
106
|
const meta = getRpcMetaFromPath(config, file);
|
|
103
107
|
if (meta) {
|
|
104
|
-
const importParts = path.relative(path.resolve(config.rootDir, config.
|
|
108
|
+
const importParts = path.relative(path.resolve(config.rootDir, config.buildDir), file).split(".");
|
|
105
109
|
importParts.pop();
|
|
106
110
|
importParts.push("js");
|
|
107
111
|
routes.push({
|
|
@@ -147,23 +151,11 @@ const getRpcMetaFromPath = (config, filePath) => {
|
|
|
147
151
|
httpPath: `/${httpParts.join("/")}`
|
|
148
152
|
};
|
|
149
153
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
await esbuild.build({
|
|
156
|
-
entryPoints: [
|
|
157
|
-
...files.map(
|
|
158
|
-
(file) => path.resolve(config.rootDir, config.srcDir, file)
|
|
159
|
-
)
|
|
160
|
-
],
|
|
161
|
-
outdir: outDir,
|
|
162
|
-
bundle: false,
|
|
163
|
-
format: "esm",
|
|
164
|
-
target: "node20",
|
|
165
|
-
platform: "node"
|
|
166
|
-
});
|
|
154
|
+
function isInsideDir(dir, parentDir) {
|
|
155
|
+
if (path.resolve(dir).startsWith(path.resolve(parentDir))) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
167
159
|
}
|
|
168
160
|
|
|
169
161
|
const build = defineCommand({
|
|
@@ -187,6 +179,14 @@ const build = defineCommand({
|
|
|
187
179
|
if (!config) {
|
|
188
180
|
throw new Error("Unable to find arri config");
|
|
189
181
|
}
|
|
182
|
+
const appEntry = path.resolve(
|
|
183
|
+
config.rootDir,
|
|
184
|
+
config.srcDir,
|
|
185
|
+
config.entry
|
|
186
|
+
);
|
|
187
|
+
if (!existsSync(appEntry)) {
|
|
188
|
+
throw new Error(`Unable to find entry at ${appEntry}`);
|
|
189
|
+
}
|
|
190
190
|
await startBuild(config, args.skipCodegen);
|
|
191
191
|
}
|
|
192
192
|
});
|
|
@@ -201,8 +201,7 @@ async function startBuild(config, skipCodeGen = false) {
|
|
|
201
201
|
await Promise.all([
|
|
202
202
|
createAppWithRoutesModule(config),
|
|
203
203
|
createServerEntryFile(config),
|
|
204
|
-
createCodegenEntryFile(config)
|
|
205
|
-
transpileFiles(config)
|
|
204
|
+
createCodegenEntryFile(config)
|
|
206
205
|
]);
|
|
207
206
|
await bundleAppEntry(config);
|
|
208
207
|
logger.log("Finished bundling");
|
|
@@ -482,21 +481,21 @@ export default app.h3App;`;
|
|
|
482
481
|
format: "esm",
|
|
483
482
|
bundle: true,
|
|
484
483
|
sourcemap: true,
|
|
485
|
-
target: "
|
|
484
|
+
target: "node20",
|
|
486
485
|
platform: "node",
|
|
487
486
|
packages: "external"
|
|
488
487
|
});
|
|
489
488
|
}
|
|
490
489
|
async function startDevServer(config) {
|
|
491
490
|
await setupWorkingDir(config);
|
|
491
|
+
const watcher = await import('chokidar');
|
|
492
492
|
let fileWatcher;
|
|
493
493
|
await Promise.all([
|
|
494
494
|
createEntryModule(config),
|
|
495
|
-
createAppWithRoutesModule(config)
|
|
496
|
-
transpileFiles(config)
|
|
495
|
+
createAppWithRoutesModule(config)
|
|
497
496
|
]);
|
|
498
|
-
const
|
|
499
|
-
await
|
|
497
|
+
const context = await bundleFilesContext(config);
|
|
498
|
+
await context.rebuild();
|
|
500
499
|
const listener = await startListener(config, true);
|
|
501
500
|
setTimeout(async () => {
|
|
502
501
|
await generateClients(config);
|
|
@@ -508,58 +507,68 @@ async function startDevServer(config) {
|
|
|
508
507
|
await Promise.allSettled([
|
|
509
508
|
listener.close(),
|
|
510
509
|
fileWatcher?.close(),
|
|
511
|
-
|
|
510
|
+
context.dispose()
|
|
512
511
|
]);
|
|
513
512
|
});
|
|
514
513
|
process.on("SIGINT", cleanExit);
|
|
515
514
|
process.on("SIGTERM", cleanExit);
|
|
516
515
|
async function load(isRestart, reason) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if (alias) {
|
|
516
|
+
if (fileWatcher) {
|
|
517
|
+
await fileWatcher.close();
|
|
518
|
+
}
|
|
519
|
+
const srcDir = path.resolve(config.rootDir ?? "", config.srcDir);
|
|
520
|
+
const dirsToWatch = [srcDir];
|
|
521
|
+
if (config.esbuild.alias) {
|
|
522
|
+
for (const key of Object.keys(config.esbuild.alias)) {
|
|
523
|
+
const alias = config.esbuild.alias[key];
|
|
524
|
+
if (alias) {
|
|
525
|
+
if (!isInsideDir(alias, srcDir)) {
|
|
527
526
|
dirsToWatch.push(alias);
|
|
528
527
|
}
|
|
529
528
|
}
|
|
530
529
|
}
|
|
531
|
-
const buildDir = path.resolve(config.rootDir, config.buildDir);
|
|
532
|
-
const outDir = path.resolve(config.rootDir, ".output");
|
|
533
|
-
fileWatcher = chokidar.watch(dirsToWatch, {
|
|
534
|
-
ignored: [buildDir, outDir],
|
|
535
|
-
ignoreInitial: true
|
|
536
|
-
});
|
|
537
|
-
fileWatcher.on("all", async (event, file) => {
|
|
538
|
-
if (event === "add" || event === "addDir") {
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
await createAppWithRoutesModule(config);
|
|
542
|
-
let bundleCreated = false;
|
|
543
|
-
try {
|
|
544
|
-
logger.log(
|
|
545
|
-
"Change detected. Bundling files and restarting server...."
|
|
546
|
-
);
|
|
547
|
-
await transpileFiles(config);
|
|
548
|
-
await bundleFiles.rebuild();
|
|
549
|
-
bundleCreated = true;
|
|
550
|
-
} catch (err) {
|
|
551
|
-
logger.error("ERROR", err);
|
|
552
|
-
bundleCreated = false;
|
|
553
|
-
}
|
|
554
|
-
if (bundleCreated && config.generators.length) {
|
|
555
|
-
setTimeout(async () => {
|
|
556
|
-
await generateClients(config);
|
|
557
|
-
bundleCreated = false;
|
|
558
|
-
}, 1e3);
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
} catch (err) {
|
|
562
530
|
}
|
|
531
|
+
if (config.devServer.additionalWatchDirs?.length) {
|
|
532
|
+
for (const dir of config.devServer.additionalWatchDirs) {
|
|
533
|
+
dirsToWatch.push(dir);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
const buildDir = path.resolve(config.rootDir, config.buildDir);
|
|
537
|
+
const outDir = path.resolve(config.rootDir, ".output");
|
|
538
|
+
fileWatcher = watcher.watch(dirsToWatch, {
|
|
539
|
+
ignoreInitial: true,
|
|
540
|
+
ignored: [
|
|
541
|
+
buildDir,
|
|
542
|
+
outDir,
|
|
543
|
+
"**/.output",
|
|
544
|
+
"**/dist/**",
|
|
545
|
+
"**/node_modules/**",
|
|
546
|
+
"**/.git/**"
|
|
547
|
+
]
|
|
548
|
+
});
|
|
549
|
+
fileWatcher.on("all", async (eventName, path2) => {
|
|
550
|
+
if (eventName === "addDir" || eventName === "add") {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
await createAppWithRoutesModule(config);
|
|
554
|
+
let bundleCreated = false;
|
|
555
|
+
try {
|
|
556
|
+
logger.log(
|
|
557
|
+
"Change detected. Bundling files and restarting server...."
|
|
558
|
+
);
|
|
559
|
+
await context.rebuild();
|
|
560
|
+
bundleCreated = true;
|
|
561
|
+
} catch (err) {
|
|
562
|
+
logger.error("ERROR", err);
|
|
563
|
+
bundleCreated = false;
|
|
564
|
+
}
|
|
565
|
+
if (bundleCreated && config.generators.length) {
|
|
566
|
+
setTimeout(async () => {
|
|
567
|
+
await generateClients(config);
|
|
568
|
+
bundleCreated = false;
|
|
569
|
+
}, 1e3);
|
|
570
|
+
}
|
|
571
|
+
});
|
|
563
572
|
}
|
|
564
573
|
await load();
|
|
565
574
|
}
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -296,6 +296,12 @@ interface ArriConfig {
|
|
|
296
296
|
passphrase?: string;
|
|
297
297
|
} | boolean;
|
|
298
298
|
http2?: boolean;
|
|
299
|
+
devServer?: {
|
|
300
|
+
/**
|
|
301
|
+
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
302
|
+
*/
|
|
303
|
+
additionalWatchDirs?: string[];
|
|
304
|
+
};
|
|
299
305
|
}
|
|
300
306
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
|
301
307
|
declare function isResolvedArriConfig(input: unknown): input is ResolvedArriConfig;
|
package/dist/index.d.mts
CHANGED
|
@@ -296,6 +296,12 @@ interface ArriConfig {
|
|
|
296
296
|
passphrase?: string;
|
|
297
297
|
} | boolean;
|
|
298
298
|
http2?: boolean;
|
|
299
|
+
devServer?: {
|
|
300
|
+
/**
|
|
301
|
+
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
302
|
+
*/
|
|
303
|
+
additionalWatchDirs?: string[];
|
|
304
|
+
};
|
|
299
305
|
}
|
|
300
306
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
|
301
307
|
declare function isResolvedArriConfig(input: unknown): input is ResolvedArriConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -296,6 +296,12 @@ interface ArriConfig {
|
|
|
296
296
|
passphrase?: string;
|
|
297
297
|
} | boolean;
|
|
298
298
|
http2?: boolean;
|
|
299
|
+
devServer?: {
|
|
300
|
+
/**
|
|
301
|
+
* Use this to add directories outside of the srcDir that should trigger a dev server reload
|
|
302
|
+
*/
|
|
303
|
+
additionalWatchDirs?: string[];
|
|
304
|
+
};
|
|
299
305
|
}
|
|
300
306
|
declare function isArriConfig(input: unknown): input is ArriConfig;
|
|
301
307
|
declare function isResolvedArriConfig(input: unknown): input is ResolvedArriConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ArriApp, t as ArriRouter, j as ArriServerError, k as ArriServerErrorResponse, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as EventStreamConnection, W as WsPeer, c as createAppDefinition, e as createHttpRpcDefinition, G as createWsRpcDefinition, q as defaultConfig, s as defineConfig, l as defineError, y as defineEventStreamRpc, u as defineRoute, d as defineRpc, C as defineWebsocketRpc, m as errorResponseFromValidationErrors, f as getRpcParamName, g as getRpcPath, h as getRpcResponseName, n as handleH3Error, x as handleRoute, o as isArriConfig, z as isEventStreamRpc, p as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, B as registerEventStreamRpc, w as registerRoute, r as registerRpc, F as registerWebsocketRpc, v as validateRpcRequestInput } from './shared/arri.
|
|
1
|
+
export { A as ArriApp, t as ArriRouter, j as ArriServerError, k as ArriServerErrorResponse, a as DEV_DEFINITION_ENDPOINT, D as DEV_ENDPOINT_ROOT, E as EventStreamConnection, W as WsPeer, c as createAppDefinition, e as createHttpRpcDefinition, G as createWsRpcDefinition, q as defaultConfig, s as defineConfig, l as defineError, y as defineEventStreamRpc, u as defineRoute, d as defineRpc, C as defineWebsocketRpc, m as errorResponseFromValidationErrors, f as getRpcParamName, g as getRpcPath, h as getRpcResponseName, n as handleH3Error, x as handleRoute, o as isArriConfig, z as isEventStreamRpc, p as isResolvedArriConfig, b as isRpc, i as isRpcParamSchema, B as registerEventStreamRpc, w as registerRoute, r as registerRpc, F as registerWebsocketRpc, v as validateRpcRequestInput } from './shared/arri.c3a553fc.mjs';
|
|
2
2
|
export * from 'h3';
|
|
3
3
|
import 'arri-codegen-utils';
|
|
4
4
|
import 'arri-validate';
|
|
@@ -1228,7 +1228,8 @@ const defaultConfig = {
|
|
|
1228
1228
|
buildDir: ".arri",
|
|
1229
1229
|
esbuild: {},
|
|
1230
1230
|
https: false,
|
|
1231
|
-
http2: false
|
|
1231
|
+
http2: false,
|
|
1232
|
+
devServer: {}
|
|
1232
1233
|
};
|
|
1233
1234
|
function defineConfig(config) {
|
|
1234
1235
|
return {
|
|
@@ -1243,7 +1244,8 @@ function defineConfig(config) {
|
|
|
1243
1244
|
esbuild: config.esbuild ?? defaultConfig.esbuild,
|
|
1244
1245
|
serverEntry: config.serverEntry ?? "",
|
|
1245
1246
|
https: config.https ?? false,
|
|
1246
|
-
http2: config.http2 ?? false
|
|
1247
|
+
http2: config.http2 ?? false,
|
|
1248
|
+
devServer: config.devServer ?? {}
|
|
1247
1249
|
};
|
|
1248
1250
|
}
|
|
1249
1251
|
|
|
@@ -1226,7 +1226,8 @@ const defaultConfig = {
|
|
|
1226
1226
|
buildDir: ".arri",
|
|
1227
1227
|
esbuild: {},
|
|
1228
1228
|
https: false,
|
|
1229
|
-
http2: false
|
|
1229
|
+
http2: false,
|
|
1230
|
+
devServer: {}
|
|
1230
1231
|
};
|
|
1231
1232
|
function defineConfig(config) {
|
|
1232
1233
|
return {
|
|
@@ -1241,7 +1242,8 @@ function defineConfig(config) {
|
|
|
1241
1242
|
esbuild: config.esbuild ?? defaultConfig.esbuild,
|
|
1242
1243
|
serverEntry: config.serverEntry ?? "",
|
|
1243
1244
|
https: config.https ?? false,
|
|
1244
|
-
http2: config.http2 ?? false
|
|
1245
|
+
http2: config.http2 ?? false,
|
|
1246
|
+
devServer: config.devServer ?? {}
|
|
1245
1247
|
};
|
|
1246
1248
|
}
|
|
1247
1249
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arri",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"arri": "./dist/cli.mjs"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@joshmossas/listhen": "1.
|
|
28
|
+
"@joshmossas/listhen": "1.10.1",
|
|
29
|
+
"@parcel/watcher": "^2.4.1",
|
|
30
|
+
"@types/source-map-support": "^0.5.10",
|
|
29
31
|
"c12": "^1.10.0",
|
|
30
32
|
"chokidar": "^3.6.0",
|
|
31
33
|
"citty": "^0.1.6",
|
|
@@ -43,14 +45,15 @@
|
|
|
43
45
|
"pathe": "^1.1.2",
|
|
44
46
|
"prettier": "^3.2.5",
|
|
45
47
|
"scule": "^1.3.0",
|
|
48
|
+
"source-map-support": "^0.5.21",
|
|
46
49
|
"uncrypto": "^0.1.3",
|
|
47
|
-
"arri-codegen-ts": "0.
|
|
48
|
-
"arri-codegen-
|
|
49
|
-
"arri-codegen-
|
|
50
|
-
"arri-validate": "0.
|
|
50
|
+
"arri-codegen-ts": "0.41.0",
|
|
51
|
+
"arri-codegen-dart": "0.41.0",
|
|
52
|
+
"arri-codegen-utils": "0.41.0",
|
|
53
|
+
"arri-validate": "0.41.0"
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
53
56
|
"@types/degit": "^2.8.6",
|
|
54
|
-
"bun-types": "^1.1.
|
|
57
|
+
"bun-types": "^1.1.4"
|
|
55
58
|
}
|
|
56
59
|
}
|