everything-dev 0.0.18 → 0.0.20
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/package.json +1 -1
- package/src/cli.ts +22 -3
- package/src/lib/sync.ts +8 -5
- package/src/plugin.ts +49 -10
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
+
import { spinner } from "@clack/prompts";
|
|
2
3
|
import { program } from "commander";
|
|
3
4
|
import { createPluginRuntime } from "every-plugin";
|
|
4
5
|
import { getConfigDir, getConfigPath, getPackages, getTitle, loadConfig, type BosConfig } from "./config";
|
|
@@ -747,25 +748,31 @@ Zephyr Configuration:
|
|
|
747
748
|
.option("--gateway <gateway>", "Gateway domain to sync from (default: everything.dev)")
|
|
748
749
|
.option("--network <network>", "Network: mainnet | testnet", "mainnet")
|
|
749
750
|
.option("--force", "Force sync even if versions match")
|
|
750
|
-
.
|
|
751
|
+
.option("--files", "Also sync template files (tsconfig, etc.)")
|
|
752
|
+
.action(async (options: { account?: string; gateway?: string; network?: string; force?: boolean; files?: boolean }) => {
|
|
751
753
|
console.log();
|
|
752
754
|
const source = options.account || options.gateway
|
|
753
755
|
? `${options.account || "every.near"}/${options.gateway || "everything.dev"}`
|
|
754
756
|
: "every.near/everything.dev";
|
|
755
|
-
|
|
757
|
+
|
|
758
|
+
const s = spinner();
|
|
759
|
+
s.start(`Syncing from ${source}...`);
|
|
756
760
|
|
|
757
761
|
const result = await client.sync({
|
|
758
762
|
account: options.account,
|
|
759
763
|
gateway: options.gateway,
|
|
760
764
|
network: (options.network as "mainnet" | "testnet") || "mainnet",
|
|
761
765
|
force: options.force || false,
|
|
766
|
+
files: options.files || false,
|
|
762
767
|
});
|
|
763
768
|
|
|
764
769
|
if (result.status === "error") {
|
|
765
|
-
|
|
770
|
+
s.stop(colors.error(`${icons.err} Sync failed: ${result.error || "Unknown error"}`));
|
|
766
771
|
process.exit(1);
|
|
767
772
|
}
|
|
768
773
|
|
|
774
|
+
s.stop(colors.green(`${icons.ok} Synced from ${source}`));
|
|
775
|
+
|
|
769
776
|
console.log();
|
|
770
777
|
console.log(colors.cyan(frames.top(52)));
|
|
771
778
|
console.log(` ${icons.ok} ${gradients.cyber("SYNCED")}`);
|
|
@@ -782,6 +789,18 @@ Zephyr Configuration:
|
|
|
782
789
|
if (result.packagesUpdated.length > 0) {
|
|
783
790
|
console.log(colors.green(` ${icons.ok} Updated packages: ${result.packagesUpdated.join(", ")}`));
|
|
784
791
|
}
|
|
792
|
+
|
|
793
|
+
if (result.filesSynced && result.filesSynced.length > 0) {
|
|
794
|
+
const totalFiles = result.filesSynced.reduce((sum, pkg) => sum + pkg.files.length, 0);
|
|
795
|
+
console.log(colors.green(` ${icons.ok} Synced ${totalFiles} files`));
|
|
796
|
+
for (const pkg of result.filesSynced) {
|
|
797
|
+
console.log(colors.dim(` ${pkg.package}: ${pkg.files.join(", ")}`));
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
if (!result.catalogUpdated && result.packagesUpdated.length === 0 && (!result.filesSynced || result.filesSynced.length === 0)) {
|
|
802
|
+
console.log(colors.dim(` ${icons.ok} Already up to date`));
|
|
803
|
+
}
|
|
785
804
|
|
|
786
805
|
console.log();
|
|
787
806
|
console.log(colors.dim(" Run 'bun install' to update lockfile"));
|
package/src/lib/sync.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { mkdtemp, rm, cp, mkdir } from "fs/promises";
|
|
2
|
-
import { tmpdir } from "os";
|
|
3
|
-
import { join, dirname } from "path";
|
|
4
1
|
import { execa } from "execa";
|
|
2
|
+
import { cp, mkdir, mkdtemp, rm } from "fs/promises";
|
|
3
|
+
import { tmpdir } from "os";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
5
|
import type { BosConfig } from "../config";
|
|
6
6
|
|
|
7
7
|
export interface FileSyncResult {
|
|
@@ -24,6 +24,10 @@ export async function syncFiles(options: FileSyncOptions): Promise<FileSyncResul
|
|
|
24
24
|
const results: FileSyncResult[] = [];
|
|
25
25
|
|
|
26
26
|
for (const pkg of packages) {
|
|
27
|
+
const pkgDir = `${configDir}/${pkg}`;
|
|
28
|
+
const pkgDirExists = await Bun.file(`${pkgDir}/package.json`).exists();
|
|
29
|
+
if (!pkgDirExists) continue;
|
|
30
|
+
|
|
27
31
|
const appConfig = bosConfig.app[pkg] as {
|
|
28
32
|
template?: string;
|
|
29
33
|
files?: string[];
|
|
@@ -44,7 +48,6 @@ export async function syncFiles(options: FileSyncOptions): Promise<FileSyncResul
|
|
|
44
48
|
const filesSynced: string[] = [];
|
|
45
49
|
const depsAdded: string[] = [];
|
|
46
50
|
const depsUpdated: string[] = [];
|
|
47
|
-
const pkgDir = `${configDir}/${pkg}`;
|
|
48
51
|
|
|
49
52
|
for (const file of appConfig.files) {
|
|
50
53
|
const srcPath = join(tempDir, file);
|
|
@@ -53,7 +56,7 @@ export async function syncFiles(options: FileSyncOptions): Promise<FileSyncResul
|
|
|
53
56
|
try {
|
|
54
57
|
const destDir = dirname(destPath);
|
|
55
58
|
await mkdir(destDir, { recursive: true });
|
|
56
|
-
await cp(srcPath, destPath, { force, recursive: true });
|
|
59
|
+
await cp(srcPath, destPath, { force: true, recursive: true });
|
|
57
60
|
filesSynced.push(file);
|
|
58
61
|
} catch {
|
|
59
62
|
}
|
package/src/plugin.ts
CHANGED
|
@@ -1247,7 +1247,7 @@ export default createPlugin({
|
|
|
1247
1247
|
const graph = new Graph();
|
|
1248
1248
|
const configPath = `${account}/bos/gateways/${gateway}/bos.config.json`;
|
|
1249
1249
|
|
|
1250
|
-
let remoteConfig:
|
|
1250
|
+
let remoteConfig: BosConfigType | null = null;
|
|
1251
1251
|
|
|
1252
1252
|
const data = await graph.get({ keys: [configPath] });
|
|
1253
1253
|
if (data) {
|
|
@@ -1262,7 +1262,7 @@ export default createPlugin({
|
|
|
1262
1262
|
}
|
|
1263
1263
|
}
|
|
1264
1264
|
if (typeof current === "string") {
|
|
1265
|
-
remoteConfig = JSON.parse(current);
|
|
1265
|
+
remoteConfig = JSON.parse(current) as BosConfigType;
|
|
1266
1266
|
}
|
|
1267
1267
|
}
|
|
1268
1268
|
|
|
@@ -1291,13 +1291,50 @@ export default createPlugin({
|
|
|
1291
1291
|
};
|
|
1292
1292
|
}
|
|
1293
1293
|
|
|
1294
|
+
const mergeAppConfig = (localApp: Record<string, unknown>, remoteApp: Record<string, unknown>): Record<string, unknown> => {
|
|
1295
|
+
const merged: Record<string, unknown> = {};
|
|
1296
|
+
|
|
1297
|
+
for (const key of Object.keys(remoteApp)) {
|
|
1298
|
+
const local = localApp[key] as Record<string, unknown> | undefined;
|
|
1299
|
+
const remote = remoteApp[key] as Record<string, unknown>;
|
|
1300
|
+
|
|
1301
|
+
if (!local) {
|
|
1302
|
+
merged[key] = remote;
|
|
1303
|
+
continue;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
merged[key] = {
|
|
1307
|
+
...remote,
|
|
1308
|
+
development: local.development,
|
|
1309
|
+
secrets: [...new Set([
|
|
1310
|
+
...((remote.secrets as string[]) || []),
|
|
1311
|
+
...((local.secrets as string[]) || []),
|
|
1312
|
+
])],
|
|
1313
|
+
variables: {
|
|
1314
|
+
...((remote.variables as Record<string, unknown>) || {}),
|
|
1315
|
+
...((local.variables as Record<string, unknown>) || {}),
|
|
1316
|
+
},
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
return merged;
|
|
1321
|
+
};
|
|
1294
1322
|
|
|
1323
|
+
const updatedBosConfig: BosConfigType = {
|
|
1324
|
+
account: bosConfig.account,
|
|
1325
|
+
testnet: bosConfig.testnet,
|
|
1326
|
+
template: remoteConfig.template,
|
|
1327
|
+
shared: remoteConfig.shared,
|
|
1328
|
+
gateway: remoteConfig.gateway,
|
|
1329
|
+
app: mergeAppConfig(
|
|
1330
|
+
bosConfig.app as Record<string, unknown>,
|
|
1331
|
+
remoteConfig.app as Record<string, unknown>
|
|
1332
|
+
) as BosConfigType["app"],
|
|
1333
|
+
};
|
|
1295
1334
|
|
|
1296
1335
|
const bosConfigPath = `${configDir}/bos.config.json`;
|
|
1297
|
-
const updatedBosConfig = {
|
|
1298
|
-
...bosConfig,
|
|
1299
|
-
};
|
|
1300
1336
|
await Bun.write(bosConfigPath, JSON.stringify(updatedBosConfig, null, 2));
|
|
1337
|
+
setConfig(updatedBosConfig, configDir);
|
|
1301
1338
|
|
|
1302
1339
|
const sharedUiDeps: Record<string, string> = {};
|
|
1303
1340
|
const sharedUi = updatedBosConfig.shared?.ui as Record<string, { requiredVersion?: string }> | undefined;
|
|
@@ -1325,10 +1362,12 @@ export default createPlugin({
|
|
|
1325
1362
|
const packagesUpdated: string[] = [];
|
|
1326
1363
|
|
|
1327
1364
|
for (const pkg of packages) {
|
|
1328
|
-
const
|
|
1329
|
-
const
|
|
1365
|
+
const pkgDir = `${configDir}/${pkg}`;
|
|
1366
|
+
const pkgDirExists = await Bun.file(`${pkgDir}/package.json`).exists();
|
|
1367
|
+
if (!pkgDirExists) continue;
|
|
1330
1368
|
|
|
1331
|
-
|
|
1369
|
+
const pkgPath = `${pkgDir}/package.json`;
|
|
1370
|
+
const pkgFile = Bun.file(pkgPath);
|
|
1332
1371
|
|
|
1333
1372
|
const pkgJson = await pkgFile.json() as {
|
|
1334
1373
|
dependencies?: Record<string, string>;
|
|
@@ -1361,8 +1400,8 @@ export default createPlugin({
|
|
|
1361
1400
|
if (input.files) {
|
|
1362
1401
|
const results = await syncFiles({
|
|
1363
1402
|
configDir,
|
|
1364
|
-
packages: Object.keys(
|
|
1365
|
-
bosConfig,
|
|
1403
|
+
packages: Object.keys(updatedBosConfig.app),
|
|
1404
|
+
bosConfig: updatedBosConfig,
|
|
1366
1405
|
catalog: rootPkg.workspaces?.catalog ?? {},
|
|
1367
1406
|
force: input.force,
|
|
1368
1407
|
});
|