arri 0.48.2 → 0.49.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/dist/cli.cjs
CHANGED
|
@@ -11,15 +11,18 @@ 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.8421be96.cjs');
|
|
15
15
|
const ofetch = require('ofetch');
|
|
16
16
|
const Degit = require('degit');
|
|
17
17
|
const enquirer = require('enquirer');
|
|
18
|
-
const
|
|
18
|
+
const schema = require('@arrirpc/schema');
|
|
19
|
+
const consola = require('consola');
|
|
20
|
+
const promises = require('fs/promises');
|
|
21
|
+
const node_url = require('node:url');
|
|
19
22
|
require('@joshmossas/listhen');
|
|
20
23
|
require('h3');
|
|
21
|
-
require('consola');
|
|
22
24
|
|
|
25
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
23
26
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
24
27
|
|
|
25
28
|
const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
@@ -28,6 +31,7 @@ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
|
28
31
|
const prettier__default = /*#__PURE__*/_interopDefaultCompat(prettier);
|
|
29
32
|
const Degit__default = /*#__PURE__*/_interopDefaultCompat(Degit);
|
|
30
33
|
const enquirer__default = /*#__PURE__*/_interopDefaultCompat(enquirer);
|
|
34
|
+
const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
|
|
31
35
|
|
|
32
36
|
const build = citty.defineCommand({
|
|
33
37
|
args: {
|
|
@@ -398,7 +402,7 @@ async function initApp(dir, force) {
|
|
|
398
402
|
encoding: "utf-8"
|
|
399
403
|
})
|
|
400
404
|
);
|
|
401
|
-
packageJson.name =
|
|
405
|
+
packageJson.name = codegenUtils.kebabCase(dir);
|
|
402
406
|
packageJson.description = "An RPC server created with Arri RPC";
|
|
403
407
|
packageJson.private = true;
|
|
404
408
|
delete packageJson.license;
|
|
@@ -423,7 +427,7 @@ async function initApp(dir, force) {
|
|
|
423
427
|
- pnpm run dev`);
|
|
424
428
|
}
|
|
425
429
|
async function initPlugin(dir, force) {
|
|
426
|
-
const name =
|
|
430
|
+
const name = codegenUtils.kebabCase(dir);
|
|
427
431
|
const degit = Degit__default("modiimedia/arri-starters/generator-starter", {
|
|
428
432
|
force
|
|
429
433
|
});
|
|
@@ -451,12 +455,244 @@ async function initPlugin(dir, force) {
|
|
|
451
455
|
- pnpm install`);
|
|
452
456
|
}
|
|
453
457
|
|
|
458
|
+
const list = citty.defineCommand({
|
|
459
|
+
meta: {
|
|
460
|
+
name: "List",
|
|
461
|
+
description: "List the available arri versions"
|
|
462
|
+
},
|
|
463
|
+
args: {
|
|
464
|
+
tags: {
|
|
465
|
+
type: "boolean",
|
|
466
|
+
default: false,
|
|
467
|
+
description: "List available tags"
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
async run({ args }) {
|
|
471
|
+
const arriInfo = await dev.getArriPackageMetadata();
|
|
472
|
+
if (args.tags) {
|
|
473
|
+
const output2 = Object.keys(arriInfo["dist-tags"]).map(
|
|
474
|
+
(tag) => `- ${tag} (${arriInfo["dist-tags"][tag]})`
|
|
475
|
+
);
|
|
476
|
+
dev.logger.log(output2.join("\n"));
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
const tagMap = {};
|
|
480
|
+
for (const key of Object.keys(arriInfo["dist-tags"])) {
|
|
481
|
+
const version = arriInfo["dist-tags"][key];
|
|
482
|
+
tagMap[version] = key;
|
|
483
|
+
}
|
|
484
|
+
const output = Object.keys(arriInfo.versions).map((version) => {
|
|
485
|
+
const tag = tagMap[version];
|
|
486
|
+
if (tag) {
|
|
487
|
+
return `- ${version} (${tag})`;
|
|
488
|
+
}
|
|
489
|
+
return `- ${version}`;
|
|
490
|
+
});
|
|
491
|
+
dev.logger.log(output.join("\n"));
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
const use = citty.defineCommand({
|
|
496
|
+
meta: {
|
|
497
|
+
name: "use",
|
|
498
|
+
description: "Use a specific arri version"
|
|
499
|
+
},
|
|
500
|
+
args: {
|
|
501
|
+
version: {
|
|
502
|
+
type: "positional",
|
|
503
|
+
required: true,
|
|
504
|
+
description: 'The version you want to use. You can also specify a tag such as "latest".'
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
async run({ args }) {
|
|
508
|
+
const arriInfo = await dev.getArriPackageMetadata();
|
|
509
|
+
const version = arriInfo["dist-tags"][args.version] ?? args.version;
|
|
510
|
+
if (!arriInfo.versions[version]) {
|
|
511
|
+
throw new Error(
|
|
512
|
+
`Version ${args.version} doesn't exist. Run "arri list" to see available versions.`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
const globby = (await import('globby')).globby;
|
|
516
|
+
consola__default.info(`Checking for TS/JS dependencies`);
|
|
517
|
+
const fileMap = {};
|
|
518
|
+
const pkgJsonFiles = await globby(
|
|
519
|
+
[
|
|
520
|
+
"package.json",
|
|
521
|
+
"**/package.json",
|
|
522
|
+
"package.jsonc",
|
|
523
|
+
"**/package.jsonc"
|
|
524
|
+
],
|
|
525
|
+
{
|
|
526
|
+
ignore: ["node_modules", "**/node_modules", "**/dist", "dist"]
|
|
527
|
+
}
|
|
528
|
+
);
|
|
529
|
+
const jkgJsonFileTasks = [];
|
|
530
|
+
for (const file of pkgJsonFiles) {
|
|
531
|
+
jkgJsonFileTasks.push(
|
|
532
|
+
promises.readFile(path__default.resolve(file), "utf8").then((content) => {
|
|
533
|
+
const result = updatePackageJson(content, version);
|
|
534
|
+
if (result.updated) {
|
|
535
|
+
fileMap[file] = result.content;
|
|
536
|
+
}
|
|
537
|
+
})
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
await Promise.all(jkgJsonFileTasks);
|
|
541
|
+
consola__default.info(`Checking for dart dependencies`);
|
|
542
|
+
const pubspecFiles = await globby(["pubspec.yaml", "**/pubspec.yaml"]);
|
|
543
|
+
const pubspecFileTasks = [];
|
|
544
|
+
if (pubspecFiles.length) {
|
|
545
|
+
const dartPackage = await getDartPackageMeta();
|
|
546
|
+
let hasVersion = false;
|
|
547
|
+
for (const item of dartPackage.versions) {
|
|
548
|
+
if (item.version == version) {
|
|
549
|
+
hasVersion = true;
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (!hasVersion) {
|
|
554
|
+
throw new Error(
|
|
555
|
+
`Version ${version} does not have Dart support`
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
for (const file of pubspecFiles) {
|
|
560
|
+
pubspecFileTasks.push(
|
|
561
|
+
promises.readFile(path__default.resolve(file), "utf8").then((content) => {
|
|
562
|
+
const result = updatePubspecYaml(content, version);
|
|
563
|
+
if (result.updated) {
|
|
564
|
+
fileMap[file] = result.content;
|
|
565
|
+
}
|
|
566
|
+
})
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
await Promise.all(pubspecFileTasks);
|
|
570
|
+
const updateTasks = [];
|
|
571
|
+
for (const key of Object.keys(fileMap)) {
|
|
572
|
+
updateTasks.push(
|
|
573
|
+
promises.writeFile(path__default.resolve(key), fileMap[key], "utf8").then(
|
|
574
|
+
() => consola__default.success(`Updated ${key}`)
|
|
575
|
+
)
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
await Promise.all(updateTasks);
|
|
579
|
+
consola__default.success(
|
|
580
|
+
`Updated to ${version}. Rerun your install commands to update your dependencies.`
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
function updatePackageJson(fileContent, targetVersion) {
|
|
585
|
+
const lines = fileContent.split("\n");
|
|
586
|
+
const output = [];
|
|
587
|
+
let updated = false;
|
|
588
|
+
for (const line of lines) {
|
|
589
|
+
if (line.includes(`"arri"`)) {
|
|
590
|
+
output.push(updateLine(line));
|
|
591
|
+
updated = true;
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
if (line.includes(`"@arrirpc/`)) {
|
|
595
|
+
output.push(updateLine(line));
|
|
596
|
+
updated = true;
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
output.push(line);
|
|
600
|
+
}
|
|
601
|
+
function updateLine(line) {
|
|
602
|
+
const parts = line.split('":');
|
|
603
|
+
if (parts.length < 2) {
|
|
604
|
+
return line;
|
|
605
|
+
}
|
|
606
|
+
const targetParts = parts[1].split('"');
|
|
607
|
+
targetParts[1] = `^${targetVersion}`;
|
|
608
|
+
parts[1] = targetParts.join('"');
|
|
609
|
+
return parts.join('":');
|
|
610
|
+
}
|
|
611
|
+
return {
|
|
612
|
+
updated,
|
|
613
|
+
content: output.join("\n")
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
const PubPackageResponse = schema.a.object({
|
|
617
|
+
name: schema.a.string(),
|
|
618
|
+
versions: schema.a.array(
|
|
619
|
+
schema.a.object({
|
|
620
|
+
version: schema.a.string(),
|
|
621
|
+
pubspec: schema.a.object({
|
|
622
|
+
name: schema.a.string(),
|
|
623
|
+
description: schema.a.string(),
|
|
624
|
+
version: schema.a.string(),
|
|
625
|
+
repository: schema.a.string(),
|
|
626
|
+
environment: schema.a.object({
|
|
627
|
+
sdk: schema.a.string()
|
|
628
|
+
}),
|
|
629
|
+
dependencies: schema.a.record(schema.a.string()),
|
|
630
|
+
dev_dependencies: schema.a.record(schema.a.string())
|
|
631
|
+
}),
|
|
632
|
+
archive_url: schema.a.string(),
|
|
633
|
+
archive_sha256: schema.a.string(),
|
|
634
|
+
published: schema.a.string()
|
|
635
|
+
})
|
|
636
|
+
)
|
|
637
|
+
});
|
|
638
|
+
async function getDartPackageMeta() {
|
|
639
|
+
const response = await ofetch.ofetch("https://pub.dev/api/packages/arri_client");
|
|
640
|
+
const data = schema.a.parse(PubPackageResponse, response);
|
|
641
|
+
return data;
|
|
642
|
+
}
|
|
643
|
+
function updatePubspecYaml(fileContent, version) {
|
|
644
|
+
const lines = fileContent.split("\n");
|
|
645
|
+
const output = [];
|
|
646
|
+
let updated = false;
|
|
647
|
+
for (const line of lines) {
|
|
648
|
+
if (line.includes("arri_client: ")) {
|
|
649
|
+
const parts = line.split(": ");
|
|
650
|
+
if (parts.length < 2) {
|
|
651
|
+
output.push(line);
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
const targetPart = parts[1];
|
|
655
|
+
const subParts = targetPart.split(" ");
|
|
656
|
+
subParts[0] = `^${version}`;
|
|
657
|
+
parts[1] = subParts.join(" ");
|
|
658
|
+
output.push(parts.join(": "));
|
|
659
|
+
updated = true;
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
output.push(line);
|
|
663
|
+
}
|
|
664
|
+
return {
|
|
665
|
+
updated,
|
|
666
|
+
content: output.join("\n")
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
|
671
|
+
const __dirname$1 = path__default.dirname(__filename$1);
|
|
672
|
+
const version = citty.defineCommand({
|
|
673
|
+
meta: {
|
|
674
|
+
name: "Version",
|
|
675
|
+
description: "Get the current Arri CLI version"
|
|
676
|
+
},
|
|
677
|
+
run() {
|
|
678
|
+
const packageJson = JSON.parse(
|
|
679
|
+
fs.readFileSync(path__default.resolve(__dirname$1, "../package.json"), {
|
|
680
|
+
encoding: "utf8"
|
|
681
|
+
})
|
|
682
|
+
);
|
|
683
|
+
console.info(`${packageJson.version}`);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
|
|
454
687
|
const main = citty.defineCommand({
|
|
455
688
|
subCommands: {
|
|
456
689
|
build,
|
|
457
|
-
dev: dev.dev,
|
|
458
690
|
codegen,
|
|
459
|
-
|
|
691
|
+
dev: dev.dev,
|
|
692
|
+
init,
|
|
693
|
+
list,
|
|
694
|
+
use,
|
|
695
|
+
version
|
|
460
696
|
}
|
|
461
697
|
});
|
|
462
698
|
void citty.runMain(main);
|
package/dist/cli.mjs
CHANGED
|
@@ -3,20 +3,22 @@ import { defineCommand, runMain } from 'citty';
|
|
|
3
3
|
import { execSync } from 'node:child_process';
|
|
4
4
|
import fs$1, { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import fs from 'node:fs/promises';
|
|
6
|
-
import { isAppDefinition } from '@arrirpc/codegen-utils';
|
|
6
|
+
import { isAppDefinition, kebabCase } from '@arrirpc/codegen-utils';
|
|
7
7
|
import { loadConfig } from 'c12';
|
|
8
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 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.1c716de9.mjs';
|
|
13
13
|
import { ofetch } from 'ofetch';
|
|
14
14
|
import Degit from 'degit';
|
|
15
15
|
import enquirer from 'enquirer';
|
|
16
|
-
import {
|
|
16
|
+
import { a } from '@arrirpc/schema';
|
|
17
|
+
import consola from 'consola';
|
|
18
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
19
|
+
import { fileURLToPath } from 'node:url';
|
|
17
20
|
import '@joshmossas/listhen';
|
|
18
21
|
import 'h3';
|
|
19
|
-
import 'consola';
|
|
20
22
|
|
|
21
23
|
const build = defineCommand({
|
|
22
24
|
args: {
|
|
@@ -440,12 +442,244 @@ async function initPlugin(dir, force) {
|
|
|
440
442
|
- pnpm install`);
|
|
441
443
|
}
|
|
442
444
|
|
|
445
|
+
const list = defineCommand({
|
|
446
|
+
meta: {
|
|
447
|
+
name: "List",
|
|
448
|
+
description: "List the available arri versions"
|
|
449
|
+
},
|
|
450
|
+
args: {
|
|
451
|
+
tags: {
|
|
452
|
+
type: "boolean",
|
|
453
|
+
default: false,
|
|
454
|
+
description: "List available tags"
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
async run({ args }) {
|
|
458
|
+
const arriInfo = await getArriPackageMetadata();
|
|
459
|
+
if (args.tags) {
|
|
460
|
+
const output2 = Object.keys(arriInfo["dist-tags"]).map(
|
|
461
|
+
(tag) => `- ${tag} (${arriInfo["dist-tags"][tag]})`
|
|
462
|
+
);
|
|
463
|
+
logger.log(output2.join("\n"));
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const tagMap = {};
|
|
467
|
+
for (const key of Object.keys(arriInfo["dist-tags"])) {
|
|
468
|
+
const version = arriInfo["dist-tags"][key];
|
|
469
|
+
tagMap[version] = key;
|
|
470
|
+
}
|
|
471
|
+
const output = Object.keys(arriInfo.versions).map((version) => {
|
|
472
|
+
const tag = tagMap[version];
|
|
473
|
+
if (tag) {
|
|
474
|
+
return `- ${version} (${tag})`;
|
|
475
|
+
}
|
|
476
|
+
return `- ${version}`;
|
|
477
|
+
});
|
|
478
|
+
logger.log(output.join("\n"));
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
const use = defineCommand({
|
|
483
|
+
meta: {
|
|
484
|
+
name: "use",
|
|
485
|
+
description: "Use a specific arri version"
|
|
486
|
+
},
|
|
487
|
+
args: {
|
|
488
|
+
version: {
|
|
489
|
+
type: "positional",
|
|
490
|
+
required: true,
|
|
491
|
+
description: 'The version you want to use. You can also specify a tag such as "latest".'
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
async run({ args }) {
|
|
495
|
+
const arriInfo = await getArriPackageMetadata();
|
|
496
|
+
const version = arriInfo["dist-tags"][args.version] ?? args.version;
|
|
497
|
+
if (!arriInfo.versions[version]) {
|
|
498
|
+
throw new Error(
|
|
499
|
+
`Version ${args.version} doesn't exist. Run "arri list" to see available versions.`
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
const globby = (await import('globby')).globby;
|
|
503
|
+
consola.info(`Checking for TS/JS dependencies`);
|
|
504
|
+
const fileMap = {};
|
|
505
|
+
const pkgJsonFiles = await globby(
|
|
506
|
+
[
|
|
507
|
+
"package.json",
|
|
508
|
+
"**/package.json",
|
|
509
|
+
"package.jsonc",
|
|
510
|
+
"**/package.jsonc"
|
|
511
|
+
],
|
|
512
|
+
{
|
|
513
|
+
ignore: ["node_modules", "**/node_modules", "**/dist", "dist"]
|
|
514
|
+
}
|
|
515
|
+
);
|
|
516
|
+
const jkgJsonFileTasks = [];
|
|
517
|
+
for (const file of pkgJsonFiles) {
|
|
518
|
+
jkgJsonFileTasks.push(
|
|
519
|
+
readFile(path.resolve(file), "utf8").then((content) => {
|
|
520
|
+
const result = updatePackageJson(content, version);
|
|
521
|
+
if (result.updated) {
|
|
522
|
+
fileMap[file] = result.content;
|
|
523
|
+
}
|
|
524
|
+
})
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
await Promise.all(jkgJsonFileTasks);
|
|
528
|
+
consola.info(`Checking for dart dependencies`);
|
|
529
|
+
const pubspecFiles = await globby(["pubspec.yaml", "**/pubspec.yaml"]);
|
|
530
|
+
const pubspecFileTasks = [];
|
|
531
|
+
if (pubspecFiles.length) {
|
|
532
|
+
const dartPackage = await getDartPackageMeta();
|
|
533
|
+
let hasVersion = false;
|
|
534
|
+
for (const item of dartPackage.versions) {
|
|
535
|
+
if (item.version == version) {
|
|
536
|
+
hasVersion = true;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (!hasVersion) {
|
|
541
|
+
throw new Error(
|
|
542
|
+
`Version ${version} does not have Dart support`
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
for (const file of pubspecFiles) {
|
|
547
|
+
pubspecFileTasks.push(
|
|
548
|
+
readFile(path.resolve(file), "utf8").then((content) => {
|
|
549
|
+
const result = updatePubspecYaml(content, version);
|
|
550
|
+
if (result.updated) {
|
|
551
|
+
fileMap[file] = result.content;
|
|
552
|
+
}
|
|
553
|
+
})
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
await Promise.all(pubspecFileTasks);
|
|
557
|
+
const updateTasks = [];
|
|
558
|
+
for (const key of Object.keys(fileMap)) {
|
|
559
|
+
updateTasks.push(
|
|
560
|
+
writeFile(path.resolve(key), fileMap[key], "utf8").then(
|
|
561
|
+
() => consola.success(`Updated ${key}`)
|
|
562
|
+
)
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
await Promise.all(updateTasks);
|
|
566
|
+
consola.success(
|
|
567
|
+
`Updated to ${version}. Rerun your install commands to update your dependencies.`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
function updatePackageJson(fileContent, targetVersion) {
|
|
572
|
+
const lines = fileContent.split("\n");
|
|
573
|
+
const output = [];
|
|
574
|
+
let updated = false;
|
|
575
|
+
for (const line of lines) {
|
|
576
|
+
if (line.includes(`"arri"`)) {
|
|
577
|
+
output.push(updateLine(line));
|
|
578
|
+
updated = true;
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
if (line.includes(`"@arrirpc/`)) {
|
|
582
|
+
output.push(updateLine(line));
|
|
583
|
+
updated = true;
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
output.push(line);
|
|
587
|
+
}
|
|
588
|
+
function updateLine(line) {
|
|
589
|
+
const parts = line.split('":');
|
|
590
|
+
if (parts.length < 2) {
|
|
591
|
+
return line;
|
|
592
|
+
}
|
|
593
|
+
const targetParts = parts[1].split('"');
|
|
594
|
+
targetParts[1] = `^${targetVersion}`;
|
|
595
|
+
parts[1] = targetParts.join('"');
|
|
596
|
+
return parts.join('":');
|
|
597
|
+
}
|
|
598
|
+
return {
|
|
599
|
+
updated,
|
|
600
|
+
content: output.join("\n")
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
const PubPackageResponse = a.object({
|
|
604
|
+
name: a.string(),
|
|
605
|
+
versions: a.array(
|
|
606
|
+
a.object({
|
|
607
|
+
version: a.string(),
|
|
608
|
+
pubspec: a.object({
|
|
609
|
+
name: a.string(),
|
|
610
|
+
description: a.string(),
|
|
611
|
+
version: a.string(),
|
|
612
|
+
repository: a.string(),
|
|
613
|
+
environment: a.object({
|
|
614
|
+
sdk: a.string()
|
|
615
|
+
}),
|
|
616
|
+
dependencies: a.record(a.string()),
|
|
617
|
+
dev_dependencies: a.record(a.string())
|
|
618
|
+
}),
|
|
619
|
+
archive_url: a.string(),
|
|
620
|
+
archive_sha256: a.string(),
|
|
621
|
+
published: a.string()
|
|
622
|
+
})
|
|
623
|
+
)
|
|
624
|
+
});
|
|
625
|
+
async function getDartPackageMeta() {
|
|
626
|
+
const response = await ofetch("https://pub.dev/api/packages/arri_client");
|
|
627
|
+
const data = a.parse(PubPackageResponse, response);
|
|
628
|
+
return data;
|
|
629
|
+
}
|
|
630
|
+
function updatePubspecYaml(fileContent, version) {
|
|
631
|
+
const lines = fileContent.split("\n");
|
|
632
|
+
const output = [];
|
|
633
|
+
let updated = false;
|
|
634
|
+
for (const line of lines) {
|
|
635
|
+
if (line.includes("arri_client: ")) {
|
|
636
|
+
const parts = line.split(": ");
|
|
637
|
+
if (parts.length < 2) {
|
|
638
|
+
output.push(line);
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
const targetPart = parts[1];
|
|
642
|
+
const subParts = targetPart.split(" ");
|
|
643
|
+
subParts[0] = `^${version}`;
|
|
644
|
+
parts[1] = subParts.join(" ");
|
|
645
|
+
output.push(parts.join(": "));
|
|
646
|
+
updated = true;
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
output.push(line);
|
|
650
|
+
}
|
|
651
|
+
return {
|
|
652
|
+
updated,
|
|
653
|
+
content: output.join("\n")
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
658
|
+
const __dirname = path.dirname(__filename);
|
|
659
|
+
const version = defineCommand({
|
|
660
|
+
meta: {
|
|
661
|
+
name: "Version",
|
|
662
|
+
description: "Get the current Arri CLI version"
|
|
663
|
+
},
|
|
664
|
+
run() {
|
|
665
|
+
const packageJson = JSON.parse(
|
|
666
|
+
readFileSync(path.resolve(__dirname, "../package.json"), {
|
|
667
|
+
encoding: "utf8"
|
|
668
|
+
})
|
|
669
|
+
);
|
|
670
|
+
console.info(`${packageJson.version}`);
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
|
|
443
674
|
const main = defineCommand({
|
|
444
675
|
subCommands: {
|
|
445
676
|
build,
|
|
446
|
-
dev,
|
|
447
677
|
codegen,
|
|
448
|
-
|
|
678
|
+
dev,
|
|
679
|
+
init,
|
|
680
|
+
list,
|
|
681
|
+
use,
|
|
682
|
+
version
|
|
449
683
|
}
|
|
450
684
|
});
|
|
451
685
|
void runMain(main);
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const dev = require('./shared/arri.
|
|
3
|
+
const dev = require('./shared/arri.8421be96.cjs');
|
|
4
4
|
const codegenDart = require('@arrirpc/codegen-dart');
|
|
5
5
|
const codegenKotlin = require('@arrirpc/codegen-kotlin');
|
|
6
6
|
const codegenTs = require('@arrirpc/codegen-ts');
|
|
@@ -14,9 +14,9 @@ require('esbuild');
|
|
|
14
14
|
require('h3');
|
|
15
15
|
require('ofetch');
|
|
16
16
|
require('pathe');
|
|
17
|
+
require('@arrirpc/schema');
|
|
17
18
|
require('consola');
|
|
18
19
|
require('prettier');
|
|
19
|
-
require('scule');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DEV_DEFINITION_ENDPOINT, d as defaultConfig, b as defineConfig, i as isArriConfig, a as isResolvedArriConfig } from './shared/arri.
|
|
1
|
+
export { D as DEV_DEFINITION_ENDPOINT, d as defaultConfig, b as defineConfig, i as isArriConfig, a as isResolvedArriConfig } from './shared/arri.1c716de9.mjs';
|
|
2
2
|
export { dartClientGenerator } from '@arrirpc/codegen-dart';
|
|
3
3
|
export { kotlinClientGenerator } from '@arrirpc/codegen-kotlin';
|
|
4
4
|
export { typescriptClientGenerator } from '@arrirpc/codegen-ts';
|
|
@@ -12,6 +12,6 @@ import 'esbuild';
|
|
|
12
12
|
import 'h3';
|
|
13
13
|
import 'ofetch';
|
|
14
14
|
import 'pathe';
|
|
15
|
+
import '@arrirpc/schema';
|
|
15
16
|
import 'consola';
|
|
16
17
|
import 'prettier';
|
|
17
|
-
import 'scule';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
|
-
import { removeDisallowedChars, isAppDefinition } from '@arrirpc/codegen-utils';
|
|
3
|
+
import { camelCase, removeDisallowedChars, kebabCase, isAppDefinition } from '@arrirpc/codegen-utils';
|
|
4
4
|
import { listenAndWatch } from '@joshmossas/listhen';
|
|
5
5
|
import { loadConfig } from 'c12';
|
|
6
6
|
import { defineCommand } from 'citty';
|
|
@@ -8,9 +8,9 @@ import * as esbuild from 'esbuild';
|
|
|
8
8
|
import 'h3';
|
|
9
9
|
import { ofetch } from 'ofetch';
|
|
10
10
|
import path from 'pathe';
|
|
11
|
+
import { a, ValidationError } from '@arrirpc/schema';
|
|
11
12
|
import { createConsola } from 'consola';
|
|
12
13
|
import prettier from 'prettier';
|
|
13
|
-
import { camelCase, kebabCase } from 'scule';
|
|
14
14
|
|
|
15
15
|
const logger = createConsola().withTag("arri");
|
|
16
16
|
const GEN_APP_FILE = "__arri_app.ts";
|
|
@@ -48,7 +48,7 @@ async function createAppWithRoutesModule(config) {
|
|
|
48
48
|
}
|
|
49
49
|
})
|
|
50
50
|
);
|
|
51
|
-
routes.sort((
|
|
51
|
+
routes.sort((a2, b) => a2.name < b.name ? -1 : 1);
|
|
52
52
|
const module = await prettier.format(
|
|
53
53
|
`import sourceMapSupport from 'source-map-support';
|
|
54
54
|
sourceMapSupport.install();
|
|
@@ -147,6 +147,88 @@ function isInsideDir(dir, parentDir) {
|
|
|
147
147
|
}
|
|
148
148
|
return false;
|
|
149
149
|
}
|
|
150
|
+
async function getArriPackageMetadata() {
|
|
151
|
+
const npmPackageResponse = await ofetch("https://registry.npmjs.com/arri");
|
|
152
|
+
const arriInfo = a.safeParse(NpmRegistryPackage, npmPackageResponse);
|
|
153
|
+
if (!arriInfo.success) {
|
|
154
|
+
const errors = a.errors(NpmRegistryPackage, npmPackageResponse);
|
|
155
|
+
console.warn(errors);
|
|
156
|
+
throw new ValidationError({
|
|
157
|
+
message: "Arri parsing response from registry",
|
|
158
|
+
errors
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return arriInfo.value;
|
|
162
|
+
}
|
|
163
|
+
const NpmPackageVersion = a.partial(
|
|
164
|
+
a.object({
|
|
165
|
+
name: a.string(),
|
|
166
|
+
version: a.string(),
|
|
167
|
+
_id: a.string(),
|
|
168
|
+
maintainers: a.array(
|
|
169
|
+
a.object({
|
|
170
|
+
name: a.string(),
|
|
171
|
+
email: a.string()
|
|
172
|
+
})
|
|
173
|
+
),
|
|
174
|
+
bin: a.record(a.string()),
|
|
175
|
+
dist: a.any(),
|
|
176
|
+
main: a.string(),
|
|
177
|
+
type: a.string(),
|
|
178
|
+
types: a.string(),
|
|
179
|
+
module: a.string(),
|
|
180
|
+
gitHead: a.string(),
|
|
181
|
+
_npmUser: a.object({
|
|
182
|
+
name: a.string(),
|
|
183
|
+
email: a.string()
|
|
184
|
+
}),
|
|
185
|
+
description: a.string(),
|
|
186
|
+
directories: a.record(a.any()),
|
|
187
|
+
_nodeVersion: a.string(),
|
|
188
|
+
dependencies: a.record(a.string()),
|
|
189
|
+
_hasShrinkWrap: a.boolean(),
|
|
190
|
+
_npmOperationalInternal: a.any()
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
const NpmRegistryPackage = a.object({
|
|
194
|
+
_id: a.string(),
|
|
195
|
+
_rev: a.string(),
|
|
196
|
+
name: a.string(),
|
|
197
|
+
description: a.string(),
|
|
198
|
+
"dist-tags": a.record(a.string()),
|
|
199
|
+
versions: a.record(NpmPackageVersion),
|
|
200
|
+
time: a.record(a.string()),
|
|
201
|
+
maintainers: a.array(
|
|
202
|
+
a.object({
|
|
203
|
+
name: a.string(),
|
|
204
|
+
email: a.string()
|
|
205
|
+
})
|
|
206
|
+
),
|
|
207
|
+
author: a.object({
|
|
208
|
+
name: a.string(),
|
|
209
|
+
url: a.string()
|
|
210
|
+
}),
|
|
211
|
+
repository: a.optional(
|
|
212
|
+
a.partial(
|
|
213
|
+
a.object({
|
|
214
|
+
type: a.string(),
|
|
215
|
+
url: a.string(),
|
|
216
|
+
directory: a.string()
|
|
217
|
+
})
|
|
218
|
+
)
|
|
219
|
+
),
|
|
220
|
+
license: a.optional(a.string()),
|
|
221
|
+
homepage: a.optional(a.string()),
|
|
222
|
+
bugs: a.optional(
|
|
223
|
+
a.partial(
|
|
224
|
+
a.object({
|
|
225
|
+
url: a.string()
|
|
226
|
+
})
|
|
227
|
+
)
|
|
228
|
+
),
|
|
229
|
+
readme: a.optional(a.string()),
|
|
230
|
+
readmeFilename: a.optional(a.string())
|
|
231
|
+
});
|
|
150
232
|
|
|
151
233
|
function isArriConfig(input) {
|
|
152
234
|
if (typeof input !== "object" || input === null) {
|
|
@@ -400,4 +482,4 @@ export default app.h3App;`;
|
|
|
400
482
|
);
|
|
401
483
|
}
|
|
402
484
|
|
|
403
|
-
export { DEV_DEFINITION_ENDPOINT as D, GEN_APP_FILE as G, OUT_CODEGEN as O, isResolvedArriConfig as a, defineConfig as b, createAppWithRoutesModule as c, defaultConfig as d, OUT_SERVER_ENTRY as e, OUT_APP_FILE as f,
|
|
485
|
+
export { DEV_DEFINITION_ENDPOINT as D, GEN_APP_FILE as G, OUT_CODEGEN as O, isResolvedArriConfig as a, defineConfig as b, createAppWithRoutesModule as c, defaultConfig as d, OUT_SERVER_ENTRY as e, OUT_APP_FILE as f, getArriPackageMetadata as g, dev as h, isArriConfig as i, logger as l, setupWorkingDir as s };
|
|
@@ -10,9 +10,9 @@ const esbuild = require('esbuild');
|
|
|
10
10
|
require('h3');
|
|
11
11
|
const ofetch = require('ofetch');
|
|
12
12
|
const path = require('pathe');
|
|
13
|
+
const schema = require('@arrirpc/schema');
|
|
13
14
|
const consola = require('consola');
|
|
14
15
|
const prettier = require('prettier');
|
|
15
|
-
const scule = require('scule');
|
|
16
16
|
|
|
17
17
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
18
18
|
|
|
@@ -69,7 +69,7 @@ async function createAppWithRoutesModule(config) {
|
|
|
69
69
|
}
|
|
70
70
|
})
|
|
71
71
|
);
|
|
72
|
-
routes.sort((
|
|
72
|
+
routes.sort((a2, b) => a2.name < b.name ? -1 : 1);
|
|
73
73
|
const module = await prettier__default.format(
|
|
74
74
|
`import sourceMapSupport from 'source-map-support';
|
|
75
75
|
sourceMapSupport.install();
|
|
@@ -121,7 +121,7 @@ async function getFsRouteBatch(glob, globPattern, config) {
|
|
|
121
121
|
importParts.pop();
|
|
122
122
|
routes.push({
|
|
123
123
|
name: meta.id,
|
|
124
|
-
importName:
|
|
124
|
+
importName: codegenUtils.camelCase(meta.id.split(".").join("_")),
|
|
125
125
|
importPath: `./${importParts.join(".")}`
|
|
126
126
|
});
|
|
127
127
|
}
|
|
@@ -154,8 +154,8 @@ const getRpcMetaFromPath = (config, filePath) => {
|
|
|
154
154
|
disallowedNameChars
|
|
155
155
|
);
|
|
156
156
|
const httpParts = [
|
|
157
|
-
...serviceParts.map((part) =>
|
|
158
|
-
|
|
157
|
+
...serviceParts.map((part) => codegenUtils.kebabCase(part)),
|
|
158
|
+
codegenUtils.kebabCase(rpcName)
|
|
159
159
|
];
|
|
160
160
|
return {
|
|
161
161
|
id: [...serviceParts, rpcName].join("."),
|
|
@@ -168,6 +168,88 @@ function isInsideDir(dir, parentDir) {
|
|
|
168
168
|
}
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
|
+
async function getArriPackageMetadata() {
|
|
172
|
+
const npmPackageResponse = await ofetch.ofetch("https://registry.npmjs.com/arri");
|
|
173
|
+
const arriInfo = schema.a.safeParse(NpmRegistryPackage, npmPackageResponse);
|
|
174
|
+
if (!arriInfo.success) {
|
|
175
|
+
const errors = schema.a.errors(NpmRegistryPackage, npmPackageResponse);
|
|
176
|
+
console.warn(errors);
|
|
177
|
+
throw new schema.ValidationError({
|
|
178
|
+
message: "Arri parsing response from registry",
|
|
179
|
+
errors
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return arriInfo.value;
|
|
183
|
+
}
|
|
184
|
+
const NpmPackageVersion = schema.a.partial(
|
|
185
|
+
schema.a.object({
|
|
186
|
+
name: schema.a.string(),
|
|
187
|
+
version: schema.a.string(),
|
|
188
|
+
_id: schema.a.string(),
|
|
189
|
+
maintainers: schema.a.array(
|
|
190
|
+
schema.a.object({
|
|
191
|
+
name: schema.a.string(),
|
|
192
|
+
email: schema.a.string()
|
|
193
|
+
})
|
|
194
|
+
),
|
|
195
|
+
bin: schema.a.record(schema.a.string()),
|
|
196
|
+
dist: schema.a.any(),
|
|
197
|
+
main: schema.a.string(),
|
|
198
|
+
type: schema.a.string(),
|
|
199
|
+
types: schema.a.string(),
|
|
200
|
+
module: schema.a.string(),
|
|
201
|
+
gitHead: schema.a.string(),
|
|
202
|
+
_npmUser: schema.a.object({
|
|
203
|
+
name: schema.a.string(),
|
|
204
|
+
email: schema.a.string()
|
|
205
|
+
}),
|
|
206
|
+
description: schema.a.string(),
|
|
207
|
+
directories: schema.a.record(schema.a.any()),
|
|
208
|
+
_nodeVersion: schema.a.string(),
|
|
209
|
+
dependencies: schema.a.record(schema.a.string()),
|
|
210
|
+
_hasShrinkWrap: schema.a.boolean(),
|
|
211
|
+
_npmOperationalInternal: schema.a.any()
|
|
212
|
+
})
|
|
213
|
+
);
|
|
214
|
+
const NpmRegistryPackage = schema.a.object({
|
|
215
|
+
_id: schema.a.string(),
|
|
216
|
+
_rev: schema.a.string(),
|
|
217
|
+
name: schema.a.string(),
|
|
218
|
+
description: schema.a.string(),
|
|
219
|
+
"dist-tags": schema.a.record(schema.a.string()),
|
|
220
|
+
versions: schema.a.record(NpmPackageVersion),
|
|
221
|
+
time: schema.a.record(schema.a.string()),
|
|
222
|
+
maintainers: schema.a.array(
|
|
223
|
+
schema.a.object({
|
|
224
|
+
name: schema.a.string(),
|
|
225
|
+
email: schema.a.string()
|
|
226
|
+
})
|
|
227
|
+
),
|
|
228
|
+
author: schema.a.object({
|
|
229
|
+
name: schema.a.string(),
|
|
230
|
+
url: schema.a.string()
|
|
231
|
+
}),
|
|
232
|
+
repository: schema.a.optional(
|
|
233
|
+
schema.a.partial(
|
|
234
|
+
schema.a.object({
|
|
235
|
+
type: schema.a.string(),
|
|
236
|
+
url: schema.a.string(),
|
|
237
|
+
directory: schema.a.string()
|
|
238
|
+
})
|
|
239
|
+
)
|
|
240
|
+
),
|
|
241
|
+
license: schema.a.optional(schema.a.string()),
|
|
242
|
+
homepage: schema.a.optional(schema.a.string()),
|
|
243
|
+
bugs: schema.a.optional(
|
|
244
|
+
schema.a.partial(
|
|
245
|
+
schema.a.object({
|
|
246
|
+
url: schema.a.string()
|
|
247
|
+
})
|
|
248
|
+
)
|
|
249
|
+
),
|
|
250
|
+
readme: schema.a.optional(schema.a.string()),
|
|
251
|
+
readmeFilename: schema.a.optional(schema.a.string())
|
|
252
|
+
});
|
|
171
253
|
|
|
172
254
|
function isArriConfig(input) {
|
|
173
255
|
if (typeof input !== "object" || input === null) {
|
|
@@ -430,6 +512,7 @@ exports.createAppWithRoutesModule = createAppWithRoutesModule;
|
|
|
430
512
|
exports.defaultConfig = defaultConfig;
|
|
431
513
|
exports.defineConfig = defineConfig;
|
|
432
514
|
exports.dev = dev;
|
|
515
|
+
exports.getArriPackageMetadata = getArriPackageMetadata;
|
|
433
516
|
exports.isArriConfig = isArriConfig;
|
|
434
517
|
exports.isResolvedArriConfig = isResolvedArriConfig;
|
|
435
518
|
exports.logger = logger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arri",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"ofetch": "^1.3.4",
|
|
40
40
|
"pathe": "^1.1.2",
|
|
41
41
|
"prettier": "^3.3.0",
|
|
42
|
-
"
|
|
43
|
-
"@arrirpc/codegen-kotlin": "0.
|
|
44
|
-
"@arrirpc/codegen-
|
|
45
|
-
"@arrirpc/codegen-utils": "0.
|
|
46
|
-
"@arrirpc/
|
|
42
|
+
"@arrirpc/codegen-dart": "0.49.1",
|
|
43
|
+
"@arrirpc/codegen-kotlin": "0.49.1",
|
|
44
|
+
"@arrirpc/codegen-ts": "0.49.1",
|
|
45
|
+
"@arrirpc/codegen-utils": "0.49.1",
|
|
46
|
+
"@arrirpc/schema": "0.49.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/degit": "^2.8.6"
|