@adsuploader/cli 0.1.0 → 0.1.1
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.cjs +49 -8
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -4706,6 +4706,10 @@ function adsetCommand() {
|
|
|
4706
4706
|
|
|
4707
4707
|
// src/commands/ad.js
|
|
4708
4708
|
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
4709
|
+
function truncate(str, max = 120) {
|
|
4710
|
+
if (!str || str.length <= max) return str;
|
|
4711
|
+
return str.slice(0, max) + "...";
|
|
4712
|
+
}
|
|
4709
4713
|
function adCommand() {
|
|
4710
4714
|
return new Command("ad").description("View ad details and creative").argument("<id>", "Ad ID").option("--account <id>", "Ad account ID").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
4711
4715
|
const client = createClient({ accountId: opts.account });
|
|
@@ -4724,13 +4728,19 @@ function adCommand() {
|
|
|
4724
4728
|
if (ad.creative) {
|
|
4725
4729
|
console.log("");
|
|
4726
4730
|
console.log(` ${import_picocolors7.default.bold("Creative")}`);
|
|
4727
|
-
if (ad.creative.
|
|
4728
|
-
if (ad.creative.
|
|
4729
|
-
if (ad.creative.
|
|
4730
|
-
if (ad.creative.
|
|
4731
|
-
if (ad.creative.
|
|
4732
|
-
if (ad.creative.
|
|
4733
|
-
if (ad.creative.
|
|
4731
|
+
if (ad.creative.headline) console.log(` ${import_picocolors7.default.bold("Headline:")} ${truncate(ad.creative.headline)}`);
|
|
4732
|
+
if (ad.creative.headlines) console.log(` ${import_picocolors7.default.bold("Headlines:")} ${ad.creative.headlines.map((h2) => truncate(h2, 60)).join(" | ")}`);
|
|
4733
|
+
if (ad.creative.primaryText) console.log(` ${import_picocolors7.default.bold("Primary Text:")} ${truncate(ad.creative.primaryText)}`);
|
|
4734
|
+
if (ad.creative.primaryTexts) console.log(` ${import_picocolors7.default.bold("Primary Texts:")} ${ad.creative.primaryTexts.map((t) => truncate(t, 60)).join(" | ")}`);
|
|
4735
|
+
if (ad.creative.description) console.log(` ${import_picocolors7.default.bold("Description:")} ${truncate(ad.creative.description)}`);
|
|
4736
|
+
if (ad.creative.descriptions) console.log(` ${import_picocolors7.default.bold("Descriptions:")} ${ad.creative.descriptions.map((d3) => truncate(d3, 60)).join(" | ")}`);
|
|
4737
|
+
if (ad.creative.cta) console.log(` ${import_picocolors7.default.bold("CTA:")} ${ad.creative.cta}`);
|
|
4738
|
+
if (ad.creative.link) console.log(` ${import_picocolors7.default.bold("Link:")} ${ad.creative.link}`);
|
|
4739
|
+
if (ad.creative.displayUrl) console.log(` ${import_picocolors7.default.bold("Display URL:")} ${ad.creative.displayUrl}`);
|
|
4740
|
+
if (ad.creative.urlTags) console.log(` ${import_picocolors7.default.bold("URL Tags:")} ${ad.creative.urlTags}`);
|
|
4741
|
+
if (ad.creative.enhancements) {
|
|
4742
|
+
console.log(` ${import_picocolors7.default.bold("Enhancements:")} ${ad.creative.enhancements.join(", ")}`);
|
|
4743
|
+
}
|
|
4734
4744
|
}
|
|
4735
4745
|
console.log(`
|
|
4736
4746
|
${import_picocolors7.default.dim("Use this ad as a template:")} ads create --copy-from ${ad.id}
|
|
@@ -5909,6 +5919,7 @@ function statusLabel(status) {
|
|
|
5909
5919
|
}
|
|
5910
5920
|
|
|
5911
5921
|
// src/cli.js
|
|
5922
|
+
var VERSION = true ? "0.1.1" : "0.0.0";
|
|
5912
5923
|
var apiUrl = process.env.ADS_API_URL || getBaseUrl();
|
|
5913
5924
|
if (apiUrl && (apiUrl.includes("localhost") || apiUrl.includes("127.0.0.1"))) {
|
|
5914
5925
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
@@ -5925,7 +5936,7 @@ var BANNER = [
|
|
|
5925
5936
|
" " + import_picocolors13.default.dim("Create Meta ads from the command line"),
|
|
5926
5937
|
""
|
|
5927
5938
|
].join("\n");
|
|
5928
|
-
var program2 = new Command().name("ads").description("Ads Uploader CLI").version(
|
|
5939
|
+
var program2 = new Command().name("ads").description("Ads Uploader CLI").version(VERSION).addHelpText("before", BANNER);
|
|
5929
5940
|
program2.addCommand(loginCommand());
|
|
5930
5941
|
program2.addCommand(logoutCommand());
|
|
5931
5942
|
program2.addCommand(whoamiCommand());
|
|
@@ -5946,6 +5957,35 @@ program2.addCommand(createInteractiveCommand());
|
|
|
5946
5957
|
program2.addCommand(createPreviewCommand());
|
|
5947
5958
|
program2.addCommand(createTestCommand(), { hidden: true });
|
|
5948
5959
|
program2.addCommand(jobsCommand());
|
|
5960
|
+
async function checkForUpdates() {
|
|
5961
|
+
try {
|
|
5962
|
+
const fs4 = await import("fs");
|
|
5963
|
+
const path3 = await import("path");
|
|
5964
|
+
const os2 = await import("os");
|
|
5965
|
+
const cacheFile = path3.join(os2.default.homedir(), ".config", "adsuploader", ".update-check");
|
|
5966
|
+
try {
|
|
5967
|
+
const stat = fs4.default.statSync(cacheFile);
|
|
5968
|
+
if (Date.now() - stat.mtimeMs < 24 * 60 * 60 * 1e3) return;
|
|
5969
|
+
} catch {
|
|
5970
|
+
}
|
|
5971
|
+
const resp = await fetch("https://registry.npmjs.org/@adsuploader/cli/latest", { signal: AbortSignal.timeout(3e3) });
|
|
5972
|
+
if (!resp.ok) return;
|
|
5973
|
+
const data = await resp.json();
|
|
5974
|
+
const latest = data.version;
|
|
5975
|
+
try {
|
|
5976
|
+
fs4.default.mkdirSync(path3.dirname(cacheFile), { recursive: true });
|
|
5977
|
+
fs4.default.writeFileSync(cacheFile, latest);
|
|
5978
|
+
} catch {
|
|
5979
|
+
}
|
|
5980
|
+
if (latest !== VERSION) {
|
|
5981
|
+
console.error(`
|
|
5982
|
+
${import_picocolors13.default.yellow("Update available:")} ${import_picocolors13.default.dim(VERSION)} \u2192 ${import_picocolors13.default.green(latest)}`);
|
|
5983
|
+
console.error(` Run ${import_picocolors13.default.cyan("npm update -g @adsuploader/cli")} to update
|
|
5984
|
+
`);
|
|
5985
|
+
}
|
|
5986
|
+
} catch {
|
|
5987
|
+
}
|
|
5988
|
+
}
|
|
5949
5989
|
program2.exitOverride();
|
|
5950
5990
|
if (process.argv.length <= 2) {
|
|
5951
5991
|
program2.outputHelp();
|
|
@@ -5954,6 +5994,7 @@ if (process.argv.length <= 2) {
|
|
|
5954
5994
|
(async () => {
|
|
5955
5995
|
try {
|
|
5956
5996
|
await program2.parseAsync(process.argv);
|
|
5997
|
+
await checkForUpdates();
|
|
5957
5998
|
} catch (err) {
|
|
5958
5999
|
if (err.code === "commander.helpDisplayed" || err.code === "commander.help" || err.code === "commander.version") {
|
|
5959
6000
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adsuploader/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Create Facebook ads from the command line — bulk upload media, preview configurations, and launch ads at scale",
|
|
5
5
|
"author": "Ads Uploader <support@adsuploader.com> (https://adsuploader.com)",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"node": ">=18"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "
|
|
33
|
+
"build": "node build.cjs",
|
|
34
34
|
"dev": "node src/cli.js",
|
|
35
35
|
"link": "npm link"
|
|
36
36
|
},
|