@temps-sdk/cli 0.1.11 → 0.1.12
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/index.js +39 -41
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -85913,6 +85913,20 @@ function parseSetPairs(pairs) {
|
|
|
85913
85913
|
function collectSet(value, previous) {
|
|
85914
85914
|
return previous.concat([value]);
|
|
85915
85915
|
}
|
|
85916
|
+
async function resolveProjectId(flagValue) {
|
|
85917
|
+
const resolved = await requireProjectSlug(flagValue);
|
|
85918
|
+
if (resolved.source !== "flag") {
|
|
85919
|
+
info(`Using project ${colors.bold(resolved.slug)} (from ${resolved.source})`);
|
|
85920
|
+
}
|
|
85921
|
+
const { data, error: error3 } = await getProjectBySlug({
|
|
85922
|
+
client,
|
|
85923
|
+
path: { slug: resolved.slug }
|
|
85924
|
+
});
|
|
85925
|
+
if (error3 || !data) {
|
|
85926
|
+
throw new Error(`Project "${resolved.slug}" not found`);
|
|
85927
|
+
}
|
|
85928
|
+
return { id: data.id, slug: resolved.slug };
|
|
85929
|
+
}
|
|
85916
85930
|
function registerServicesCommands(program2) {
|
|
85917
85931
|
const services = program2.command("services").alias("svc").description("Manage external services (databases, caches, storage)");
|
|
85918
85932
|
services.command("list").alias("ls").description("List all external services").option("--json", "Output in JSON format").action(listServicesAction);
|
|
@@ -85927,10 +85941,10 @@ function registerServicesCommands(program2) {
|
|
|
85927
85941
|
services.command("update").description("Update a service").requiredOption("--id <id>", "Service ID").option("-n, --name <name>", "Docker image name (e.g., postgres:18-alpine)").option("-s, --set <key=value>", "Set a parameter (repeatable)", collectSet, []).action(updateServiceAction);
|
|
85928
85942
|
services.command("upgrade").description("Upgrade a service to a newer version").requiredOption("--id <id>", "Service ID").option("-v, --version <version>", "Docker image to upgrade to (e.g., postgres:18-alpine)").action(upgradeServiceAction);
|
|
85929
85943
|
services.command("import").description("Import an existing external service").option("-t, --type <type>", "Service type (postgres, mongodb, redis, s3)").option("-n, --name <name>", "Service name").option("--container-id <id>", "Container ID or name to import").option("-s, --set <key=value>", "Set a parameter (repeatable)", collectSet, []).option("--version <version>", "Optional version override").option("-y, --yes", "Skip confirmation prompts (for automation)").action(importServiceAction);
|
|
85930
|
-
services.command("link").description("Link a service to a project").requiredOption("--id <id>", "Service ID").
|
|
85931
|
-
services.command("unlink").description("Unlink a service from a project").requiredOption("--id <id>", "Service ID").
|
|
85932
|
-
services.command("env").description("Show environment variables for a linked service").requiredOption("--id <id>", "Service ID").
|
|
85933
|
-
services.command("env-var").description("Get a specific environment variable").requiredOption("--id <id>", "Service ID").
|
|
85944
|
+
services.command("link").description("Link a service to a project").requiredOption("--id <id>", "Service ID").option("-p, --project <slug>", "Project slug (auto-detected from .temps/config.json)").action(linkServiceAction);
|
|
85945
|
+
services.command("unlink").description("Unlink a service from a project").requiredOption("--id <id>", "Service ID").option("-p, --project <slug>", "Project slug (auto-detected from .temps/config.json)").option("-f, --force", "Skip confirmation").option("-y, --yes", "Skip confirmation prompts (alias for --force)").action(unlinkServiceAction);
|
|
85946
|
+
services.command("env").description("Show environment variables for a linked service").requiredOption("--id <id>", "Service ID").option("-p, --project <slug>", "Project slug (auto-detected from .temps/config.json)").option("--json", "Output in JSON format").action(envAction);
|
|
85947
|
+
services.command("env-var").description("Get a specific environment variable").requiredOption("--id <id>", "Service ID").option("-p, --project <slug>", "Project slug (auto-detected from .temps/config.json)").requiredOption("--var <name>", "Environment variable name").option("--json", "Output in JSON format").action(envVarAction);
|
|
85934
85948
|
}
|
|
85935
85949
|
async function listServicesAction(options) {
|
|
85936
85950
|
await requireAuth();
|
|
@@ -86477,24 +86491,20 @@ async function linkServiceAction(options) {
|
|
|
86477
86491
|
warning("Invalid service ID");
|
|
86478
86492
|
return;
|
|
86479
86493
|
}
|
|
86480
|
-
const
|
|
86481
|
-
|
|
86482
|
-
warning("Invalid project ID");
|
|
86483
|
-
return;
|
|
86484
|
-
}
|
|
86485
|
-
await withSpinner("Linking service to project...", async () => {
|
|
86494
|
+
const project = await resolveProjectId(options.project);
|
|
86495
|
+
await withSpinner(`Linking service to project ${colors.bold(project.slug)}...`, async () => {
|
|
86486
86496
|
const { error: error3 } = await linkServiceToProject({
|
|
86487
86497
|
client,
|
|
86488
86498
|
path: { id },
|
|
86489
86499
|
body: {
|
|
86490
|
-
project_id:
|
|
86500
|
+
project_id: project.id
|
|
86491
86501
|
}
|
|
86492
86502
|
});
|
|
86493
86503
|
if (error3) {
|
|
86494
86504
|
throw new Error(getErrorMessage(error3));
|
|
86495
86505
|
}
|
|
86496
86506
|
});
|
|
86497
|
-
success(`Service ${options.id} linked to project ${
|
|
86507
|
+
success(`Service ${options.id} linked to project ${project.slug}`);
|
|
86498
86508
|
}
|
|
86499
86509
|
async function unlinkServiceAction(options) {
|
|
86500
86510
|
await requireAuth();
|
|
@@ -86504,15 +86514,11 @@ async function unlinkServiceAction(options) {
|
|
|
86504
86514
|
warning("Invalid service ID");
|
|
86505
86515
|
return;
|
|
86506
86516
|
}
|
|
86507
|
-
const
|
|
86508
|
-
if (isNaN(projectId)) {
|
|
86509
|
-
warning("Invalid project ID");
|
|
86510
|
-
return;
|
|
86511
|
-
}
|
|
86517
|
+
const project = await resolveProjectId(options.project);
|
|
86512
86518
|
const skipConfirmation = options.force || options.yes;
|
|
86513
86519
|
if (!skipConfirmation) {
|
|
86514
86520
|
const confirmed = await promptConfirm({
|
|
86515
|
-
message: `Unlink service ${options.id} from project ${
|
|
86521
|
+
message: `Unlink service ${options.id} from project ${project.slug}?`,
|
|
86516
86522
|
default: false
|
|
86517
86523
|
});
|
|
86518
86524
|
if (!confirmed) {
|
|
@@ -86520,16 +86526,16 @@ async function unlinkServiceAction(options) {
|
|
|
86520
86526
|
return;
|
|
86521
86527
|
}
|
|
86522
86528
|
}
|
|
86523
|
-
await withSpinner(
|
|
86529
|
+
await withSpinner(`Unlinking service from project ${colors.bold(project.slug)}...`, async () => {
|
|
86524
86530
|
const { error: error3 } = await unlinkServiceFromProject({
|
|
86525
86531
|
client,
|
|
86526
|
-
path: { id, project_id:
|
|
86532
|
+
path: { id, project_id: project.id }
|
|
86527
86533
|
});
|
|
86528
86534
|
if (error3) {
|
|
86529
86535
|
throw new Error(getErrorMessage(error3));
|
|
86530
86536
|
}
|
|
86531
86537
|
});
|
|
86532
|
-
success(`Service ${options.id} unlinked from project ${
|
|
86538
|
+
success(`Service ${options.id} unlinked from project ${project.slug}`);
|
|
86533
86539
|
}
|
|
86534
86540
|
async function envAction(options) {
|
|
86535
86541
|
await requireAuth();
|
|
@@ -86539,15 +86545,11 @@ async function envAction(options) {
|
|
|
86539
86545
|
warning("Invalid service ID");
|
|
86540
86546
|
return;
|
|
86541
86547
|
}
|
|
86542
|
-
const
|
|
86543
|
-
if (isNaN(projectId)) {
|
|
86544
|
-
warning("Invalid project ID");
|
|
86545
|
-
return;
|
|
86546
|
-
}
|
|
86548
|
+
const project = await resolveProjectId(options.project);
|
|
86547
86549
|
const envVars = await withSpinner("Fetching environment variables...", async () => {
|
|
86548
86550
|
const { data, error: error3 } = await getServiceEnvironmentVariables({
|
|
86549
86551
|
client,
|
|
86550
|
-
path: { id, project_id:
|
|
86552
|
+
path: { id, project_id: project.id }
|
|
86551
86553
|
});
|
|
86552
86554
|
if (error3) {
|
|
86553
86555
|
throw new Error(getErrorMessage(error3));
|
|
@@ -86579,15 +86581,11 @@ async function envVarAction(options) {
|
|
|
86579
86581
|
warning("Invalid service ID");
|
|
86580
86582
|
return;
|
|
86581
86583
|
}
|
|
86582
|
-
const
|
|
86583
|
-
if (isNaN(projectId)) {
|
|
86584
|
-
warning("Invalid project ID");
|
|
86585
|
-
return;
|
|
86586
|
-
}
|
|
86584
|
+
const project = await resolveProjectId(options.project);
|
|
86587
86585
|
const envVar = await withSpinner("Fetching environment variable...", async () => {
|
|
86588
86586
|
const { data, error: error3 } = await getServiceEnvironmentVariable({
|
|
86589
86587
|
client,
|
|
86590
|
-
path: { id, project_id:
|
|
86588
|
+
path: { id, project_id: project.id, var_name: options.var }
|
|
86591
86589
|
});
|
|
86592
86590
|
if (error3) {
|
|
86593
86591
|
throw new Error(getErrorMessage(error3));
|
|
@@ -88705,7 +88703,7 @@ async function makeRequest(method, path7, body) {
|
|
|
88705
88703
|
}
|
|
88706
88704
|
return response.json();
|
|
88707
88705
|
}
|
|
88708
|
-
async function
|
|
88706
|
+
async function resolveProjectId2(projectSlug) {
|
|
88709
88707
|
const numId = parseInt(projectSlug, 10);
|
|
88710
88708
|
if (!isNaN(numId)) {
|
|
88711
88709
|
return numId;
|
|
@@ -88733,7 +88731,7 @@ async function listTokensAction(options) {
|
|
|
88733
88731
|
info(`Using project ${colors.bold(resolved.slug)} (from ${resolved.source})`);
|
|
88734
88732
|
}
|
|
88735
88733
|
const projectId = await withSpinner("Resolving project...", async () => {
|
|
88736
|
-
return
|
|
88734
|
+
return resolveProjectId2(resolved.slug);
|
|
88737
88735
|
});
|
|
88738
88736
|
const response = await withSpinner("Fetching deployment tokens...", async () => {
|
|
88739
88737
|
return makeRequest("GET", `/projects/${projectId}/deployment-tokens`);
|
|
@@ -88771,7 +88769,7 @@ async function createTokenAction(options) {
|
|
|
88771
88769
|
info(`Using project ${colors.bold(resolved.slug)} (from ${resolved.source})`);
|
|
88772
88770
|
}
|
|
88773
88771
|
const projectId = await withSpinner("Resolving project...", async () => {
|
|
88774
|
-
return
|
|
88772
|
+
return resolveProjectId2(resolved.slug);
|
|
88775
88773
|
});
|
|
88776
88774
|
let name;
|
|
88777
88775
|
let permissions = null;
|
|
@@ -88872,7 +88870,7 @@ async function showTokenAction(options) {
|
|
|
88872
88870
|
info(`Using project ${colors.bold(resolved.slug)} (from ${resolved.source})`);
|
|
88873
88871
|
}
|
|
88874
88872
|
const projectId = await withSpinner("Resolving project...", async () => {
|
|
88875
|
-
return
|
|
88873
|
+
return resolveProjectId2(resolved.slug);
|
|
88876
88874
|
});
|
|
88877
88875
|
const tokenId = parseInt(options.id, 10);
|
|
88878
88876
|
if (isNaN(tokenId)) {
|
|
@@ -88905,7 +88903,7 @@ async function deleteTokenAction(options) {
|
|
|
88905
88903
|
info(`Using project ${colors.bold(resolved.slug)} (from ${resolved.source})`);
|
|
88906
88904
|
}
|
|
88907
88905
|
const projectId = await withSpinner("Resolving project...", async () => {
|
|
88908
|
-
return
|
|
88906
|
+
return resolveProjectId2(resolved.slug);
|
|
88909
88907
|
});
|
|
88910
88908
|
const tokenId = parseInt(options.id, 10);
|
|
88911
88909
|
if (isNaN(tokenId)) {
|
|
@@ -98120,7 +98118,7 @@ import * as path7 from "node:path";
|
|
|
98120
98118
|
init_sdk_gen();
|
|
98121
98119
|
init_prompts();
|
|
98122
98120
|
init_output();
|
|
98123
|
-
async function
|
|
98121
|
+
async function resolveProjectId3(slug) {
|
|
98124
98122
|
const { data, error: error4 } = await getProjectBySlug({
|
|
98125
98123
|
client,
|
|
98126
98124
|
path: { slug }
|
|
@@ -98136,7 +98134,7 @@ async function pull(file, options) {
|
|
|
98136
98134
|
const resolved = await requireProjectSlug(options.project);
|
|
98137
98135
|
const outputFile = file ?? ".env";
|
|
98138
98136
|
const result = await withSpinner("Fetching environment variables...", async () => {
|
|
98139
|
-
const projectId = await
|
|
98137
|
+
const projectId = await resolveProjectId3(resolved.slug);
|
|
98140
98138
|
const [varsResult, envsResult] = await Promise.all([
|
|
98141
98139
|
getEnvironmentVariables({ client, path: { project_id: projectId } }),
|
|
98142
98140
|
getEnvironments({ client, path: { project_id: projectId } })
|
|
@@ -98216,7 +98214,7 @@ async function push(file, options) {
|
|
|
98216
98214
|
}
|
|
98217
98215
|
info(`Found ${Object.keys(variables).length} variables in ${inputFile}`);
|
|
98218
98216
|
const result = await withSpinner("Fetching environments...", async () => {
|
|
98219
|
-
const projectId = await
|
|
98217
|
+
const projectId = await resolveProjectId3(resolved.slug);
|
|
98220
98218
|
const [varsResult, envsResult] = await Promise.all([
|
|
98221
98219
|
getEnvironmentVariables({ client, path: { project_id: projectId } }),
|
|
98222
98220
|
getEnvironments({ client, path: { project_id: projectId } })
|