everything-dev 1.3.7 → 1.4.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.
Files changed (76) hide show
  1. package/dist/cli/init.cjs +34 -5
  2. package/dist/cli/init.cjs.map +1 -1
  3. package/dist/cli/init.d.cts +10 -7
  4. package/dist/cli/init.d.cts.map +1 -1
  5. package/dist/cli/init.d.mts +10 -7
  6. package/dist/cli/init.d.mts.map +1 -1
  7. package/dist/cli/init.mjs +34 -6
  8. package/dist/cli/init.mjs.map +1 -1
  9. package/dist/cli/prompts.cjs +19 -9
  10. package/dist/cli/prompts.cjs.map +1 -1
  11. package/dist/cli/prompts.mjs +19 -9
  12. package/dist/cli/prompts.mjs.map +1 -1
  13. package/dist/cli/snapshot.cjs +35 -0
  14. package/dist/cli/snapshot.cjs.map +1 -0
  15. package/dist/cli/snapshot.mjs +33 -0
  16. package/dist/cli/snapshot.mjs.map +1 -0
  17. package/dist/cli/status.cjs +80 -0
  18. package/dist/cli/status.cjs.map +1 -0
  19. package/dist/cli/status.mjs +79 -0
  20. package/dist/cli/status.mjs.map +1 -0
  21. package/dist/cli/sync.cjs +170 -0
  22. package/dist/cli/sync.cjs.map +1 -0
  23. package/dist/cli/sync.mjs +169 -0
  24. package/dist/cli/sync.mjs.map +1 -0
  25. package/dist/cli/upgrade.cjs +123 -0
  26. package/dist/cli/upgrade.cjs.map +1 -0
  27. package/dist/cli/upgrade.mjs +122 -0
  28. package/dist/cli/upgrade.mjs.map +1 -0
  29. package/dist/cli.cjs +101 -5
  30. package/dist/cli.cjs.map +1 -1
  31. package/dist/cli.mjs +101 -5
  32. package/dist/cli.mjs.map +1 -1
  33. package/dist/contract.cjs +81 -8
  34. package/dist/contract.cjs.map +1 -1
  35. package/dist/contract.d.cts +162 -21
  36. package/dist/contract.d.cts.map +1 -1
  37. package/dist/contract.d.mts +162 -21
  38. package/dist/contract.d.mts.map +1 -1
  39. package/dist/contract.meta.cjs +32 -9
  40. package/dist/contract.meta.cjs.map +1 -1
  41. package/dist/contract.meta.d.cts +50 -11
  42. package/dist/contract.meta.d.mts +50 -11
  43. package/dist/contract.meta.mjs +32 -9
  44. package/dist/contract.meta.mjs.map +1 -1
  45. package/dist/contract.mjs +77 -9
  46. package/dist/contract.mjs.map +1 -1
  47. package/dist/index.cjs +5 -0
  48. package/dist/index.d.cts +2 -2
  49. package/dist/index.d.mts +2 -2
  50. package/dist/index.mjs +2 -2
  51. package/dist/plugin.cjs +123 -43
  52. package/dist/plugin.cjs.map +1 -1
  53. package/dist/plugin.d.cts +78 -11
  54. package/dist/plugin.d.cts.map +1 -1
  55. package/dist/plugin.d.mts +78 -11
  56. package/dist/plugin.d.mts.map +1 -1
  57. package/dist/plugin.mjs +126 -46
  58. package/dist/plugin.mjs.map +1 -1
  59. package/dist/types.d.cts +2 -2
  60. package/dist/types.d.mts +2 -2
  61. package/dist/utils/theme.cjs +1 -0
  62. package/dist/utils/theme.cjs.map +1 -1
  63. package/dist/utils/theme.mjs +1 -0
  64. package/dist/utils/theme.mjs.map +1 -1
  65. package/package.json +1 -1
  66. package/src/cli/init.ts +60 -11
  67. package/src/cli/prompts.ts +34 -16
  68. package/src/cli/snapshot.ts +46 -0
  69. package/src/cli/status.ts +85 -0
  70. package/src/cli/sync.ts +239 -0
  71. package/src/cli/upgrade.ts +165 -0
  72. package/src/cli.ts +152 -5
  73. package/src/contract.meta.ts +36 -6
  74. package/src/contract.ts +74 -7
  75. package/src/plugin.ts +156 -45
  76. package/src/utils/theme.ts +1 -0
