@optima-chat/ads-cli 0.6.0 → 0.8.0
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/LICENSE +21 -0
- package/dist/commands/account/check.d.ts.map +1 -1
- package/dist/commands/account/check.js +12 -62
- package/dist/commands/account/check.js.map +1 -1
- package/dist/commands/account/index.d.ts.map +1 -1
- package/dist/commands/account/index.js +2 -2
- package/dist/commands/account/index.js.map +1 -1
- package/dist/commands/account/link.d.ts +6 -0
- package/dist/commands/account/link.d.ts.map +1 -0
- package/dist/commands/account/link.js +57 -0
- package/dist/commands/account/link.js.map +1 -0
- package/dist/commands/ad/create.d.ts.map +1 -1
- package/dist/commands/ad/create.js +29 -28
- package/dist/commands/ad/create.js.map +1 -1
- package/dist/commands/ad/delete.d.ts.map +1 -1
- package/dist/commands/ad/delete.js +1 -28
- package/dist/commands/ad/delete.js.map +1 -1
- package/dist/commands/ad/info.d.ts.map +1 -1
- package/dist/commands/ad/info.js +3 -66
- package/dist/commands/ad/info.js.map +1 -1
- package/dist/commands/ad/list.d.ts.map +1 -1
- package/dist/commands/ad/list.js +1 -65
- package/dist/commands/ad/list.js.map +1 -1
- package/dist/commands/ad/update.d.ts.map +1 -1
- package/dist/commands/ad/update.js +8 -17
- package/dist/commands/ad/update.js.map +1 -1
- package/dist/commands/ad-group/create.d.ts.map +1 -1
- package/dist/commands/ad-group/create.js +1 -23
- package/dist/commands/ad-group/create.js.map +1 -1
- package/dist/commands/ad-group/delete.d.ts.map +1 -1
- package/dist/commands/ad-group/delete.js +1 -28
- package/dist/commands/ad-group/delete.js.map +1 -1
- package/dist/commands/ad-group/info.d.ts.map +1 -1
- package/dist/commands/ad-group/info.js +4 -37
- package/dist/commands/ad-group/info.js.map +1 -1
- package/dist/commands/ad-group/list.d.ts.map +1 -1
- package/dist/commands/ad-group/list.js +1 -57
- package/dist/commands/ad-group/list.js.map +1 -1
- package/dist/commands/ad-group/update.d.ts.map +1 -1
- package/dist/commands/ad-group/update.js +11 -28
- package/dist/commands/ad-group/update.js.map +1 -1
- package/dist/commands/auth/status.d.ts +0 -2
- package/dist/commands/auth/status.d.ts.map +1 -1
- package/dist/commands/auth/status.js +12 -47
- package/dist/commands/auth/status.js.map +1 -1
- package/dist/commands/campaign/create.d.ts.map +1 -1
- package/dist/commands/campaign/create.js +1 -24
- package/dist/commands/campaign/create.js.map +1 -1
- package/dist/commands/campaign/delete.d.ts.map +1 -1
- package/dist/commands/campaign/delete.js +1 -28
- package/dist/commands/campaign/delete.js.map +1 -1
- package/dist/commands/campaign/info.d.ts.map +1 -1
- package/dist/commands/campaign/info.js +3 -34
- package/dist/commands/campaign/info.js.map +1 -1
- package/dist/commands/campaign/list.d.ts.map +1 -1
- package/dist/commands/campaign/list.js +1 -46
- package/dist/commands/campaign/list.js.map +1 -1
- package/dist/commands/campaign/update.d.ts.map +1 -1
- package/dist/commands/campaign/update.js +11 -28
- package/dist/commands/campaign/update.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +16 -72
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/keyword/add.d.ts.map +1 -1
- package/dist/commands/keyword/add.js +1 -20
- package/dist/commands/keyword/add.js.map +1 -1
- package/dist/commands/keyword/delete.d.ts.map +1 -1
- package/dist/commands/keyword/delete.js +1 -28
- package/dist/commands/keyword/delete.js.map +1 -1
- package/dist/commands/keyword/list.d.ts.map +1 -1
- package/dist/commands/keyword/list.js +1 -51
- package/dist/commands/keyword/list.js.map +1 -1
- package/dist/commands/keyword/update.d.ts.map +1 -1
- package/dist/commands/keyword/update.js +10 -24
- package/dist/commands/keyword/update.js.map +1 -1
- package/dist/index.js +0 -0
- package/package.json +9 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/ad/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/ad/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,MAAM,CAAC;KACnB,MAAM,CAAC,oBAAoB,EAAE,SAAS,CAAC;KACvC,MAAM,CAAC,oBAAoB,EAAE,QAAQ,CAAC;KACtC,MAAM,CAAC,mBAAmB,EAAE,gCAAgC,CAAC;KAC7D,MAAM,CAAC,kBAAkB,EAAE,QAAQ,EAAE,KAAK,CAAC;KAC3C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE;YAC3C,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;SAC/B,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/ad/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/ad/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SA0BtB,CAAC"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* Ad Update Command - 更新广告状态
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
8
6
|
import { handleError } from '../../utils/errors.js';
|
|
9
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
@@ -12,30 +10,23 @@ export const updateCommand = new Command('update')
|
|
|
12
10
|
.requiredOption('--ad-group-id <id>', '广告组 ID')
|
|
13
11
|
.requiredOption('--ad-id <id>', '广告 ID')
|
|
14
12
|
.option('--status <status>', '状态 (ENABLED, PAUSED)')
|
|
15
|
-
.option('--json', '以 JSON 格式输出')
|
|
16
13
|
.action(async (options) => {
|
|
17
|
-
if (!options.status) {
|
|
18
|
-
console.log(chalk.red('请指定要更新的状态: --status (ENABLED, PAUSED)'));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const spinner = ora('更新广告...').start();
|
|
22
14
|
try {
|
|
15
|
+
if (!options.status) {
|
|
16
|
+
console.log(JSON.stringify({
|
|
17
|
+
error: 'missing_status',
|
|
18
|
+
message: '请指定要更新的状态: --status (ENABLED, PAUSED)'
|
|
19
|
+
}, null, 2));
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
23
22
|
const customerId = getCustomerId();
|
|
24
23
|
const client = getApiClient();
|
|
25
24
|
const result = await client.updateAd(customerId, options.adGroupId, options.adId, {
|
|
26
25
|
status: options.status,
|
|
27
26
|
});
|
|
28
|
-
|
|
29
|
-
if (options.json) {
|
|
30
|
-
console.log(JSON.stringify(result, null, 2));
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
console.log(chalk.green(`\n✅ 广告 ${options.adId} 已更新`));
|
|
34
|
-
console.log(chalk.gray(`状态: ${options.status}`));
|
|
35
|
-
}
|
|
27
|
+
console.log(JSON.stringify(result, null, 2));
|
|
36
28
|
}
|
|
37
29
|
catch (error) {
|
|
38
|
-
spinner.fail('更新失败');
|
|
39
30
|
handleError(error);
|
|
40
31
|
}
|
|
41
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/ad/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/ad/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,QAAQ,CAAC;KACrB,cAAc,CAAC,oBAAoB,EAAE,QAAQ,CAAC;KAC9C,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC;KACvC,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;KACnD,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;gBACzB,KAAK,EAAE,gBAAgB;gBACvB,OAAO,EAAE,uCAAuC;aACjD,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE;YAChF,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SAwBtB,CAAC"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* Ad Group Create Command - 创建广告组
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
8
6
|
import { handleError } from '../../utils/errors.js';
|
|
9
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
@@ -13,13 +11,10 @@ export const createCommand = new Command('create')
|
|
|
13
11
|
.requiredOption('-n, --name <name>', '广告组名称')
|
|
14
12
|
.option('--cpc-bid <amount>', 'CPC 出价(美元)', parseFloat, 1.0)
|
|
15
13
|
.option('--status <status>', '状态 (ENABLED, PAUSED)', 'ENABLED')
|
|
16
|
-
.option('--json', '以 JSON 格式输出')
|
|
17
14
|
.action(async (options) => {
|
|
18
|
-
const spinner = ora('创建广告组...').start();
|
|
19
15
|
try {
|
|
20
16
|
const customerId = getCustomerId();
|
|
21
17
|
const client = getApiClient();
|
|
22
|
-
// 转换 CPC 出价为 micros
|
|
23
18
|
const cpcBidMicros = Math.round(options.cpcBid * 1000000);
|
|
24
19
|
const result = await client.createAdGroup(customerId, {
|
|
25
20
|
name: options.name,
|
|
@@ -27,26 +22,9 @@ export const createCommand = new Command('create')
|
|
|
27
22
|
cpcBidMicros: cpcBidMicros,
|
|
28
23
|
status: options.status,
|
|
29
24
|
});
|
|
30
|
-
|
|
31
|
-
if (options.json) {
|
|
32
|
-
console.log(JSON.stringify(result, null, 2));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
console.log(chalk.green('\n✅ 广告组已创建'));
|
|
36
|
-
console.log(chalk.gray('名称:'), chalk.white(options.name));
|
|
37
|
-
console.log(chalk.gray('CPC 出价:'), chalk.white(`$${options.cpcBid}`));
|
|
38
|
-
console.log(chalk.gray('状态:'), chalk.white(options.status));
|
|
39
|
-
// 提取创建的资源名称
|
|
40
|
-
const res = result;
|
|
41
|
-
if (res?.adGroupId) {
|
|
42
|
-
console.log(chalk.gray('Ad Group ID:'), chalk.cyan(res.adGroupId));
|
|
43
|
-
console.log(chalk.gray('\n💡 下一步: 添加关键词'));
|
|
44
|
-
console.log(chalk.cyan(` google-ads keyword add --ad-group-id ${res.adGroupId} --keywords "关键词1,关键词2"`));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
25
|
+
console.log(JSON.stringify(result, null, 2));
|
|
47
26
|
}
|
|
48
27
|
catch (error) {
|
|
49
|
-
spinner.fail('创建失败');
|
|
50
28
|
handleError(error);
|
|
51
29
|
}
|
|
52
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/ad-group/create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/ad-group/create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,OAAO,CAAC;KACpB,cAAc,CAAC,oBAAoB,EAAE,SAAS,CAAC;KAC/C,cAAc,CAAC,mBAAmB,EAAE,OAAO,CAAC;KAC5C,MAAM,CAAC,oBAAoB,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,CAAC;KAC3D,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,SAAS,CAAC;KAC9D,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;QAE1D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE;YACpD,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,YAAY,EAAE,YAAY;YAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SActB,CAAC"}
|
|
@@ -2,45 +2,18 @@
|
|
|
2
2
|
* Ad Group Delete Command - 删除广告组
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
|
-
import inquirer from 'inquirer';
|
|
8
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
9
6
|
import { handleError } from '../../utils/errors.js';
|
|
10
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
11
8
|
export const deleteCommand = new Command('delete')
|
|
12
9
|
.description('删除广告组')
|
|
13
10
|
.requiredOption('--ad-group-id <id>', '广告组 ID')
|
|
14
|
-
.option('-y, --yes', '跳过确认')
|
|
15
|
-
.option('--json', '以 JSON 格式输出')
|
|
16
11
|
.action(async (options) => {
|
|
17
12
|
try {
|
|
18
13
|
const customerId = getCustomerId();
|
|
19
|
-
// 确认删除
|
|
20
|
-
if (!options.yes) {
|
|
21
|
-
const answer = await inquirer.prompt([
|
|
22
|
-
{
|
|
23
|
-
type: 'confirm',
|
|
24
|
-
name: 'confirm',
|
|
25
|
-
message: `确定要删除广告组 ${options.adGroupId} 吗?`,
|
|
26
|
-
default: false,
|
|
27
|
-
},
|
|
28
|
-
]);
|
|
29
|
-
if (!answer.confirm) {
|
|
30
|
-
console.log(chalk.yellow('已取消'));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const spinner = ora('删除广告组...').start();
|
|
35
14
|
const client = getApiClient();
|
|
36
15
|
const result = await client.deleteAdGroup(customerId, options.adGroupId);
|
|
37
|
-
|
|
38
|
-
if (options.json) {
|
|
39
|
-
console.log(JSON.stringify(result, null, 2));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
console.log(chalk.green(`\n✅ 广告组 ${options.adGroupId} 已删除`));
|
|
43
|
-
}
|
|
16
|
+
console.log(JSON.stringify(result, null, 2));
|
|
44
17
|
}
|
|
45
18
|
catch (error) {
|
|
46
19
|
handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/ad-group/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/ad-group/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,OAAO,CAAC;KACpB,cAAc,CAAC,oBAAoB,EAAE,QAAQ,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAEzE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,WAAW,SAmBpB,CAAC"}
|
|
@@ -2,55 +2,22 @@
|
|
|
2
2
|
* Ad Group Info Command - 查看广告组详情
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
8
6
|
import { handleError } from '../../utils/errors.js';
|
|
9
|
-
import { warn } from '../../utils/logger.js';
|
|
10
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
11
8
|
export const infoCommand = new Command('info')
|
|
12
9
|
.description('查看广告组详情')
|
|
13
10
|
.argument('<ad-group-id>', '广告组 ID')
|
|
14
|
-
.
|
|
15
|
-
.action(async (adGroupId, options) => {
|
|
11
|
+
.action(async (adGroupId) => {
|
|
16
12
|
try {
|
|
17
13
|
const customerId = getCustomerId();
|
|
18
14
|
const client = getApiClient();
|
|
19
|
-
const spinner = ora('正在获取广告组信息...').start();
|
|
20
15
|
const result = await client.getAdGroup(customerId, adGroupId);
|
|
21
|
-
spinner.stop();
|
|
22
16
|
if (!result) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
if (options.json) {
|
|
27
|
-
console.log(JSON.stringify(result, null, 2));
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
const adGroup = result.ad_group;
|
|
31
|
-
const campaign = result.campaign;
|
|
32
|
-
const metrics = result.metrics;
|
|
33
|
-
const statusMap = {
|
|
34
|
-
2: 'ENABLED',
|
|
35
|
-
3: 'PAUSED',
|
|
36
|
-
4: 'REMOVED',
|
|
37
|
-
};
|
|
38
|
-
console.log(chalk.cyan.bold('\n广告组详情\n'));
|
|
39
|
-
console.log(chalk.gray('ID:'), chalk.white(adGroup?.id));
|
|
40
|
-
console.log(chalk.gray('名称:'), chalk.white(adGroup?.name));
|
|
41
|
-
console.log(chalk.gray('状态:'), chalk.white(statusMap[adGroup?.status] || adGroup?.status));
|
|
42
|
-
console.log(chalk.gray('广告系列:'), chalk.white(campaign?.name));
|
|
43
|
-
console.log(chalk.gray('广告系列 ID:'), chalk.white(campaign?.id));
|
|
44
|
-
if (adGroup?.cpc_bid_micros) {
|
|
45
|
-
console.log(chalk.gray('CPC 出价:'), chalk.white(`$${(adGroup.cpc_bid_micros / 1000000).toFixed(2)}`));
|
|
46
|
-
}
|
|
47
|
-
console.log(chalk.cyan.bold('\n效果数据\n'));
|
|
48
|
-
console.log(chalk.gray('展示量:'), chalk.white(metrics?.impressions || 0));
|
|
49
|
-
console.log(chalk.gray('点击量:'), chalk.white(metrics?.clicks || 0));
|
|
50
|
-
console.log(chalk.gray('费用:'), chalk.white(`$${((metrics?.cost_micros || 0) / 1000000).toFixed(2)}`));
|
|
51
|
-
console.log(chalk.gray('转化:'), chalk.white(metrics?.conversions || 0));
|
|
52
|
-
console.log();
|
|
17
|
+
console.log(JSON.stringify({ error: 'not_found', ad_group_id: adGroupId }, null, 2));
|
|
18
|
+
process.exit(1);
|
|
53
19
|
}
|
|
20
|
+
console.log(JSON.stringify(result, null, 2));
|
|
54
21
|
}
|
|
55
22
|
catch (error) {
|
|
56
23
|
handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../../src/commands/ad-group/info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../../src/commands/ad-group/info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,SAAS,CAAC;KACtB,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC;KACnC,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;IAC1B,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAE9D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,WAAW,SAoBpB,CAAC"}
|
|
@@ -2,80 +2,24 @@
|
|
|
2
2
|
* Ad Group List Command - 列出广告组
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import Table from 'cli-table3';
|
|
7
|
-
import ora from 'ora';
|
|
8
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
9
6
|
import { handleError } from '../../utils/errors.js';
|
|
10
|
-
import { warn } from '../../utils/logger.js';
|
|
11
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
12
8
|
export const listCommand = new Command('list')
|
|
13
9
|
.description('列出广告组')
|
|
14
10
|
.option('--campaign-id <id>', '按广告系列过滤')
|
|
15
11
|
.option('--status <status>', '按状态过滤 (ENABLED/PAUSED/REMOVED)')
|
|
16
12
|
.option('--limit <number>', '限制返回数量', '100')
|
|
17
|
-
.option('--json', '以 JSON 格式输出')
|
|
18
13
|
.action(async (options) => {
|
|
19
14
|
try {
|
|
20
15
|
const customerId = getCustomerId();
|
|
21
16
|
const client = getApiClient();
|
|
22
|
-
const spinner = ora('正在获取广告组列表...').start();
|
|
23
17
|
const adGroups = await client.listAdGroups(customerId, {
|
|
24
18
|
campaignId: options.campaignId,
|
|
25
19
|
status: options.status,
|
|
26
20
|
limit: parseInt(options.limit),
|
|
27
21
|
});
|
|
28
|
-
|
|
29
|
-
if (adGroups.length === 0) {
|
|
30
|
-
warn('未找到广告组');
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (options.json) {
|
|
34
|
-
console.log(JSON.stringify(adGroups, null, 2));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const table = new Table({
|
|
38
|
-
head: [
|
|
39
|
-
chalk.cyan('ID'),
|
|
40
|
-
chalk.cyan('名称'),
|
|
41
|
-
chalk.cyan('广告系列'),
|
|
42
|
-
chalk.cyan('状态'),
|
|
43
|
-
chalk.cyan('CPC 出价'),
|
|
44
|
-
chalk.cyan('展示量'),
|
|
45
|
-
chalk.cyan('点击量'),
|
|
46
|
-
chalk.cyan('费用'),
|
|
47
|
-
],
|
|
48
|
-
colWidths: [15, 20, 20, 10, 12, 12, 10, 12],
|
|
49
|
-
});
|
|
50
|
-
adGroups.forEach((item) => {
|
|
51
|
-
const adGroup = item.ad_group;
|
|
52
|
-
const campaign = item.campaign;
|
|
53
|
-
const metrics = item.metrics;
|
|
54
|
-
const cpcBid = adGroup?.cpc_bid_micros
|
|
55
|
-
? (adGroup.cpc_bid_micros / 1000000).toFixed(2)
|
|
56
|
-
: 'N/A';
|
|
57
|
-
const cost = metrics?.cost_micros
|
|
58
|
-
? (metrics.cost_micros / 1000000).toFixed(2)
|
|
59
|
-
: '0.00';
|
|
60
|
-
const statusMap = {
|
|
61
|
-
2: 'ENABLED',
|
|
62
|
-
3: 'PAUSED',
|
|
63
|
-
4: 'REMOVED',
|
|
64
|
-
};
|
|
65
|
-
table.push([
|
|
66
|
-
adGroup?.id || 'N/A',
|
|
67
|
-
(adGroup?.name || 'N/A').substring(0, 18),
|
|
68
|
-
(campaign?.name || 'N/A').substring(0, 18),
|
|
69
|
-
statusMap[adGroup?.status] || adGroup?.status || 'N/A',
|
|
70
|
-
cpcBid,
|
|
71
|
-
metrics?.impressions || 0,
|
|
72
|
-
metrics?.clicks || 0,
|
|
73
|
-
cost,
|
|
74
|
-
]);
|
|
75
|
-
});
|
|
76
|
-
console.log('\n' + table.toString() + '\n');
|
|
77
|
-
console.log(chalk.gray(`共 ${adGroups.length} 个广告组\n`));
|
|
78
|
-
}
|
|
22
|
+
console.log(JSON.stringify(adGroups, null, 2));
|
|
79
23
|
}
|
|
80
24
|
catch (error) {
|
|
81
25
|
handleError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/ad-group/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/ad-group/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,OAAO,CAAC;KACpB,MAAM,CAAC,oBAAoB,EAAE,SAAS,CAAC;KACvC,MAAM,CAAC,mBAAmB,EAAE,gCAAgC,CAAC;KAC7D,MAAM,CAAC,kBAAkB,EAAE,QAAQ,EAAE,KAAK,CAAC;KAC3C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE;YACrD,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;SAC/B,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/ad-group/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SA8BtB,CAAC"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* Ad Group Update Command - 更新广告组
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
8
6
|
import { handleError } from '../../utils/errors.js';
|
|
9
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
@@ -13,43 +11,28 @@ export const updateCommand = new Command('update')
|
|
|
13
11
|
.option('--status <status>', '状态 (ENABLED, PAUSED)')
|
|
14
12
|
.option('--name <name>', '新名称')
|
|
15
13
|
.option('--cpc-bid <amount>', 'CPC 出价(美元)')
|
|
16
|
-
.option('--json', '以 JSON 格式输出')
|
|
17
14
|
.action(async (options) => {
|
|
18
|
-
if (!options.status && !options.name && !options.cpcBid) {
|
|
19
|
-
console.log(chalk.red('请至少指定一个要更新的字段: --status, --name, 或 --cpc-bid'));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const spinner = ora('更新广告组...').start();
|
|
23
15
|
try {
|
|
16
|
+
if (!options.status && !options.name && !options.cpcBid) {
|
|
17
|
+
console.log(JSON.stringify({
|
|
18
|
+
error: 'missing_fields',
|
|
19
|
+
message: '请至少指定一个要更新的字段: --status, --name, 或 --cpc-bid'
|
|
20
|
+
}, null, 2));
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
24
23
|
const customerId = getCustomerId();
|
|
25
24
|
const client = getApiClient();
|
|
26
25
|
const updateData = {};
|
|
27
|
-
if (options.status)
|
|
26
|
+
if (options.status)
|
|
28
27
|
updateData.status = options.status;
|
|
29
|
-
|
|
30
|
-
if (options.name) {
|
|
28
|
+
if (options.name)
|
|
31
29
|
updateData.name = options.name;
|
|
32
|
-
|
|
33
|
-
if (options.cpcBid) {
|
|
30
|
+
if (options.cpcBid)
|
|
34
31
|
updateData.cpcBidMicros = Math.round(parseFloat(options.cpcBid) * 1000000);
|
|
35
|
-
}
|
|
36
32
|
const result = await client.updateAdGroup(customerId, options.adGroupId, updateData);
|
|
37
|
-
|
|
38
|
-
if (options.json) {
|
|
39
|
-
console.log(JSON.stringify(result, null, 2));
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
console.log(chalk.green(`\n✅ 广告组 ${options.adGroupId} 已更新`));
|
|
43
|
-
if (options.status)
|
|
44
|
-
console.log(chalk.gray(`状态: ${options.status}`));
|
|
45
|
-
if (options.name)
|
|
46
|
-
console.log(chalk.gray(`名称: ${options.name}`));
|
|
47
|
-
if (options.cpcBid)
|
|
48
|
-
console.log(chalk.gray(`CPC 出价: $${options.cpcBid}`));
|
|
49
|
-
}
|
|
33
|
+
console.log(JSON.stringify(result, null, 2));
|
|
50
34
|
}
|
|
51
35
|
catch (error) {
|
|
52
|
-
spinner.fail('更新失败');
|
|
53
36
|
handleError(error);
|
|
54
37
|
}
|
|
55
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/ad-group/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/ad-group/update.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,OAAO,CAAC;KACpB,cAAc,CAAC,oBAAoB,EAAE,QAAQ,CAAC;KAC9C,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;KACnD,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC;KAC9B,MAAM,CAAC,oBAAoB,EAAE,YAAY,CAAC;KAC1C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,IAAI,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;gBACzB,KAAK,EAAE,gBAAgB;gBACvB,OAAO,EAAE,8CAA8C;aACxD,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAE9B,MAAM,UAAU,GAAQ,EAAE,CAAC;QAC3B,IAAI,OAAO,CAAC,MAAM;YAAE,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QACvD,IAAI,OAAO,CAAC,IAAI;YAAE,UAAU,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACjD,IAAI,OAAO,CAAC,MAAM;YAAE,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;QAE/F,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAErF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,eAAO,MAAM,aAAa,SAuBtB,CAAC"}
|
|
@@ -1,62 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auth Status Command - 查看认证状态
|
|
3
|
-
*
|
|
4
|
-
* 与 optima-agent 兼容
|
|
5
3
|
*/
|
|
6
4
|
import { Command } from 'commander';
|
|
7
|
-
import chalk from 'chalk';
|
|
8
|
-
import Table from 'cli-table3';
|
|
9
5
|
import { getTokenData, isTokenExpired } from '../../lib/token-store.js';
|
|
10
6
|
export const statusCommand = new Command('status')
|
|
11
7
|
.description('查看认证状态')
|
|
12
|
-
.
|
|
13
|
-
.action((options) => {
|
|
8
|
+
.action(() => {
|
|
14
9
|
const tokenData = getTokenData();
|
|
15
10
|
if (!tokenData) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
console.log();
|
|
21
|
-
console.log(chalk.yellow('⚠️ 您还未登录'));
|
|
22
|
-
console.log();
|
|
23
|
-
console.log(chalk.gray('请运行以下命令登录: ') + chalk.cyan('google-ads auth login'));
|
|
24
|
-
console.log();
|
|
25
|
-
}
|
|
11
|
+
console.log(JSON.stringify({
|
|
12
|
+
logged_in: false,
|
|
13
|
+
message: '未登录,请运行 google-ads auth login'
|
|
14
|
+
}, null, 2));
|
|
26
15
|
return;
|
|
27
16
|
}
|
|
28
17
|
const expired = isTokenExpired(tokenData);
|
|
29
18
|
const expiresAt = new Date(tokenData.expires_at);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, null, 2));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
console.log();
|
|
41
|
-
const table = new Table({
|
|
42
|
-
head: [chalk.cyan('认证状态'), chalk.cyan('值')],
|
|
43
|
-
colWidths: [15, 50],
|
|
44
|
-
});
|
|
45
|
-
table.push(['状态', expired ? chalk.red('已过期') : chalk.green('✓ 已认证')], ['环境', tokenData.env]);
|
|
46
|
-
if (tokenData.user?.email) {
|
|
47
|
-
table.push(['账号', tokenData.user.email]);
|
|
48
|
-
}
|
|
49
|
-
if (tokenData.user?.name) {
|
|
50
|
-
table.push(['用户名', tokenData.user.name]);
|
|
51
|
-
}
|
|
52
|
-
table.push(['过期时间', expiresAt.toLocaleString('zh-CN')]);
|
|
53
|
-
console.log(table.toString());
|
|
54
|
-
console.log();
|
|
55
|
-
if (expired) {
|
|
56
|
-
console.log(chalk.yellow('⚠️ Token 已过期'));
|
|
57
|
-
console.log(chalk.gray('请重新登录: ') + chalk.cyan('google-ads auth login'));
|
|
58
|
-
console.log();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
19
|
+
console.log(JSON.stringify({
|
|
20
|
+
logged_in: true,
|
|
21
|
+
expired,
|
|
22
|
+
env: tokenData.env,
|
|
23
|
+
user: tokenData.user || null,
|
|
24
|
+
expires_at: expiresAt.toISOString(),
|
|
25
|
+
}, null, 2));
|
|
61
26
|
});
|
|
62
27
|
//# sourceMappingURL=status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/auth/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAExE,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,QAAQ,CAAC;KACrB,MAAM,CAAC,GAAG,EAAE;IACX,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IAEjC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;YACzB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,+BAA+B;SACzC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACb,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAEjD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;QACzB,SAAS,EAAE,IAAI;QACf,OAAO;QACP,GAAG,EAAE,SAAS,CAAC,GAAG;QAClB,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,IAAI;QAC5B,UAAU,EAAE,SAAS,CAAC,WAAW,EAAE;KACpC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACf,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/campaign/create.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SAsBtB,CAAC"}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* Campaign Create Command - 创建广告系列
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import ora from 'ora';
|
|
7
5
|
import { getApiClient } from '../../lib/api-client.js';
|
|
8
6
|
import { handleError } from '../../utils/errors.js';
|
|
9
7
|
import { getCustomerId } from '../../utils/customer-id.js';
|
|
@@ -12,40 +10,19 @@ export const createCommand = new Command('create')
|
|
|
12
10
|
.requiredOption('-n, --name <name>', '广告系列名称')
|
|
13
11
|
.requiredOption('-b, --budget <amount>', '每日预算(美元)', parseFloat)
|
|
14
12
|
.option('--status <status>', '状态 (ENABLED, PAUSED)', 'PAUSED')
|
|
15
|
-
.option('--json', '以 JSON 格式输出')
|
|
16
13
|
.action(async (options) => {
|
|
17
|
-
const spinner = ora('创建广告系列...').start();
|
|
18
14
|
try {
|
|
19
15
|
const customerId = getCustomerId();
|
|
20
16
|
const client = getApiClient();
|
|
21
|
-
// 转换预算为 micros
|
|
22
17
|
const budgetMicros = Math.round(options.budget * 1000000);
|
|
23
18
|
const result = await client.createCampaign(customerId, {
|
|
24
19
|
name: options.name,
|
|
25
20
|
budgetAmountMicros: budgetMicros,
|
|
26
21
|
status: options.status,
|
|
27
22
|
});
|
|
28
|
-
|
|
29
|
-
if (options.json) {
|
|
30
|
-
console.log(JSON.stringify(result, null, 2));
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
console.log(chalk.green('\n✅ 广告系列已创建'));
|
|
34
|
-
console.log(chalk.gray('名称:'), chalk.white(options.name));
|
|
35
|
-
console.log(chalk.gray('预算:'), chalk.white(`$${options.budget}/天`));
|
|
36
|
-
console.log(chalk.gray('状态:'), chalk.white(options.status));
|
|
37
|
-
// 提取创建的资源名称
|
|
38
|
-
const res = result;
|
|
39
|
-
if (res?.campaignId) {
|
|
40
|
-
console.log(chalk.gray('Campaign ID:'), chalk.cyan(res.campaignId));
|
|
41
|
-
console.log(chalk.gray('\n💡 下一步: 创建广告组'));
|
|
42
|
-
console.log(chalk.cyan(` google-ads ad-group create --campaign-id ${res.campaignId} -n "广告组名称"`));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
23
|
+
console.log(JSON.stringify(result, null, 2));
|
|
45
24
|
}
|
|
46
25
|
catch (error) {
|
|
47
|
-
spinner.fail('创建失败');
|
|
48
|
-
console.error('详细错误:', error);
|
|
49
26
|
handleError(error);
|
|
50
27
|
}
|
|
51
28
|
});
|