hereya-cli 0.100.3 → 0.100.5

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.
@@ -1,3 +1,5 @@
1
+ import { getCurrentBackendType } from '../backend/config.js';
2
+ import { BackendType, getBackend } from '../backend/index.js';
1
3
  import { InfrastructureType } from '../infrastructure/common.js';
2
4
  import { resolvePackage } from '../lib/package/index.js';
3
5
  export class DelegatingExecutor {
@@ -36,7 +38,33 @@ export class DelegatingExecutor {
36
38
  if (pkg.startsWith('local/')) {
37
39
  return this.localExecutor;
38
40
  }
39
- // Resolve package to check infra type
41
+ // Cloud-backend short-circuit: read `infra` from the registry rather than
42
+ // cloning the package repo just to discover the infra type. This avoids
43
+ // requiring GitHub credentials on the user's local machine when the remote
44
+ // executor will handle all package fetching and provisioning server-side.
45
+ try {
46
+ const backendType = await getCurrentBackendType();
47
+ if (backendType === BackendType.Cloud) {
48
+ const backend = await getBackend();
49
+ const { packageName, version } = parsePackageSpec(pkg);
50
+ let registryResult;
51
+ if (version && backend.getPackageByVersion) {
52
+ registryResult = await backend.getPackageByVersion(packageName, version);
53
+ }
54
+ else if (backend.getPackageLatest) {
55
+ registryResult = await backend.getPackageLatest(packageName);
56
+ }
57
+ if (registryResult?.success) {
58
+ return registryResult.package.infra === InfrastructureType.local
59
+ ? this.localExecutor
60
+ : this.remoteExecutor;
61
+ }
62
+ }
63
+ }
64
+ catch {
65
+ // Fall through to legacy resolvePackage path on any failure
66
+ }
67
+ // Fallback: resolve package metadata via the legacy code path.
40
68
  try {
41
69
  const resolved = await resolvePackage({
42
70
  package: pkg,
@@ -52,3 +80,13 @@ export class DelegatingExecutor {
52
80
  return this.localExecutor;
53
81
  }
54
82
  }
83
+ // Parse package spec into name and version (mirrors the helper in
84
+ // `src/lib/package/index.ts`). `latest` is treated as no version.
85
+ function parsePackageSpec(spec) {
86
+ const match = spec.match(/^([^@]+)(?:@(.+))?$/);
87
+ if (!match) {
88
+ return { packageName: spec };
89
+ }
90
+ const [, packageName, version] = match;
91
+ return { packageName, version: version === 'latest' ? undefined : version };
92
+ }