@publishq/cli 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -27,7 +27,7 @@ You get two commands: `publishq` and the shorter `pq`. They do the same thing.
27
27
  ## Quick start
28
28
 
29
29
  ```bash
30
- # 1. Save your API key (create one under Settings → API Keys in the web app)
30
+ # 1. Save your API key (create one under API Keys in the web app)
31
31
  pq auth set --key "pq_live_..."
32
32
 
33
33
  # 2. See your connected accounts
@@ -83,7 +83,7 @@ pq media get <media-id>
83
83
  pq media upload --file ./photo.jpg [--filename custom.jpg]
84
84
  ```
85
85
 
86
- Upload returns a media object whose `id` you can pass to `pq posts create --media-id <id>`.
86
+ Upload returns a media object whose `id` you can pass to `pq posts create --media-id <id>`. Files up to 4 GB are accepted (500 MB on the Free plan).
87
87
 
88
88
  ## Scopes
89
89
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { readFileSync as readFileSync2 } from "fs";
4
+ import { openAsBlob, statSync } from "fs";
5
5
  import { basename } from "path";
6
6
  import yargs from "yargs";
7
7
  import { hideBin } from "yargs/helpers";
@@ -33,7 +33,7 @@ function getClient() {
33
33
  const apiKey = getApiKey();
34
34
  if (!apiKey) {
35
35
  console.error(
36
- 'No API key found. Generate one at https://publishq.com/app/settings, then run `publishq auth set --key "pq_live_..."` or set PUBLISHQ_API_KEY.'
36
+ 'No API key found. Generate one at https://publishq.com/app/api-keys, then run `publishq auth set --key "pq_live_..."` or set PUBLISHQ_API_KEY.'
37
37
  );
38
38
  process.exit(1);
39
39
  }
@@ -70,6 +70,7 @@ function describeError(error) {
70
70
  }
71
71
 
72
72
  // src/index.ts
73
+ var OPEN_AS_BLOB_MAX_BYTES = 2 ** 32;
73
74
  function parseJsonOption(option, value) {
74
75
  try {
75
76
  return JSON.parse(value);
@@ -115,18 +116,26 @@ yargs(hideBin(process.argv)).scriptName("publishq").usage("$0 <command> [options
115
116
  "Create, list, update, and delete posts",
116
117
  (y) => y.command(
117
118
  ["list", "$0"],
118
- "List posts (paginate with --page and --limit)",
119
+ "List the posts you created through PublishQ (paginate with --page and --limit; imported posts need --include-imported or --only-imported)",
119
120
  (yy) => yy.option("page", {
120
121
  type: "number",
121
122
  describe: "Page number (starts at 1)"
122
123
  }).option("limit", {
123
124
  type: "number",
124
125
  describe: "Page size (max 100)"
126
+ }).option("include-imported", {
127
+ type: "boolean",
128
+ describe: "Also include posts imported from a connected platform (excluded by default)"
129
+ }).option("only-imported", {
130
+ type: "boolean",
131
+ describe: "Return only posts imported from a connected platform"
125
132
  }),
126
133
  (argv) => {
127
134
  const query = {
128
135
  ...argv.page !== void 0 ? { page: argv.page } : {},
129
- ...argv.limit !== void 0 ? { limit: argv.limit } : {}
136
+ ...argv.limit !== void 0 ? { limit: argv.limit } : {},
137
+ ...argv.includeImported !== void 0 ? { includeImported: argv.includeImported } : {},
138
+ ...argv.onlyImported !== void 0 ? { onlyImported: argv.onlyImported } : {}
130
139
  };
131
140
  output(
132
141
  getClient().posts.list(
@@ -361,11 +370,21 @@ yargs(hideBin(process.argv)).scriptName("publishq").usage("$0 <command> [options
361
370
  type: "string",
362
371
  describe: "Override the uploaded file name"
363
372
  }),
364
- (argv) => {
365
- const buffer = readFileSync2(argv.file);
373
+ async (argv) => {
374
+ if (statSync(argv.file).size >= OPEN_AS_BLOB_MAX_BYTES) {
375
+ console.error(
376
+ JSON.stringify({
377
+ error: `${argv.file} is too big to upload: files must be smaller than 4 GB.`
378
+ })
379
+ );
380
+ process.exit(1);
381
+ }
366
382
  const name = argv.filename ?? basename(argv.file);
367
- const file = new File([buffer], name);
368
- output(getClient().media.upload({ file }), argv.pretty);
383
+ const file = new File([await openAsBlob(argv.file)], name);
384
+ return output(
385
+ getClient().media.upload({ file }),
386
+ argv.pretty
387
+ );
369
388
  }
370
389
  ).demandCommand(1, "Specify a media subcommand."),
371
390
  () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@publishq/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "private": false,
5
5
  "description": "Official command-line interface for the PublishQ API — schedule and publish across your social platforms.",
6
6
  "license": "Apache-2.0",
@@ -27,8 +27,8 @@
27
27
  "LICENSE"
28
28
  ],
29
29
  "dependencies": {
30
- "yargs": "^17.7.2",
31
- "@publishq/sdk": "^0.0.1"
30
+ "@publishq/sdk": "^0.0.2",
31
+ "yargs": "^17.7.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^20",