package/src/plugin.ts CHANGED
@@ -1,18 +1,24 @@
1
1
  import { readFileSync, writeFileSync } from "node:fs";
2
- import { basename, join, resolve } from "node:path";
2
+ import { basename, dirname, join, resolve } from "node:path";
3
3
  import { Effect } from "effect";
4
4
  import { syncApiContractBridge } from "./api-contract";
5
5
  import { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from "./app";
6
6
  import {
7
7
  copyFilteredFiles,
8
+ fetchParentConfig,
8
9
  personalizeConfig,
9
10
  readTemplatekeep,
10
11
  resolveSourceDir,
11
12
  runBunInstall,
13
+ writeInitSnapshot,
12
14
  } from "./cli/init";
13
15
  import { promptInitOptions } from "./cli/prompts";
16
+ import { getStatus } from "./cli/status";
17
+ import { syncTemplate } from "./cli/sync";
18
+ import { upgradeTemplate } from "./cli/upgrade";
14
19
  import {
15
20
  buildRuntimePluginsForConfig,
21
+ findConfigPath,
16
22
  getHostDevelopmentPort,
17
23
  getProjectRoot,
18
24
  loadConfig,
@@ -33,6 +39,8 @@ import {
33
39
  type PluginRemoveOptions,
34
40
  type PublishOptions,
35
41
  type StartOptions,
42
+ type SyncOptions,
43
+ type UpgradeOptions,
36
44
  } from "./contract";
37
45
  import { type AppConfig, type AppOrchestrator, startApp } from "./dev-session";
38
46
  import {
@@ -982,9 +990,14 @@ export default createPlugin({
982
990
  throw error;
983
991
  }
984
992
 
985
- const verifiedConfig = await fetchBosConfigFromFastKv<BosConfig>(bosUrl);
986
- if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) {
987
- throw error;
993
+ try {
994
+ const verifiedConfig = await fetchBosConfigFromFastKv<BosConfig>(bosUrl);
995
+ if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) {
996
+ throw error;
997
+ }
998
+ } catch {
999
+ // Config may not exist yet on first publish or propagation delay;
1000
+ // a valid txHash is sufficient proof the transaction was submitted.
988
1001
  }
989
1002
  }
990
1003
 
@@ -1057,50 +1070,69 @@ export default createPlugin({
1057
1070
 
1058
1071
  init: builder.init.handler(async ({ input }: { input: InitOptions }) => {
1059
1072
  try {
1073
+ let extendsAccount = input.extendsAccount;
1074
+ let extendsGateway = input.extendsGateway;
1075
+ let directory = input.directory;
1060
1076
  let account = input.account;
1061
- let gateway = input.gateway;
1062
- let destination = input.destination;
1063
- let name = input.name;
1064
1077
  let domain = input.domain;
1065
1078
  let withHost = input.withHost;
1066
1079
 
1067
- if (!account || !gateway) {
1080
+ if (!domain) {
1068
1081
  if (input.noInteractive) {
1069
1082
  return {
1070
1083
  status: "error" as const,
1071
- destination: "",
1072
- parentAccount: account ?? "",
1073
- parentGateway: gateway ?? "",
1074
- name: input.name,
1084
+ directory: "",
1085
+ extendsAccount: extendsAccount ?? "",
1086
+ extendsGateway: extendsGateway ?? "",
1087
+ account: input.account,
1075
1088
  domain: input.domain,
1076
- extends: account && gateway ? `bos://${account}/${gateway}` : "",
1089
+ extends:
1090
+ extendsAccount && extendsGateway ? `bos://${extendsAccount}/${extendsGateway}` : "",
1077
1091
  filesCopied: 0,
1078
1092
  error:
1079
- "account and gateway are required (use --no-interactive to skip prompts and provide them as positional args)",
1093
+ "domain is required (use --no-interactive to skip prompts and provide it as a flag)",
1080
1094
  };
1081
1095
  }
1082
1096
 
1083
1097
  const prompted = await promptInitOptions({
1098
+ extendsAccount,
1099
+ extendsGateway,
1100
+ directory,
1084
1101
  account,
1085
- gateway,
1086
- destination,
1087
- name,
1088
1102
  domain,
1089
1103
  withHost,
1090
1104
  });
1105
+ extendsAccount = prompted.extendsAccount;
1106
+ extendsGateway = prompted.extendsGateway;
1107
+ directory = prompted.directory;
1091
1108
  account = prompted.account;
1092
- gateway = prompted.gateway;
1093
- destination = prompted.destination;
1094
- name = prompted.name;
1095
1109
  domain = prompted.domain;
1096
1110
  withHost = prompted.withHost;
1097
1111
  }
1098
1112
 
1099
- destination = destination || gateway;
1113
+ extendsAccount = extendsAccount || "dev.everything.near";
1114
+ extendsGateway = extendsGateway || "everything.dev";
1115
+ directory = directory || (domain ? domain.split(".")[0] : extendsGateway);
1116
+
1117
+ try {
1118
+ await fetchParentConfig(extendsAccount, extendsGateway);
1119
+ } catch {
1120
+ return {
1121
+ status: "error" as const,
1122
+ directory,
1123
+ extendsAccount,
1124
+ extendsGateway,
1125
+ account,
1126
+ domain,
1127
+ extends: `bos://${extendsAccount}/${extendsGateway}`,
1128
+ filesCopied: 0,
1129
+ error: `No config found at bos://${extendsAccount}/${extendsGateway} — are you sure this is the right parent?`,
1130
+ };
1131
+ }
1100
1132
 
1101
1133
  const { sourceDir, cleanup } = await resolveSourceDir({
1102
- account,
1103
- gateway,
1134
+ extendsAccount,
1135
+ extendsGateway,
1104
1136
  source: input.source,
1105
1137
  });
1106
1138
 
@@ -1109,41 +1141,45 @@ export default createPlugin({
1109
1141
  if (patterns.length === 0) {
1110
1142
  return {
1111
1143
  status: "error" as const,
1112
- destination,
1113
- parentAccount: account,
1114
- parentGateway: gateway,
1115
- name,
1144
+ directory,
1145
+ extendsAccount,
1146
+ extendsGateway,
1147
+ account,
1116
1148
  domain,
1117
- extends: `bos://${account}/${gateway}`,
1149
+ extends: `bos://${extendsAccount}/${extendsGateway}`,
1118
1150
  filesCopied: 0,
1119
1151
  error: "No .templatekeep found in template source",
1120
1152
  };
1121
1153
  }
1122
1154
 
1123
- const filesCopied = await copyFilteredFiles(sourceDir, destination, patterns, {
1155
+ const filesCopied = await copyFilteredFiles(sourceDir, directory, patterns, {
1124
1156
  withHost,
1125
1157
  });
1126
1158
 
1127
- await personalizeConfig(destination, {
1128
- parentAccount: account,
1129
- parentGateway: gateway,
1130
- name: name || account,
1131
- domain: domain || gateway,
1159
+ await personalizeConfig(directory, {
1160
+ extendsAccount,
1161
+ extendsGateway,
1162
+ account: account || extendsAccount,
1163
+ domain: domain || extendsGateway,
1132
1164
  workspaceOpts: { sourceDir },
1133
1165
  });
1134
1166
 
1167
+ await writeInitSnapshot(directory, extendsAccount, extendsGateway, sourceDir, patterns, {
1168
+ withHost,
1169
+ });
1170
+
1135
1171
  if (!input.noInstall) {
1136
- await runBunInstall(destination);
1172
+ await runBunInstall(directory);
1137
1173
  }
1138
1174
 
1139
1175
  return {
1140
1176
  status: "initialized" as const,
1141
- destination: resolve(destination),
1142
- parentAccount: account,
1143
- parentGateway: gateway,
1144
- name,
1177
+ directory: resolve(directory),
1178
+ extendsAccount,
1179
+ extendsGateway,
1180
+ account,
1145
1181
  domain,
1146
- extends: `bos://${account}/${gateway}`,
1182
+ extends: `bos://${extendsAccount}/${extendsGateway}`,
1147
1183
  filesCopied,
1148
1184
  };
1149
1185
  } finally {
@@ -1152,17 +1188,92 @@ export default createPlugin({
1152
1188
  } catch (error) {
1153
1189
  return {
1154
1190
  status: "error" as const,
1155
- destination: input.destination ?? input.gateway ?? "",
1156
- parentAccount: input.account ?? "",
1157
- parentGateway: input.gateway ?? "",
1158
- name: input.name,
1191
+ directory: input.directory ?? "",
1192
+ extendsAccount: input.extendsAccount ?? "",
1193
+ extendsGateway: input.extendsGateway ?? "",
1194
+ account: input.account,
1159
1195
  domain: input.domain,
1160
- extends: input.account && input.gateway ? `bos://${input.account}/${input.gateway}` : "",
1196
+ extends:
1197
+ input.extendsAccount && input.extendsGateway
1198
+ ? `bos://${input.extendsAccount}/${input.extendsGateway}`
1199
+ : "",
1161
1200
  filesCopied: 0,
1162
1201
  error: error instanceof Error ? error.message : "Unknown error",
1163
1202
  };
1164
1203
  }
1165
1204
  }),
1205
+
1206
+ sync: builder.sync.handler(async ({ input }: { input: SyncOptions }) => {
1207
+ try {
1208
+ const configPath = findConfigPath();
1209
+ if (!configPath) {
1210
+ return {
1211
+ status: "error" as const,
1212
+ updated: [],
1213
+ skipped: [],
1214
+ added: [],
1215
+ error: "No bos.config.json found in current directory",
1216
+ };
1217
+ }
1218
+
1219
+ const projectDir = resolve(dirname(configPath));
1220
+ return await syncTemplate(projectDir, input);
1221
+ } catch (error) {
1222
+ return {
1223
+ status: "error" as const,
1224
+ updated: [],
1225
+ skipped: [],
1226
+ added: [],
1227
+ error: error instanceof Error ? error.message : "Unknown error",
1228
+ };
1229
+ }
1230
+ }),
1231
+
1232
+ upgrade: builder.upgrade.handler(async ({ input }: { input: UpgradeOptions }) => {
1233
+ try {
1234
+ const configPath = findConfigPath();
1235
+ if (!configPath) {
1236
+ return {
1237
+ status: "error" as const,
1238
+ packages: [],
1239
+ error: "No bos.config.json found in current directory",
1240
+ };
1241
+ }
1242
+
1243
+ const projectDir = resolve(dirname(configPath));
1244
+ return await upgradeTemplate(projectDir, input);
1245
+ } catch (error) {
1246
+ return {
1247
+ status: "error" as const,
1248
+ packages: [],
1249
+ error: error instanceof Error ? error.message : "Unknown error",
1250
+ };
1251
+ }
1252
+ }),
1253
+
1254
+ status: builder.status.handler(async () => {
1255
+ try {
1256
+ const configPath = findConfigPath();
1257
+ if (!configPath) {
1258
+ return {
1259
+ status: "error" as const,
1260
+ packages: [],
1261
+ envFile: "missing" as const,
1262
+ error: "No bos.config.json found in current directory",
1263
+ };
1264
+ }
1265
+
1266
+ const projectDir = resolve(dirname(configPath));
1267
+ return await getStatus(projectDir);
1268
+ } catch (error) {
1269
+ return {
1270
+ status: "error" as const,
1271
+ packages: [],
1272
+ envFile: "missing" as const,
1273
+ error: error instanceof Error ? error.message : "Unknown error",
1274
+ };
1275
+ }
1276
+ }),
1166
1277
  }),
1167
1278
  });
1168
1279
 
@@ -10,6 +10,7 @@ export const colors = {
10
10
  magenta: chalk.hex("#ff00ff"),
11
11
  green: chalk.hex("#00ff41"),
12
12
  blue: chalk.hex("#0080ff"),
13
+ yellow: chalk.hex("#ffcc00"),
13
14
  white: chalk.hex("#f0f0f0"),
14
15
  gray: chalk.hex("#555555"),
15
16
  dim: chalk.dim,