• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

electrode-io / electrode-native / 7478

24 Oct 2025 12:58AM UTC coverage: 60.043% (-0.02%) from 60.065%
7478

push

Azure Pipelines

r0h0gg6
Merge pull request #1918 from electrode-io/cuid2-fix-2

Update yarn.lock

3821 of 7725 branches covered (49.46%)

Branch coverage included in aggregate %.

2 of 5 new or added lines in 1 file covered. (40.0%)

18 existing lines in 2 files now uncovered.

9945 of 15202 relevant lines covered (65.42%)

547.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.61
/ern-cauldron-api/src/getActiveCauldron.ts
1
import { CauldronHelper } from './CauldronHelper';
17✔
2
import { config, kax, Platform } from 'ern-core';
17✔
3
import { getCurrentSchemaVersion } from './util';
17✔
4
import semver from 'semver';
17✔
5
import { defaultCauldron } from './CauldronApiFactory';
17✔
6
import path from 'path';
17✔
7

8
// Singleton CauldronHelper
9
// Returns undefined if no Cauldron is active
10
// Throw error if Cauldron is not using the correct schema version
11
let currentCauldronHelperInstance: CauldronHelper;
12
let currentCauldronRepoInUse: string;
13
const ernPlatformUseCmdMsg = 'ern platform use <version> command';
17✔
14

15
export default async function getActiveCauldron({
16
  ignoreRequiredErnVersionMismatch,
17
  ignoreSchemaVersionMismatch,
18
  localRepoPath,
19
  throwIfNoActiveCauldron,
20
  silent,
21
}?: {
22
  ignoreRequiredErnVersionMismatch?: boolean;
23
  ignoreSchemaVersionMismatch?: boolean;
24
  localRepoPath?: string;
25
  throwIfNoActiveCauldron: true;
26
  silent?: boolean;
27
}): Promise<CauldronHelper>;
28
export default async function getActiveCauldron({
29
  ignoreRequiredErnVersionMismatch,
30
  ignoreSchemaVersionMismatch,
31
  localRepoPath,
32
  throwIfNoActiveCauldron,
33
  silent,
34
}: {
35
  ignoreRequiredErnVersionMismatch?: boolean;
36
  ignoreSchemaVersionMismatch?: boolean;
37
  localRepoPath?: string;
38
  throwIfNoActiveCauldron: false;
39
  silent?: boolean;
40
}): Promise<CauldronHelper | undefined>;
41
export default async function getActiveCauldron({
17✔
42
  ignoreRequiredErnVersionMismatch,
43
  ignoreSchemaVersionMismatch,
44
  localRepoPath,
45
  throwIfNoActiveCauldron = true,
×
46
  silent = false,
×
47
}: {
48
  ignoreRequiredErnVersionMismatch?: boolean;
49
  ignoreSchemaVersionMismatch?: boolean;
50
  localRepoPath?: string;
51
  throwIfNoActiveCauldron?: boolean;
52
  silent?: boolean;
53
} = {}): Promise<CauldronHelper | undefined> {
×
54
  const repoInUse = config.get('cauldronRepoInUse');
41✔
55
  ignoreRequiredErnVersionMismatch =
41✔
56
    ignoreRequiredErnVersionMismatch ||
123✔
57
    config.get('ignore-required-ern-version') ||
58
    process.env.ERN_IGNORE_REQUIRED_ERN_VERSION;
59
  if (!repoInUse && throwIfNoActiveCauldron) {
41!
UNCOV
60
    throw new Error('No active Cauldron');
×
61
  }
62

63
  if (repoInUse && repoInUse !== currentCauldronRepoInUse) {
41!
64
    const kaxTask = !silent
×
65
      ? kax.task(`Connecting to the Cauldron`)
×
66
      : undefined;
67
    try {
×
68
      const cauldronRepositories = config.get('cauldronRepositories');
×
69
      const cauldronRepoUrl = cauldronRepositories[repoInUse];
×
70
      const cauldronRepoBranchReResult = /#(.+)$/.exec(cauldronRepoUrl);
×
71
      const cauldronRepoUrlWithoutBranch = cauldronRepoUrl.replace(
×
72
        /#(.+)$/,
73
        '',
74
      );
75
      const cauldronCli = defaultCauldron({
×
76
        branch: cauldronRepoBranchReResult
77
          ? cauldronRepoBranchReResult[1]
×
78
          : 'master',
79
        cauldronPath: path.isAbsolute(cauldronRepoUrl)
80
          ? cauldronRepoUrl
×
81
          : localRepoPath || Platform.cauldronDirectory,
×
82
        repository: path.isAbsolute(cauldronRepoUrl)
83
          ? undefined
×
84
          : cauldronRepoUrlWithoutBranch,
85
      });
86
      currentCauldronHelperInstance = new CauldronHelper(cauldronCli);
×
87
      const schemaVersionUsedByCauldron =
88
        await currentCauldronHelperInstance.getCauldronSchemaVersion();
×
89
      const schemaVersionOfCurrentCauldronApi = getCurrentSchemaVersion();
×
90
      if (
×
91
        !ignoreSchemaVersionMismatch &&
×
92
        schemaVersionUsedByCauldron !== schemaVersionOfCurrentCauldronApi
93
      ) {
94
        if (
×
95
          semver.gt(
96
            schemaVersionUsedByCauldron,
97
            schemaVersionOfCurrentCauldronApi,
98
          )
99
        ) {
100
          throw new Error(
×
101
            `Cauldron schema version mismatch (${schemaVersionUsedByCauldron} > ${schemaVersionOfCurrentCauldronApi}).
102
              You should switch to a newer Electrode Native version that supports this Cauldron schema using ${ernPlatformUseCmdMsg}`,
103
          );
104
        } else if (
×
105
          semver.lt(
106
            schemaVersionUsedByCauldron,
107
            schemaVersionOfCurrentCauldronApi,
108
          )
109
        ) {
110
          throw new Error(
×
111
            `Cauldron schema version mismatch (${schemaVersionUsedByCauldron} < ${schemaVersionOfCurrentCauldronApi}.
112
              You can upgrade your Cauldron to the latest version using 'ern cauldron upgrade' command.
113
              You can switch to an older version of the Electrode Native which supports this Cauldron schema version using ${ernPlatformUseCmdMsg}`,
114
          );
115
        }
116
      }
117
      if (!ignoreRequiredErnVersionMismatch) {
×
118
        const requiredErnVersion =
119
          await currentCauldronHelperInstance.getConfigForKey(
×
120
            'requiredErnVersion',
121
          );
122
        if (requiredErnVersion) {
×
123
          if (!semver.satisfies(Platform.currentVersion, requiredErnVersion)) {
×
124
            throw new Error(
×
125
              `This Cauldron requires a specific version of Electrode Native to be used.
126
                You are currently using Electrode Native version ${Platform.currentVersion} which does not satisfy version requirement of ${requiredErnVersion}.
127
                You should use a version of Electrode Native that satisfies the Cauldron requirement using ${ernPlatformUseCmdMsg} or use a different Cauldron.`,
128
            );
129
          }
130
        }
131
      }
132
      currentCauldronRepoInUse = repoInUse;
×
133
    } catch (e) {
134
      if (kaxTask) {
×
135
        kaxTask.fail();
×
136
      }
137
      throw e;
×
138
    }
139
    if (kaxTask) {
×
140
      kaxTask.succeed();
×
141
    }
142
  }
143

144
  return Promise.resolve(currentCauldronHelperInstance);
41✔
145
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc