@lukoweb/apitogo 0.1.139 → 0.1.140
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/cli.js
CHANGED
|
@@ -5809,7 +5809,7 @@ import {
|
|
|
5809
5809
|
// package.json
|
|
5810
5810
|
var package_default = {
|
|
5811
5811
|
name: "@lukoweb/apitogo",
|
|
5812
|
-
version: "0.1.
|
|
5812
|
+
version: "0.1.140",
|
|
5813
5813
|
type: "module",
|
|
5814
5814
|
sideEffects: [
|
|
5815
5815
|
"**/*.css",
|
|
@@ -19048,6 +19048,20 @@ async function isBackendDeploymentHealthy(client, projectId) {
|
|
|
19048
19048
|
return summary.lastDeploymentStatus?.toLowerCase() === "healthy";
|
|
19049
19049
|
}
|
|
19050
19050
|
|
|
19051
|
+
// src/cli/platform/helpers/project-name.ts
|
|
19052
|
+
function normalizeProjectName(name) {
|
|
19053
|
+
return name.trim().split(/\s+/).filter(Boolean).join(" ").toLowerCase();
|
|
19054
|
+
}
|
|
19055
|
+
function findProjectByNormalizedName(projects, name) {
|
|
19056
|
+
const needle = normalizeProjectName(name);
|
|
19057
|
+
if (!needle) {
|
|
19058
|
+
return void 0;
|
|
19059
|
+
}
|
|
19060
|
+
return projects.find(
|
|
19061
|
+
(project) => normalizeProjectName(project.name) === needle
|
|
19062
|
+
);
|
|
19063
|
+
}
|
|
19064
|
+
|
|
19051
19065
|
// src/cli/platform/helpers/platform-plan.ts
|
|
19052
19066
|
var UNSELECTED_TIER = "unselected";
|
|
19053
19067
|
var FREE_TIER = "free";
|
|
@@ -19120,20 +19134,6 @@ function parseToolJsonResult(result) {
|
|
|
19120
19134
|
}
|
|
19121
19135
|
}
|
|
19122
19136
|
|
|
19123
|
-
// src/cli/platform/helpers/project-name.ts
|
|
19124
|
-
function normalizeProjectName(name) {
|
|
19125
|
-
return name.trim().split(/\s+/).filter(Boolean).join(" ").toLowerCase();
|
|
19126
|
-
}
|
|
19127
|
-
function findProjectByNormalizedName(projects, name) {
|
|
19128
|
-
const needle = normalizeProjectName(name);
|
|
19129
|
-
if (!needle) {
|
|
19130
|
-
return void 0;
|
|
19131
|
-
}
|
|
19132
|
-
return projects.find(
|
|
19133
|
-
(project) => normalizeProjectName(project.name) === needle
|
|
19134
|
-
);
|
|
19135
|
-
}
|
|
19136
|
-
|
|
19137
19137
|
// src/cli/platform/helpers/platform-plan-catalog.ts
|
|
19138
19138
|
var PLATFORM_PLAN_CATALOG = [
|
|
19139
19139
|
{
|
|
@@ -20155,6 +20155,27 @@ async function resolveProjectIdForPublish(client, config2, args, wait, progress,
|
|
|
20155
20155
|
if (!args.projectName?.trim()) {
|
|
20156
20156
|
throw new Error("projectName is required when projectId is not provided.");
|
|
20157
20157
|
}
|
|
20158
|
+
if (!args.reuseExistingByName) {
|
|
20159
|
+
const projectName = args.projectName.trim();
|
|
20160
|
+
const existing = findProjectByNormalizedName(
|
|
20161
|
+
await client.listProjects(),
|
|
20162
|
+
projectName
|
|
20163
|
+
);
|
|
20164
|
+
if (existing) {
|
|
20165
|
+
return {
|
|
20166
|
+
blocked: true,
|
|
20167
|
+
payload: {
|
|
20168
|
+
status: "blocked",
|
|
20169
|
+
reason: "project_name_exists",
|
|
20170
|
+
projectId: existing.id,
|
|
20171
|
+
projectName,
|
|
20172
|
+
userMessage: `The config has no projectId, but a project named "${projectName}" already exists on your account.`,
|
|
20173
|
+
nextStep: "reuse_or_rename_project",
|
|
20174
|
+
hint: "Re-run with a different --project-name to create a new project, or set projectId in the config to deploy to the existing one."
|
|
20175
|
+
}
|
|
20176
|
+
};
|
|
20177
|
+
}
|
|
20178
|
+
}
|
|
20158
20179
|
await progress?.onStep("Creating project and provisioning modules");
|
|
20159
20180
|
const bootstrapJson = await handleBootstrapProject(
|
|
20160
20181
|
client,
|
|
@@ -21108,7 +21129,8 @@ async function runApplyFromSiteDirectory(client, config2, args, progress) {
|
|
|
21108
21129
|
config2,
|
|
21109
21130
|
{
|
|
21110
21131
|
projectId: args.createNewProject ? void 0 : args.projectId ?? manifest.projectId,
|
|
21111
|
-
projectName: args.projectName ?? resolveProjectDisplayName(manifest)
|
|
21132
|
+
projectName: args.projectName ?? resolveProjectDisplayName(manifest),
|
|
21133
|
+
reuseExistingByName: args.reuseExistingProject
|
|
21112
21134
|
},
|
|
21113
21135
|
wait,
|
|
21114
21136
|
publishProgress,
|
|
@@ -21983,6 +22005,16 @@ function formatBlockedOrFailedResultForHuman(parsed) {
|
|
|
21983
22005
|
);
|
|
21984
22006
|
return lines;
|
|
21985
22007
|
}
|
|
22008
|
+
if (status2 === "blocked" && parsed.reason === "project_name_exists") {
|
|
22009
|
+
const projectId = typeof parsed.projectId === "string" ? parsed.projectId : void 0;
|
|
22010
|
+
return [
|
|
22011
|
+
typeof parsed.userMessage === "string" ? parsed.userMessage : "Deploy is blocked: a project with this name already exists.",
|
|
22012
|
+
"",
|
|
22013
|
+
"To fix this:",
|
|
22014
|
+
` Deploy to the existing project: set "projectId"${projectId ? ` to "${projectId}"` : ""} in apitogo.config.json`,
|
|
22015
|
+
" Or create a new project: re-run `apitogo deploy --project-name <new-name>`"
|
|
22016
|
+
];
|
|
22017
|
+
}
|
|
21986
22018
|
if (status2 === "blocked" && parsed.reason === "project_not_found") {
|
|
21987
22019
|
const projectId = typeof parsed.projectId === "string" ? parsed.projectId : void 0;
|
|
21988
22020
|
const lines = [
|
|
@@ -22226,6 +22258,34 @@ async function resolveProjectNotFoundInteractively(payload, defaultProjectName)
|
|
|
22226
22258
|
rl.close();
|
|
22227
22259
|
}
|
|
22228
22260
|
}
|
|
22261
|
+
async function resolveProjectNameExistsInteractively(payload, defaultProjectName) {
|
|
22262
|
+
const existingName = typeof payload.projectName === "string" ? payload.projectName : defaultProjectName;
|
|
22263
|
+
const projectId = typeof payload.projectId === "string" ? payload.projectId : "";
|
|
22264
|
+
printWarningToConsole(
|
|
22265
|
+
`This site has no projectId, but a project named "${existingName}"${projectId ? ` (${projectId})` : ""} already exists on your account.`
|
|
22266
|
+
);
|
|
22267
|
+
printDiagnosticsToConsole("");
|
|
22268
|
+
const rl = createInterface3({ input: input4, output: output3 });
|
|
22269
|
+
try {
|
|
22270
|
+
const choice = (await rl.question(
|
|
22271
|
+
"[c] Create a new project [u] Use the existing project [x] Cancel (default c): "
|
|
22272
|
+
)).trim().toLowerCase();
|
|
22273
|
+
if (choice === "x" || choice === "cancel") {
|
|
22274
|
+
return null;
|
|
22275
|
+
}
|
|
22276
|
+
if (choice === "u" || choice === "use") {
|
|
22277
|
+
return { action: "reuse" };
|
|
22278
|
+
}
|
|
22279
|
+
for (; ; ) {
|
|
22280
|
+
const nameAnswer = (await rl.question("New project name: ")).trim();
|
|
22281
|
+
if (nameAnswer) {
|
|
22282
|
+
return { action: "create", projectName: nameAnswer };
|
|
22283
|
+
}
|
|
22284
|
+
}
|
|
22285
|
+
} finally {
|
|
22286
|
+
rl.close();
|
|
22287
|
+
}
|
|
22288
|
+
}
|
|
22229
22289
|
|
|
22230
22290
|
// src/cli/apply/handler.ts
|
|
22231
22291
|
function normalizeOnly(only) {
|
|
@@ -22277,6 +22337,7 @@ async function apply(argv) {
|
|
|
22277
22337
|
let effectiveProjectId = argv.projectId?.trim();
|
|
22278
22338
|
let effectiveProjectName = argv.projectName?.trim();
|
|
22279
22339
|
let createNewProject = false;
|
|
22340
|
+
let reuseExistingProject = false;
|
|
22280
22341
|
const runOnce = (plan) => runApplyFromSiteDirectory(
|
|
22281
22342
|
client,
|
|
22282
22343
|
config2,
|
|
@@ -22289,7 +22350,8 @@ async function apply(argv) {
|
|
|
22289
22350
|
force: argv.force,
|
|
22290
22351
|
resumeFromStep: argv.resumeFrom?.trim(),
|
|
22291
22352
|
wait: argv.wait !== false,
|
|
22292
|
-
createNewProject
|
|
22353
|
+
createNewProject,
|
|
22354
|
+
reuseExistingProject
|
|
22293
22355
|
},
|
|
22294
22356
|
progress
|
|
22295
22357
|
);
|
|
@@ -22324,6 +22386,30 @@ async function apply(argv) {
|
|
|
22324
22386
|
parsed = safeParseResult(result);
|
|
22325
22387
|
}
|
|
22326
22388
|
}
|
|
22389
|
+
while (canPromptInteractively && parsed?.status === "blocked" && parsed.reason === "project_name_exists") {
|
|
22390
|
+
const resolution = await resolveProjectNameExistsInteractively(
|
|
22391
|
+
parsed,
|
|
22392
|
+
effectiveProjectName ?? path63.basename(sourceDirectory)
|
|
22393
|
+
);
|
|
22394
|
+
if (!resolution) {
|
|
22395
|
+
break;
|
|
22396
|
+
}
|
|
22397
|
+
if (resolution.action === "reuse") {
|
|
22398
|
+
reuseExistingProject = true;
|
|
22399
|
+
} else {
|
|
22400
|
+
effectiveProjectName = resolution.projectName;
|
|
22401
|
+
createNewProject = true;
|
|
22402
|
+
}
|
|
22403
|
+
try {
|
|
22404
|
+
result = await runOnce(platformPlan);
|
|
22405
|
+
} catch (error) {
|
|
22406
|
+
await printCriticalFailureToConsoleAndExit(
|
|
22407
|
+
error instanceof Error ? error.message : String(error)
|
|
22408
|
+
);
|
|
22409
|
+
return;
|
|
22410
|
+
}
|
|
22411
|
+
parsed = safeParseResult(result);
|
|
22412
|
+
}
|
|
22327
22413
|
if (canPromptInteractively && parsed?.status === "blocked" && parsed.reason === "platform_plan_unselected") {
|
|
22328
22414
|
const blockedProjectId = typeof parsed.projectId === "string" ? parsed.projectId : void 0;
|
|
22329
22415
|
const resolved = await resolvePlatformPlanInteractively(
|
|
@@ -27,4 +27,5 @@ export type ResolveProjectIdResult = {
|
|
|
27
27
|
export declare function resolveProjectIdForPublish(client: PlatformApiClient, config: ApitogoConfig, args: {
|
|
28
28
|
projectId?: string;
|
|
29
29
|
projectName?: string;
|
|
30
|
+
reuseExistingByName?: boolean;
|
|
30
31
|
}, wait: boolean, progress?: ProgressReporter, timeoutMs?: number, pollIntervalMs?: number): Promise<ResolveProjectIdResult>;
|
|
@@ -24,6 +24,7 @@ export interface PublishDevPortalArgs {
|
|
|
24
24
|
force?: boolean;
|
|
25
25
|
resumeFromStep?: PublishStepId;
|
|
26
26
|
createNewProject?: boolean;
|
|
27
|
+
reuseExistingProject?: boolean;
|
|
27
28
|
}
|
|
28
29
|
export type ApplyFromSiteDirectoryArgs = PublishDevPortalArgs;
|
|
29
30
|
export declare function validateManifestForPublish(manifest: DevPortalLocalManifest, secrets: DevPortalLocalSecrets, emailOptions?: {
|