formatferry 1.0.9 → 1.0.10

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.
Files changed (2) hide show
  1. package/dist/index.js +38 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -21124,27 +21124,26 @@ async function importXlsx() {
21124
21124
  }
21125
21125
  async function importPdfjs() {
21126
21126
  if (typeof process !== "undefined") {
21127
- const proxyProcess = process;
21128
- if (typeof proxyProcess.getBuiltinModule !== "function") {
21129
- let requireWorker;
21127
+ const p = process;
21128
+ if (typeof p.getBuiltinModule !== "function") {
21130
21129
  try {
21131
- const moduleName = "module";
21132
- const mod2 = await import(
21133
- /* @vite-ignore */
21134
- moduleName
21135
- );
21136
- if (mod2 && typeof mod2.createRequire === "function") {
21137
- requireWorker = mod2.createRequire(import.meta.url);
21130
+ const mod2 = await import("node:module");
21131
+ const createRequire = mod2.createRequire;
21132
+ if (typeof createRequire === "function") {
21133
+ const req = createRequire(process.argv?.[1] || import.meta.url);
21134
+ p.getBuiltinModule = (name) => {
21135
+ try {
21136
+ return req(name);
21137
+ } catch {
21138
+ return void 0;
21139
+ }
21140
+ };
21141
+ } else {
21142
+ p.getBuiltinModule = () => void 0;
21138
21143
  }
21139
21144
  } catch {
21145
+ p.getBuiltinModule = () => void 0;
21140
21146
  }
21141
- proxyProcess.getBuiltinModule = (name) => {
21142
- try {
21143
- return requireWorker ? requireWorker(name) : void 0;
21144
- } catch {
21145
- return void 0;
21146
- }
21147
- };
21148
21147
  }
21149
21148
  }
21150
21149
  const mod = await import("pdfjs-dist/legacy/build/pdf.mjs");
@@ -21969,6 +21968,9 @@ function readConfig() {
21969
21968
  return null;
21970
21969
  }
21971
21970
  }
21971
+ function getApiKey() {
21972
+ return process.env.FORMATFERRY_API_KEY || readConfig()?.apiKey;
21973
+ }
21972
21974
  function writeConfig(config) {
21973
21975
  mkdirSync(dirname(CONFIG_PATH), { recursive: true });
21974
21976
  writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), { mode: 384 });
@@ -22731,11 +22733,10 @@ async function convertCommand(options) {
22731
22733
  process.stderr.write("Error: --url and --input are mutually exclusive. Use one or the other.\n");
22732
22734
  process.exit(1);
22733
22735
  }
22734
- const config = readConfig();
22735
- const apiKey = config?.apiKey;
22736
+ const apiKey = getApiKey();
22736
22737
  if (!apiKey) {
22737
22738
  process.stderr.write(
22738
- "Error: No SaaS API key configured. URL extraction requires a subscription.\nSet your API key with: formatferry auth --license-key <KEY>\n"
22739
+ "Error: No SaaS API key configured. URL extraction requires a subscription.\nSet your API key with: formatferry auth --api-key <KEY>\nOr via the FORMATFERRY_API_KEY environment variable.\n"
22739
22740
  );
22740
22741
  process.exit(1);
22741
22742
  }
@@ -23074,15 +23075,20 @@ async function handleLicenseKey(key) {
23074
23075
  }
23075
23076
  }
23076
23077
  function handleStatus() {
23078
+ const envKey = process.env.FORMATFERRY_API_KEY;
23077
23079
  const config = readConfig();
23078
- if (!config || !config.licenseKey && !config.apiKey) {
23080
+ if (envKey) {
23081
+ process.stdout.write(`Using API Key from FORMATFERRY_API_KEY environment variable.
23082
+ `);
23083
+ }
23084
+ if ((!config || !config.licenseKey && !config.apiKey) && !envKey) {
23079
23085
  process.stdout.write(`Tier: free
23080
23086
  `);
23081
23087
  process.stdout.write(`No license key or API key configured.
23082
23088
  `);
23083
23089
  return;
23084
23090
  }
23085
- if (config.apiKey) {
23091
+ if (config?.apiKey) {
23086
23092
  const plan = config.plan ?? "free";
23087
23093
  process.stdout.write(`Plan: ${formatPlanName(plan)}
23088
23094
  `);
@@ -23104,9 +23110,14 @@ function handleStatus() {
23104
23110
  }
23105
23111
  return;
23106
23112
  }
23107
- const tier = config.tier ?? "free";
23108
- const features = config.features ?? [];
23109
- const expiresAt = config.expiresAt ?? null;
23113
+ if (!config && envKey) {
23114
+ process.stdout.write(`Plan: API key configured via environment variable
23115
+ `);
23116
+ return;
23117
+ }
23118
+ const tier = config?.tier ?? "free";
23119
+ const features = config?.features ?? [];
23120
+ const expiresAt = config?.expiresAt ?? null;
23110
23121
  process.stdout.write(`Tier: ${tier}
23111
23122
  `);
23112
23123
  if (expiresAt) {
@@ -23129,8 +23140,8 @@ import { readFileSync as readFileSync4 } from "fs";
23129
23140
  import { resolve, dirname as dirname3 } from "path";
23130
23141
  import { fileURLToPath } from "url";
23131
23142
  var getVersion = () => {
23132
- if ("1.0.9") {
23133
- return "1.0.9";
23143
+ if ("1.0.10") {
23144
+ return "1.0.10";
23134
23145
  }
23135
23146
  try {
23136
23147
  const __dirname = dirname3(fileURLToPath(import.meta.url));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formatferry",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "FormatFerry CLI — Convert HTML, DOCX, PDF, XLSX, CSV to Markdown",
5
5
  "keywords": [
6
6
  "markdown",