@adkit/cli 1.13.24 → 1.13.25
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 +53 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -162,7 +162,7 @@ function parseArgs(argv, options) {
|
|
|
162
162
|
} else {
|
|
163
163
|
key = arg.slice(2);
|
|
164
164
|
const next = argv[i + 1];
|
|
165
|
-
if (next && !next.startsWith("--")) {
|
|
165
|
+
if (next !== void 0 && !next.startsWith("--")) {
|
|
166
166
|
value = next;
|
|
167
167
|
i++;
|
|
168
168
|
} else value = true;
|
|
@@ -1227,6 +1227,12 @@ async function createProject(client, options) {
|
|
|
1227
1227
|
current: true
|
|
1228
1228
|
};
|
|
1229
1229
|
}
|
|
1230
|
+
async function updateProject(client, projectId, update) {
|
|
1231
|
+
const encodedProjectId = encodeURIComponent(projectId);
|
|
1232
|
+
const response = await client.patch(`/manage/projects/${encodedProjectId}`, update);
|
|
1233
|
+
if (!isUpdateProjectResponse(response)) throw new Error("Unexpected response from AdKit project update");
|
|
1234
|
+
return response.project;
|
|
1235
|
+
}
|
|
1230
1236
|
async function listProjects(client, options = {}) {
|
|
1231
1237
|
const qs = queryString({ query: options.query, limit: options.limit });
|
|
1232
1238
|
const response = await client.get(`/manage/projects${qs}`);
|
|
@@ -1257,6 +1263,13 @@ function isCreateProjectResponse(value) {
|
|
|
1257
1263
|
if (!("name" in value) || typeof value.name !== "string") return false;
|
|
1258
1264
|
return !("website" in value) || typeof value.website === "string";
|
|
1259
1265
|
}
|
|
1266
|
+
function isUpdateProjectResponse(value) {
|
|
1267
|
+
if (!value || typeof value !== "object" || !("project" in value)) return false;
|
|
1268
|
+
const project = value.project;
|
|
1269
|
+
if (!project || typeof project !== "object") return false;
|
|
1270
|
+
if (!("projectId" in project) || typeof project.projectId !== "string") return false;
|
|
1271
|
+
return "name" in project && typeof project.name === "string";
|
|
1272
|
+
}
|
|
1260
1273
|
function mapProjectEntry(project, selectedProject) {
|
|
1261
1274
|
const entry = {
|
|
1262
1275
|
id: project.projectId,
|
|
@@ -4822,7 +4835,7 @@ Commands:
|
|
|
4822
4835
|
library Browse ads and advertisers
|
|
4823
4836
|
studio Create and manage Studio ads
|
|
4824
4837
|
manage Manage ad platforms and drafts
|
|
4825
|
-
projects Manage projects (list, create, use, current)
|
|
4838
|
+
projects Manage projects (list, create, update, use, current)
|
|
4826
4839
|
|
|
4827
4840
|
Advanced:
|
|
4828
4841
|
logout Remove stored API key
|
|
@@ -7036,23 +7049,28 @@ Examples:
|
|
|
7036
7049
|
|
|
7037
7050
|
list List accessible projects
|
|
7038
7051
|
create Create a project and make it active
|
|
7052
|
+
update <id> Update a project
|
|
7039
7053
|
use <id> Switch active project
|
|
7040
7054
|
current Show active project
|
|
7041
7055
|
|
|
7042
7056
|
Flags:
|
|
7043
7057
|
--query <text> Filter projects by name or website
|
|
7044
7058
|
--limit <n> Max results (default: 20, max: 50)
|
|
7045
|
-
--name <text> Project or business name (create)
|
|
7046
|
-
--website <url> Project website URL or domain (create)
|
|
7059
|
+
--name <text> Project or business name (create/update)
|
|
7060
|
+
--website <url> Project website URL or domain (create/update)
|
|
7047
7061
|
--workspace <id> Target workspace ID (create)
|
|
7048
|
-
--description <t>
|
|
7049
|
-
--industry <text>
|
|
7050
|
-
--category <text>
|
|
7051
|
-
--tags <a,b>
|
|
7062
|
+
--description <t> Business description (create/update)
|
|
7063
|
+
--industry <text> Business industry (create/update)
|
|
7064
|
+
--category <text> Business category (create/update)
|
|
7065
|
+
--tags <a,b> Tags; update replaces all tags
|
|
7066
|
+
--primary-color <hex> Primary brand color (update)
|
|
7067
|
+
--accent-color <hex> Accent brand color (update)
|
|
7068
|
+
--background-color <hex> Background brand color (update)
|
|
7052
7069
|
|
|
7053
7070
|
Examples:
|
|
7054
7071
|
adkit projects list
|
|
7055
7072
|
adkit projects create --name "Acme" --website acme.com
|
|
7073
|
+
adkit projects update proj_abc123 --name "Acme Inc." --primary-color "#7c3aed"
|
|
7056
7074
|
adkit projects use proj_abc123`.trim()
|
|
7057
7075
|
};
|
|
7058
7076
|
var STUDIO_GENERATE_HELP_FULL = `adkit studio generate \u2014 Create ad images with AI
|
|
@@ -9086,6 +9104,32 @@ ${pageInfo}`);
|
|
|
9086
9104
|
else console.log(`Created and selected project: ${project.name} (${project.id})`);
|
|
9087
9105
|
break;
|
|
9088
9106
|
}
|
|
9107
|
+
case "update": {
|
|
9108
|
+
validateFlags(flags, ["name", "website", "description", "industry", "category", "tags", "primary-color", "accent-color", "background-color"], "projects update");
|
|
9109
|
+
const projectId = args[2];
|
|
9110
|
+
if (!projectId) throw new CliError("MISSING_ARGUMENT", "Missing required argument: `<project-id>`", "Run: adkit projects update <project-id> [flags]");
|
|
9111
|
+
const update = {};
|
|
9112
|
+
if (typeof flags.name === "string") update.name = flags.name;
|
|
9113
|
+
if (typeof flags.website === "string") update.website = flags.website;
|
|
9114
|
+
const descriptionValues = collectFlagValues(flags, "description");
|
|
9115
|
+
if (descriptionValues.length > 0) update.description = descriptionValues.join(" ");
|
|
9116
|
+
if (typeof flags.industry === "string") update.industry = flags.industry;
|
|
9117
|
+
if (typeof flags.category === "string") update.category = flags.category;
|
|
9118
|
+
if (typeof flags.tags === "string") {
|
|
9119
|
+
const tagParts = flags.tags.split(",");
|
|
9120
|
+
const trimmedTags = tagParts.map((tag) => tag.trim());
|
|
9121
|
+
update.tags = trimmedTags.filter(Boolean);
|
|
9122
|
+
}
|
|
9123
|
+
const colors = {};
|
|
9124
|
+
if (typeof flags["primary-color"] === "string") colors.primary = flags["primary-color"];
|
|
9125
|
+
if (typeof flags["accent-color"] === "string") colors.accent = flags["accent-color"];
|
|
9126
|
+
if (typeof flags["background-color"] === "string") colors.background = flags["background-color"];
|
|
9127
|
+
if (Object.keys(colors).length > 0) update.brand = { colors };
|
|
9128
|
+
const project = await updateProject(client, projectId, update);
|
|
9129
|
+
if (wantsJson(flags)) printResult(project, flags);
|
|
9130
|
+
else console.log(`Updated project: ${project.name} (${project.projectId})`);
|
|
9131
|
+
break;
|
|
9132
|
+
}
|
|
9089
9133
|
case "use": {
|
|
9090
9134
|
const projectId = args[2];
|
|
9091
9135
|
if (!projectId) throw new CliError("MISSING_ARGUMENT", "Missing required argument: `<project-id>`", "Run: adkit projects use <project-id>");
|
|
@@ -9094,7 +9138,7 @@ ${pageInfo}`);
|
|
|
9094
9138
|
break;
|
|
9095
9139
|
}
|
|
9096
9140
|
default:
|
|
9097
|
-
throw new CliError("UNKNOWN_COMMAND", `Unknown action: projects ${action}`, "Available: list, create, use, current");
|
|
9141
|
+
throw new CliError("UNKNOWN_COMMAND", `Unknown action: projects ${action}`, "Available: list, create, update, use, current");
|
|
9098
9142
|
}
|
|
9099
9143
|
return;
|
|
9100
9144
|
}
|
package/package.json
CHANGED