runcloud 0.1.98 → 0.1.100

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,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
2
2
  import { basename, join, resolve } from 'node:path';
3
3
  import { ApiClient, ApiError, friendlyApiError } from '../api.js';
4
- import { requireCredentials, writeEnvironmentSelection, writeProjectLink } from '../config.js';
4
+ import { controlPlaneUrl, requireCredentials, writeEnvironmentSelection, writeProjectLink, } from '../config.js';
5
5
  import { runEnvironmentDeploy } from './deploy.js';
6
6
  const POLL_INTERVAL_MS = 2_000;
7
7
  const POLL_TIMEOUT_MS = 20 * 60 * 1_000;
@@ -121,7 +121,7 @@ export function registerCreate(program) {
121
121
  throw new Error('This directory is already linked to a project. Use a fresh directory for `newly create`.');
122
122
  }
123
123
  const creds = requireCredentials();
124
- await runCreate(new ApiClient(creds.apiUrl, creds.token), process.cwd(), {
124
+ await runCreate(new ApiClient(controlPlaneUrl(creds), creds.token), process.cwd(), {
125
125
  name,
126
126
  deploy: opts.deploy,
127
127
  });
@@ -1,12 +1,12 @@
1
1
  import { createInterface } from 'node:readline/promises';
2
2
  import { ApiClient, friendlyApiError } from '../api.js';
3
3
  import { runEnvironmentDatabaseShell } from '../shellSession.js';
4
- import { clearEnvironmentSelection, readEnvironmentSelection, requireCredentials, requireEnvironmentSelection, resolveProject, writeEnvironmentSelection, } from '../config.js';
4
+ import { clearEnvironmentSelection, readEnvironmentSelection, controlPlaneUrl, requireCredentials, requireEnvironmentSelection, resolveProject, writeEnvironmentSelection, } from '../config.js';
5
5
  const POLL_INTERVAL_MS = 2_000;
6
6
  const POLL_TIMEOUT_MS = 10 * 60 * 1_000;
7
7
  function client() {
8
8
  const credentials = requireCredentials();
9
- return new ApiClient(credentials.apiUrl, credentials.token);
9
+ return new ApiClient(controlPlaneUrl(credentials), credentials.token);
10
10
  }
11
11
  async function projectEnvironments(api, projectId) {
12
12
  const response = await api.get(`/projects/${encodeURIComponent(projectId)}/environments`);
@@ -248,7 +248,7 @@ export function registerEnvironment(program) {
248
248
  const projectId = resolveProject(process.cwd(), opts.project);
249
249
  const selected = requireEnvironmentSelection(process.cwd(), projectId);
250
250
  const credentials = requireCredentials();
251
- const environment = await new ApiClient(credentials.apiUrl, credentials.token).get(`/environments/${encodeURIComponent(selected.id)}`);
251
+ const environment = await new ApiClient(controlPlaneUrl(credentials), credentials.token).get(`/environments/${encodeURIComponent(selected.id)}`);
252
252
  const resource = resolveNamedResource(environment.databases, value, 'database');
253
253
  if (resource.status !== 'ready')
254
254
  throw new Error(`Database is not ready (${resource.status}).`);
@@ -94,8 +94,9 @@ function hostLabel() {
94
94
  }
95
95
  }
96
96
  export async function verifyRunCloudCredential(apiUrl, token) {
97
+ const probe = token.startsWith('nl_live_') ? '/auth/mobile/identity' : '/run-cloud/account';
97
98
  try {
98
- await new ApiClient(normalizeApiUrl(apiUrl), token).get('/run-cloud/account');
99
+ await new ApiClient(normalizeApiUrl(apiUrl), token).get(probe);
99
100
  }
100
101
  catch (e) {
101
102
  if (e instanceof ApiError && (e.status === 401 || e.status === 403)) {
package/dist/config.js CHANGED
@@ -33,6 +33,9 @@ export function loginCommandName() {
33
33
  export function normalizeApiUrl(url) {
34
34
  return url.replace(/\/+$/, '');
35
35
  }
36
+ export function controlPlaneUrl(creds) {
37
+ return normalizeApiUrl(creds.authApiUrl ?? creds.apiUrl);
38
+ }
36
39
  export function saveCredentials(creds) {
37
40
  mkdirSync(credentialsHome(), { recursive: true, mode: 0o700 });
38
41
  const normalized = { ...creds, apiUrl: normalizeApiUrl(creds.apiUrl) };
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = '0.1.98';
1
+ export const CLI_VERSION = '0.1.100';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcloud",
3
- "version": "0.1.98",
3
+ "version": "0.1.100",
4
4
  "description": "Create and control run.cloud remote mobile simulators and cloud sandboxes",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [