@absolutejs/absolute 0.19.0-beta.672 → 0.19.0-beta.674

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/index.js CHANGED
@@ -210,34 +210,46 @@ var init_telemetryEvent = __esm(() => {
210
210
 
211
211
  // src/utils/loadConfig.ts
212
212
  import { resolve } from "path";
213
- var isObject = (value) => typeof value === "object" && value !== null, isCommandService = (service) => service.kind === "command" || Array.isArray(service.command), projectServiceConfig = (config, serviceName) => {
214
- const service = config.services?.[serviceName];
213
+ var RESERVED_TOP_LEVEL_KEYS, isObject = (value) => typeof value === "object" && value !== null, isCommandService = (service) => service.kind === "command" || Array.isArray(service.command), isServiceCandidate = (value) => isObject(value) && (typeof value.entry === "string" || Array.isArray(value.command)), isWorkspaceConfig = (config) => {
214
+ if (!isObject(config)) {
215
+ return false;
216
+ }
217
+ const entries = Object.entries(config);
218
+ if (entries.length === 0) {
219
+ return false;
220
+ }
221
+ if (entries.some(([key]) => RESERVED_TOP_LEVEL_KEYS.has(key))) {
222
+ return false;
223
+ }
224
+ return entries.every(([, value]) => isServiceCandidate(value));
225
+ }, getWorkspaceServices = (config) => {
226
+ if (!isWorkspaceConfig(config)) {
227
+ throw new Error("absolute.config.ts is not a multi-service config. Define top-level named services with `entry` or `command` before using `absolute workspace dev`.");
228
+ }
229
+ return config;
230
+ }, projectServiceConfig = (config, serviceName) => {
231
+ const services = getWorkspaceServices(config);
232
+ const service = services[serviceName];
215
233
  if (!service) {
216
- throw new Error(`Config file does not define services.${serviceName}.`);
234
+ throw new Error(`Config file does not define service "${serviceName}".`);
217
235
  }
218
236
  if (isCommandService(service)) {
219
- throw new Error(`services.${serviceName} is a command service and cannot be loaded as an AbsoluteJS app config.`);
237
+ throw new Error(`Service "${serviceName}" is a command service and cannot be loaded as an AbsoluteJS app config.`);
220
238
  }
221
239
  const {
222
240
  command: _command,
223
241
  config: _config,
224
242
  cwd: _cwd,
225
243
  dependsOn: _dependsOn,
226
- entry: _entry,
227
244
  env: _env,
228
245
  healthcheck: _healthcheck,
229
246
  kind: _kind,
230
247
  port: _port,
231
- services: _nestedServices,
232
248
  visibility: _visibility,
233
249
  ...serviceConfig
234
250
  } = service;
235
- const { services: _services, ...sharedConfig } = config;
236
- return {
237
- ...sharedConfig,
238
- ...serviceConfig
239
- };
240
- }, loadConfig = async (configPath2) => {
251
+ return serviceConfig;
252
+ }, loadRawConfig = async (configPath2) => {
241
253
  const resolved = resolve(configPath2 ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
242
254
  const mod = await import(resolved);
243
255
  const config = mod.default ?? mod.config;
@@ -248,13 +260,51 @@ Expected: export default defineConfig({ ... })`);
248
260
  if (!isObject(config)) {
249
261
  throw new Error(`Config file "${resolved}" must export an object configuration.`);
250
262
  }
263
+ return config;
264
+ }, loadConfig = async (configPath2) => {
265
+ const config = await loadRawConfig(configPath2);
251
266
  const serviceName = process.env.ABSOLUTE_WORKSPACE_SERVICE_NAME;
252
267
  if (typeof serviceName === "string" && serviceName.length > 0) {
253
268
  return projectServiceConfig(config, serviceName);
254
269
  }
270
+ if (isWorkspaceConfig(config)) {
271
+ throw new Error("absolute.config.ts defines multiple services. Use `absolute workspace dev` or set ABSOLUTE_WORKSPACE_SERVICE_NAME before loading a specific service config.");
272
+ }
255
273
  return config;
256
274
  };
257
- var init_loadConfig = () => {};
275
+ var init_loadConfig = __esm(() => {
276
+ RESERVED_TOP_LEVEL_KEYS = new Set([
277
+ "assetsDirectory",
278
+ "astroDirectory",
279
+ "buildDirectory",
280
+ "command",
281
+ "config",
282
+ "cwd",
283
+ "dependsOn",
284
+ "dev",
285
+ "entry",
286
+ "env",
287
+ "healthcheck",
288
+ "htmlDirectory",
289
+ "htmxDirectory",
290
+ "images",
291
+ "incrementalFiles",
292
+ "islands",
293
+ "kind",
294
+ "mode",
295
+ "options",
296
+ "port",
297
+ "publicDirectory",
298
+ "reactDirectory",
299
+ "sitemap",
300
+ "static",
301
+ "stylesConfig",
302
+ "svelteDirectory",
303
+ "tailwind",
304
+ "visibility",
305
+ "vueDirectory"
306
+ ]);
307
+ });
258
308
 
259
309
  // src/cli/utils.ts
260
310
  var {$ } = globalThis.Bun;
@@ -1075,7 +1125,13 @@ __export(exports_typecheck, {
1075
1125
  import { resolve as resolve8, join as join7 } from "path";
1076
1126
  import { existsSync as existsSync10 } from "fs";
1077
1127
  import { mkdir as mkdir2, writeFile } from "fs/promises";
1078
- var run = async (name, command) => {
1128
+ var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), getTypecheckTargets = async (configPath2) => {
1129
+ const rawConfig = await loadRawConfig(configPath2);
1130
+ if (!isWorkspaceConfig(rawConfig)) {
1131
+ return [await loadConfig(configPath2)];
1132
+ }
1133
+ return Object.values(getWorkspaceServices(rawConfig)).filter((service) => !isCommandService3(service));
1134
+ }, run = async (name, command) => {
1079
1135
  const proc = Bun.spawn(command, {
1080
1136
  stderr: "pipe",
1081
1137
  stdout: "pipe"
@@ -1225,19 +1281,25 @@ Found ${errorCount} error${suffix}.`;
1225
1281
  "--color"
1226
1282
  ]);
1227
1283
  }, typecheck = async (configPath2) => {
1228
- const config = await loadConfig(configPath2);
1229
- const hasAngular = Boolean(config.angularDirectory);
1230
- const hasSvelte = Boolean(config.svelteDirectory);
1231
- const hasVue = Boolean(config.vueDirectory);
1284
+ const targets = await getTypecheckTargets(configPath2);
1285
+ const hasAngular = targets.some((config) => Boolean(config.angularDirectory));
1286
+ const hasSvelte = targets.some((config) => Boolean(config.svelteDirectory));
1287
+ const hasVue = targets.some((config) => Boolean(config.vueDirectory));
1288
+ const svelteDirs = [...new Set(targets.map((config) => config.svelteDirectory).filter((dir) => typeof dir === "string" && dir.length > 0))];
1289
+ const angularDirs = [...new Set(targets.map((config) => config.angularDirectory).filter((dir) => typeof dir === "string" && dir.length > 0))];
1232
1290
  const cacheDir = ".absolutejs";
1233
1291
  await mkdir2(cacheDir, { recursive: true });
1234
1292
  const checks = [];
1235
1293
  checks.push(hasVue ? buildVueTscCheck(cacheDir) : buildTscCheck(cacheDir));
1236
1294
  if (hasSvelte) {
1237
- checks.push(buildSvelteCheck(cacheDir, config.svelteDirectory ?? ""));
1295
+ for (const svelteDir of svelteDirs) {
1296
+ checks.push(buildSvelteCheck(cacheDir, svelteDir));
1297
+ }
1238
1298
  }
1239
1299
  if (hasAngular) {
1240
- checks.push(buildAngularCheck(cacheDir, config.angularDirectory ?? ""));
1300
+ for (const angularDir of angularDirs) {
1301
+ checks.push(buildAngularCheck(cacheDir, angularDir));
1302
+ }
1241
1303
  }
1242
1304
  const results = await Promise.all(checks);
1243
1305
  const failed = results.filter((res) => res.exitCode !== 0);
@@ -3000,12 +3062,6 @@ var getHealthcheckUrl = (service) => {
3000
3062
  }
3001
3063
  return;
3002
3064
  };
3003
- var ensureServicesConfig = (config) => {
3004
- if (!config.services || Object.keys(config.services).length === 0) {
3005
- throw new Error("absolute.config.ts is missing services. Add a services section before using `absolute workspace dev`.");
3006
- }
3007
- return config.services;
3008
- };
3009
3065
  var resolveHealthcheck = (healthcheck) => {
3010
3066
  if (!healthcheck) {
3011
3067
  return null;
@@ -3153,8 +3209,8 @@ var workspace = async (subcommand, options) => {
3153
3209
  if (subcommand !== "dev") {
3154
3210
  throw new Error(subcommand ? `Unknown workspace command: ${subcommand}` : "No workspace subcommand specified. Use `absolute workspace dev`.");
3155
3211
  }
3156
- const config = await loadConfig(options.configPath);
3157
- const services = ensureServicesConfig(config);
3212
+ const config = await loadRawConfig(options.configPath);
3213
+ const services = getWorkspaceServices(config);
3158
3214
  const orderedNames = topologicallySortServices(services);
3159
3215
  const running = [];
3160
3216
  const serviceBootStartedAt = new Map;
package/dist/index.js CHANGED
@@ -181925,37 +181925,83 @@ import { Elysia as Elysia5 } from "elysia";
181925
181925
 
181926
181926
  // src/utils/loadConfig.ts
181927
181927
  import { resolve as resolve6 } from "path";
181928
+ var RESERVED_TOP_LEVEL_KEYS = new Set([
181929
+ "assetsDirectory",
181930
+ "astroDirectory",
181931
+ "buildDirectory",
181932
+ "command",
181933
+ "config",
181934
+ "cwd",
181935
+ "dependsOn",
181936
+ "dev",
181937
+ "entry",
181938
+ "env",
181939
+ "healthcheck",
181940
+ "htmlDirectory",
181941
+ "htmxDirectory",
181942
+ "images",
181943
+ "incrementalFiles",
181944
+ "islands",
181945
+ "kind",
181946
+ "mode",
181947
+ "options",
181948
+ "port",
181949
+ "publicDirectory",
181950
+ "reactDirectory",
181951
+ "sitemap",
181952
+ "static",
181953
+ "stylesConfig",
181954
+ "svelteDirectory",
181955
+ "tailwind",
181956
+ "visibility",
181957
+ "vueDirectory"
181958
+ ]);
181928
181959
  var isObject = (value) => typeof value === "object" && value !== null;
181929
181960
  var isCommandService = (service) => service.kind === "command" || Array.isArray(service.command);
181961
+ var isServiceCandidate = (value) => isObject(value) && (typeof value.entry === "string" || Array.isArray(value.command));
181962
+ var isWorkspaceConfig = (config) => {
181963
+ if (!isObject(config)) {
181964
+ return false;
181965
+ }
181966
+ const entries = Object.entries(config);
181967
+ if (entries.length === 0) {
181968
+ return false;
181969
+ }
181970
+ if (entries.some(([key]) => RESERVED_TOP_LEVEL_KEYS.has(key))) {
181971
+ return false;
181972
+ }
181973
+ return entries.every(([, value]) => isServiceCandidate(value));
181974
+ };
181975
+ var getWorkspaceServices = (config) => {
181976
+ if (!isWorkspaceConfig(config)) {
181977
+ throw new Error("absolute.config.ts is not a multi-service config. Define top-level named services with `entry` or `command` before using `absolute workspace dev`.");
181978
+ }
181979
+ return config;
181980
+ };
181930
181981
  var projectServiceConfig = (config, serviceName) => {
181931
- const service = config.services?.[serviceName];
181982
+ const services = getWorkspaceServices(config);
181983
+ const service = services[serviceName];
181932
181984
  if (!service) {
181933
- throw new Error(`Config file does not define services.${serviceName}.`);
181985
+ throw new Error(`Config file does not define service "${serviceName}".`);
181934
181986
  }
181935
181987
  if (isCommandService(service)) {
181936
- throw new Error(`services.${serviceName} is a command service and cannot be loaded as an AbsoluteJS app config.`);
181988
+ throw new Error(`Service "${serviceName}" is a command service and cannot be loaded as an AbsoluteJS app config.`);
181937
181989
  }
181938
181990
  const {
181939
181991
  command: _command,
181940
181992
  config: _config,
181941
181993
  cwd: _cwd,
181942
181994
  dependsOn: _dependsOn,
181943
- entry: _entry,
181944
181995
  env: _env,
181945
181996
  healthcheck: _healthcheck,
181946
181997
  kind: _kind,
181947
181998
  port: _port,
181948
- services: _nestedServices,
181949
181999
  visibility: _visibility,
181950
182000
  ...serviceConfig
181951
182001
  } = service;
181952
- const { services: _services, ...sharedConfig } = config;
181953
- return {
181954
- ...sharedConfig,
181955
- ...serviceConfig
181956
- };
182002
+ return serviceConfig;
181957
182003
  };
181958
- var loadConfig = async (configPath) => {
182004
+ var loadRawConfig = async (configPath) => {
181959
182005
  const resolved = resolve6(configPath ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
181960
182006
  const mod = await import(resolved);
181961
182007
  const config = mod.default ?? mod.config;
@@ -181966,10 +182012,17 @@ Expected: export default defineConfig({ ... })`);
181966
182012
  if (!isObject(config)) {
181967
182013
  throw new Error(`Config file "${resolved}" must export an object configuration.`);
181968
182014
  }
182015
+ return config;
182016
+ };
182017
+ var loadConfig = async (configPath) => {
182018
+ const config = await loadRawConfig(configPath);
181969
182019
  const serviceName = process.env.ABSOLUTE_WORKSPACE_SERVICE_NAME;
181970
182020
  if (typeof serviceName === "string" && serviceName.length > 0) {
181971
182021
  return projectServiceConfig(config, serviceName);
181972
182022
  }
182023
+ if (isWorkspaceConfig(config)) {
182024
+ throw new Error("absolute.config.ts defines multiple services. Use `absolute workspace dev` or set ABSOLUTE_WORKSPACE_SERVICE_NAME before loading a specific service config.");
182025
+ }
181973
182026
  return config;
181974
182027
  };
181975
182028
 
@@ -188845,5 +188898,5 @@ export {
188845
188898
  ANGULAR_INIT_TIMEOUT_MS
188846
188899
  };
188847
188900
 
188848
- //# debugId=4B9F0A17F5EB81CB64756E2164756E21
188901
+ //# debugId=98967D2F4839D93264756E2164756E21
188849
188902
  //# sourceMappingURL=index.js.map