@temps-sdk/cli 0.1.22 → 0.1.23
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 +171 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -75980,6 +75980,23 @@ async function createNewServiceOfType(serviceType) {
|
|
|
75980
75980
|
}
|
|
75981
75981
|
|
|
75982
75982
|
// src/commands/projects/create.ts
|
|
75983
|
+
var MANUAL_SOURCE_TYPES = [
|
|
75984
|
+
{
|
|
75985
|
+
value: "manual",
|
|
75986
|
+
name: "Flexible (Recommended)",
|
|
75987
|
+
description: "Deploy via Docker images, static files, or Git - switch anytime"
|
|
75988
|
+
},
|
|
75989
|
+
{
|
|
75990
|
+
value: "docker_image",
|
|
75991
|
+
name: "Docker Image Only",
|
|
75992
|
+
description: "Locked to Docker image deployments only"
|
|
75993
|
+
},
|
|
75994
|
+
{
|
|
75995
|
+
value: "static_files",
|
|
75996
|
+
name: "Static Files Only",
|
|
75997
|
+
description: "Locked to static file deployments only"
|
|
75998
|
+
}
|
|
75999
|
+
];
|
|
75983
76000
|
async function create(options) {
|
|
75984
76001
|
await requireAuth();
|
|
75985
76002
|
await setupClient();
|
|
@@ -75988,6 +76005,43 @@ async function create(options) {
|
|
|
75988
76005
|
console.log(colors.bold(`${icons.sparkles} Create New Project`));
|
|
75989
76006
|
console.log(colors.muted("─".repeat(40)));
|
|
75990
76007
|
newline();
|
|
76008
|
+
const manualRequested = options.manual === true || options.sourceType !== undefined || options.image !== undefined || options.port !== undefined;
|
|
76009
|
+
let manualSourceType;
|
|
76010
|
+
if (manualRequested) {
|
|
76011
|
+
if (options.sourceType) {
|
|
76012
|
+
const match = MANUAL_SOURCE_TYPES.find((t) => t.value === options.sourceType);
|
|
76013
|
+
if (!match) {
|
|
76014
|
+
error(`Invalid --source-type "${options.sourceType}". Use one of: ${MANUAL_SOURCE_TYPES.map((t) => t.value).join(", ")}`);
|
|
76015
|
+
return;
|
|
76016
|
+
}
|
|
76017
|
+
manualSourceType = match.value;
|
|
76018
|
+
} else {
|
|
76019
|
+
manualSourceType = "manual";
|
|
76020
|
+
}
|
|
76021
|
+
} else if (!skipPrompts && !options.repo && !options.connection) {
|
|
76022
|
+
const choice = await promptSelect({
|
|
76023
|
+
message: "How do you want to deploy this project?",
|
|
76024
|
+
choices: [
|
|
76025
|
+
{
|
|
76026
|
+
name: "Git Repository",
|
|
76027
|
+
value: "git",
|
|
76028
|
+
description: "Connect a repo - builds and deploys on every push"
|
|
76029
|
+
},
|
|
76030
|
+
...MANUAL_SOURCE_TYPES.map((t) => ({
|
|
76031
|
+
name: t.name,
|
|
76032
|
+
value: t.value,
|
|
76033
|
+
description: t.description
|
|
76034
|
+
}))
|
|
76035
|
+
]
|
|
76036
|
+
});
|
|
76037
|
+
if (choice !== "git") {
|
|
76038
|
+
manualSourceType = choice;
|
|
76039
|
+
}
|
|
76040
|
+
}
|
|
76041
|
+
if (manualSourceType) {
|
|
76042
|
+
await createManualProject(options, manualSourceType, skipPrompts);
|
|
76043
|
+
return;
|
|
76044
|
+
}
|
|
75991
76045
|
try {
|
|
75992
76046
|
let connection;
|
|
75993
76047
|
if (options.connection) {
|
|
@@ -76132,6 +76186,122 @@ async function create(options) {
|
|
|
76132
76186
|
error(getErrorMessage(err));
|
|
76133
76187
|
}
|
|
76134
76188
|
}
|
|
76189
|
+
async function createManualProject(options, sourceType, skipPrompts) {
|
|
76190
|
+
const methodMeta = MANUAL_SOURCE_TYPES.find((t) => t.value === sourceType);
|
|
76191
|
+
info(`Deployment method: ${methodMeta.name}`);
|
|
76192
|
+
try {
|
|
76193
|
+
let projectName;
|
|
76194
|
+
if (options.name) {
|
|
76195
|
+
projectName = options.name;
|
|
76196
|
+
info(`Using project name: ${projectName}`);
|
|
76197
|
+
} else if (skipPrompts) {
|
|
76198
|
+
error("Project name is required. Pass --name when using --yes.");
|
|
76199
|
+
return;
|
|
76200
|
+
} else {
|
|
76201
|
+
newline();
|
|
76202
|
+
projectName = await promptText({
|
|
76203
|
+
message: "Project name",
|
|
76204
|
+
required: true,
|
|
76205
|
+
validate: (v) => v.length >= 2 ? true : "Name must be at least 2 characters"
|
|
76206
|
+
});
|
|
76207
|
+
}
|
|
76208
|
+
let dockerImage;
|
|
76209
|
+
if (sourceType === "manual" || sourceType === "docker_image") {
|
|
76210
|
+
if (options.image) {
|
|
76211
|
+
dockerImage = options.image;
|
|
76212
|
+
info(`Using Docker image: ${dockerImage}`);
|
|
76213
|
+
} else if (!skipPrompts) {
|
|
76214
|
+
const entered = await promptText({
|
|
76215
|
+
message: "Docker image (optional, e.g. nginx:latest or ghcr.io/org/image:tag)",
|
|
76216
|
+
required: false
|
|
76217
|
+
});
|
|
76218
|
+
dockerImage = entered.trim() || undefined;
|
|
76219
|
+
}
|
|
76220
|
+
}
|
|
76221
|
+
let port;
|
|
76222
|
+
if (options.port) {
|
|
76223
|
+
const parsed = parseInt(options.port, 10);
|
|
76224
|
+
if (isNaN(parsed) || parsed < 1 || parsed > 65535) {
|
|
76225
|
+
error(`Invalid --port "${options.port}". Must be a number between 1 and 65535.`);
|
|
76226
|
+
return;
|
|
76227
|
+
}
|
|
76228
|
+
port = parsed;
|
|
76229
|
+
info(`Using port: ${port}`);
|
|
76230
|
+
} else if (skipPrompts) {
|
|
76231
|
+
port = 3000;
|
|
76232
|
+
} else {
|
|
76233
|
+
port = await promptNumber(sourceType === "docker_image" ? "Container port" : "Application port", { default: 3000, min: 1, max: 65535 });
|
|
76234
|
+
}
|
|
76235
|
+
const serviceIds = skipPrompts ? [] : await selectStorageServices();
|
|
76236
|
+
const envVars = skipPrompts ? [] : await configureEnvironmentVariables();
|
|
76237
|
+
const projectType = sourceType === "static_files" ? "static" : "docker";
|
|
76238
|
+
const project = await withSpinner("Creating project...", async () => {
|
|
76239
|
+
const { data, error: apiError } = await createProject({
|
|
76240
|
+
client,
|
|
76241
|
+
body: {
|
|
76242
|
+
name: projectName,
|
|
76243
|
+
preset: "dockerfile",
|
|
76244
|
+
directory: "./",
|
|
76245
|
+
main_branch: "main",
|
|
76246
|
+
source_type: sourceType,
|
|
76247
|
+
project_type: projectType,
|
|
76248
|
+
automatic_deploy: false,
|
|
76249
|
+
exposed_port: port,
|
|
76250
|
+
storage_service_ids: serviceIds,
|
|
76251
|
+
environment_variables: envVars.length > 0 ? envVars : undefined
|
|
76252
|
+
}
|
|
76253
|
+
});
|
|
76254
|
+
if (apiError || !data) {
|
|
76255
|
+
throw new Error(getErrorMessage(apiError) || "Failed to create project");
|
|
76256
|
+
}
|
|
76257
|
+
return data;
|
|
76258
|
+
});
|
|
76259
|
+
newline();
|
|
76260
|
+
header(`${icons.check} Project Created Successfully`);
|
|
76261
|
+
newline();
|
|
76262
|
+
keyValue("ID", project.id);
|
|
76263
|
+
keyValue("Name", project.name);
|
|
76264
|
+
keyValue("Slug", project.slug);
|
|
76265
|
+
keyValue("Deployment Method", methodMeta.name);
|
|
76266
|
+
if (dockerImage) {
|
|
76267
|
+
keyValue("Docker Image", `${dockerImage} ${colors.muted("(deploy with the command below)")}`);
|
|
76268
|
+
}
|
|
76269
|
+
keyValue("Port", port);
|
|
76270
|
+
if (serviceIds.length > 0) {
|
|
76271
|
+
keyValue("Services", `${serviceIds.length} linked`);
|
|
76272
|
+
}
|
|
76273
|
+
if (envVars.length > 0) {
|
|
76274
|
+
keyValue("Environment Variables", `${envVars.length} configured`);
|
|
76275
|
+
}
|
|
76276
|
+
newline();
|
|
76277
|
+
if (skipPrompts) {
|
|
76278
|
+
config.set("defaultProject", project.slug);
|
|
76279
|
+
success(`Default project set to "${project.slug}"`);
|
|
76280
|
+
} else {
|
|
76281
|
+
const setDefault = await promptConfirm({
|
|
76282
|
+
message: "Set as default project?",
|
|
76283
|
+
default: true
|
|
76284
|
+
});
|
|
76285
|
+
if (setDefault) {
|
|
76286
|
+
config.set("defaultProject", project.slug);
|
|
76287
|
+
success(`Default project set to "${project.slug}"`);
|
|
76288
|
+
}
|
|
76289
|
+
}
|
|
76290
|
+
newline();
|
|
76291
|
+
info(`View your project: temps projects show ${project.slug}`);
|
|
76292
|
+
if (sourceType === "static_files") {
|
|
76293
|
+
info(`Deploy static files: temps deploy:static -p ${project.slug} --path <path>`);
|
|
76294
|
+
} else {
|
|
76295
|
+
const imageHint = dockerImage ?? "<image>";
|
|
76296
|
+
info(`Deploy a Docker image: temps deploy:image -p ${project.slug} --image ${imageHint}`);
|
|
76297
|
+
if (sourceType === "manual") {
|
|
76298
|
+
info(`Or deploy static files: temps deploy:static -p ${project.slug} --path <path>`);
|
|
76299
|
+
}
|
|
76300
|
+
}
|
|
76301
|
+
} catch (err) {
|
|
76302
|
+
error(getErrorMessage(err));
|
|
76303
|
+
}
|
|
76304
|
+
}
|
|
76135
76305
|
async function configureProjectName(repository, directory) {
|
|
76136
76306
|
let defaultName = repository.name;
|
|
76137
76307
|
if (directory && directory !== "./" && directory !== "." && directory !== "root") {
|
|
@@ -76774,7 +76944,7 @@ async function updateConfigAction(options) {
|
|
|
76774
76944
|
function registerProjectsCommands(program2) {
|
|
76775
76945
|
const projects = program2.command("projects").alias("project").alias("p").description("Manage projects");
|
|
76776
76946
|
projects.command("list").alias("ls").description("List all projects").option("--json", "Output in JSON format").option("--page <n>", "Page number").option("--per-page <n>", "Items per page").action(list);
|
|
76777
|
-
projects.command("create").alias("new").description("Create a new project").option("-n, --name <name>", "Project name").option("-d, --description <description>", "Project description").option("--repo <repository>", "Repository in owner/name format").option("--branch <branch>", "Git branch").option("--directory <directory>", "Root directory (relative to repo)").option("--preset <preset>", "Build preset (e.g., nextjs, nodejs, static, docker)").option("--connection <id>", "Git connection ID").option("-y, --yes", "Skip optional prompts (services, env vars, set-default)").action(create);
|
|
76947
|
+
projects.command("create").alias("new").description("Create a new project (git-based or manual deployment)").option("-n, --name <name>", "Project name").option("-d, --description <description>", "Project description").option("--repo <repository>", "Repository in owner/name format").option("--branch <branch>", "Git branch").option("--directory <directory>", "Root directory (relative to repo)").option("--preset <preset>", "Build preset (e.g., nextjs, nodejs, static, docker)").option("--connection <id>", "Git connection ID").option("--manual", "Create a manual (non-git) project - deploy via Docker image or static files").option("--source-type <type>", "Manual deployment method: manual (flexible), docker_image, or static_files").option("--image <image>", "Docker image for the first deployment (manual mode)").option("--port <port>", "Application/container port (manual mode, default: 3000)").option("-y, --yes", "Skip optional prompts (services, env vars, set-default)").action(create);
|
|
76778
76948
|
projects.command("show").alias("get").description("Show project details").option("-p, --project <project>", "Project slug or ID").option("--json", "Output in JSON format").action(show);
|
|
76779
76949
|
projects.command("update").alias("edit").description("Update project name and description").option("-p, --project <project>", "Project slug or ID").option("-n, --name <name>", "New project name").option("-d, --description <description>", "New project description").option("--json", "Output in JSON format").option("-y, --yes", "Skip prompts, use provided values (for automation)").action(updateProjectAction);
|
|
76780
76950
|
projects.command("settings").description("Update project settings (slug, attack mode, preview environments)").option("-p, --project <project>", "Project slug or ID").option("--slug <slug>", "Project URL slug").option("--attack-mode", "Enable attack mode (CAPTCHA protection)").option("--no-attack-mode", "Disable attack mode").option("--preview-envs", "Enable preview environments").option("--no-preview-envs", "Disable preview environments").option("--json", "Output in JSON format").option("-y, --yes", "Skip prompts (for automation)").action(updateSettingsAction);
|