@get-dx/cli 0.5.4 → 0.5.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.
- package/dist/cli.js +0 -2
- package/dist/config.js +0 -58
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10,11 +10,9 @@ import { workflowRunsCommand } from "./commands/workflowRuns.js";
|
|
|
10
10
|
import { workflowsCommand } from "./commands/workflows.js";
|
|
11
11
|
import { handleError } from "./commandHelpers.js";
|
|
12
12
|
import cliPackage from "../package.json" with { type: "json" };
|
|
13
|
-
import { handleTemporaryBaseUrlMigration } from "./config.js";
|
|
14
13
|
import { checkForNewVersion, performUpdate, promptVersionUpdate, } from "./versionCheck.js";
|
|
15
14
|
export async function run(argv = process.argv) {
|
|
16
15
|
try {
|
|
17
|
-
handleTemporaryBaseUrlMigration(argv);
|
|
18
16
|
const program = createProgram();
|
|
19
17
|
if (argv.length <= 2) {
|
|
20
18
|
program.outputHelp();
|
package/dist/config.js
CHANGED
|
@@ -45,64 +45,6 @@ export function persistVersionPromptSelection(prompt) {
|
|
|
45
45
|
}
|
|
46
46
|
writeConfig(config);
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Responsible for handling the migration from `baseUrl` to `apiBaseUrl` and `webBaseUrl`,
|
|
50
|
-
* so the upgrade to 0.3.x will be non-breaking for `cloud` and `dedicated` deployments.
|
|
51
|
-
*
|
|
52
|
-
* `managed` deployments will encounter an error and will have to reauthenticate.
|
|
53
|
-
*
|
|
54
|
-
* TODO: delete after 2026-07-01.
|
|
55
|
-
*/
|
|
56
|
-
export function handleTemporaryBaseUrlMigration(argv) {
|
|
57
|
-
if (!process.env.VITEST) {
|
|
58
|
-
// Running tests - we don't want our permanent tests to exercise this logic
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const COMMANDS_TO_SKIP_MIGRATION = ["login", "logout", "init"];
|
|
62
|
-
if (COMMANDS_TO_SKIP_MIGRATION.some((command) => argv.includes(command))) {
|
|
63
|
-
// Logging in or logging out: we need to ignore the current config file's contents
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const configPath = getConfigPath();
|
|
67
|
-
if (!fs.existsSync(configPath)) {
|
|
68
|
-
// No config file, no need to migrate
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const content = fs.readFileSync(configPath, "utf8");
|
|
72
|
-
const raw = JSON.parse(content);
|
|
73
|
-
const api = raw.apiBaseUrl;
|
|
74
|
-
const web = raw.webBaseUrl;
|
|
75
|
-
if (api !== undefined && web !== undefined) {
|
|
76
|
-
// Already migrated, no need to do anything
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (raw.baseUrl) {
|
|
80
|
-
// Legacy baseUrl is present, migrate to apiBaseUrl and webBaseUrl
|
|
81
|
-
const apiBaseUrl = raw.baseUrl;
|
|
82
|
-
let webBaseUrl;
|
|
83
|
-
if (apiBaseUrl.endsWith(".getdx.com")) {
|
|
84
|
-
// Migrate `cloud`
|
|
85
|
-
webBaseUrl = "https://app.getdx.com";
|
|
86
|
-
writeConfig({
|
|
87
|
-
apiBaseUrl: normalizeUrl(apiBaseUrl),
|
|
88
|
-
webBaseUrl: normalizeUrl(webBaseUrl),
|
|
89
|
-
});
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const dedicatedMatch = apiBaseUrl.match(/^api\.(.+)\.getdx\.io$/);
|
|
93
|
-
if (dedicatedMatch) {
|
|
94
|
-
// Migrate `dedicated`
|
|
95
|
-
webBaseUrl = `https://${dedicatedMatch[1]}.getdx.io`;
|
|
96
|
-
writeConfig({
|
|
97
|
-
apiBaseUrl: normalizeUrl(apiBaseUrl),
|
|
98
|
-
webBaseUrl: normalizeUrl(webBaseUrl),
|
|
99
|
-
});
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
// Unable to automatically migrate `managed`
|
|
103
|
-
throw new CliError("Your on-disk DX CLI config is missing apiBaseUrl and webBaseUrl. Run `dx auth logout`, then login again via `dx init` or `dx auth login`.");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
48
|
export function writeConfig(config) {
|
|
107
49
|
fs.mkdirSync(getConfigDir(), { recursive: true });
|
|
108
50
|
fs.writeFileSync(getConfigPath(), JSON.stringify(config, null, 2) + "\n", "utf8");
|