@peculiar/pdf-cli 1.17.1 → 2.0.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/README.md CHANGED
@@ -1,4 +1,15 @@
1
- # `@peculiar/pdf-cli`
1
+ <h1 align="center">
2
+ @peculiar/pdf-cli
3
+ </h1>
4
+
5
+ <div align="center">
6
+
7
+ ![GitHub License](https://img.shields.io/github/license/PeculiarVentures/pdf)
8
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/PeculiarVentures/pdf/release.yml?branch=main&label=release)
9
+ [![npm version](https://img.shields.io/npm/v/@peculiar/pdf-cli.svg)](https://www.npmjs.com/package/@peculiar/pdf-cli)
10
+ [![npm downloads](https://img.shields.io/npm/dm/@peculiar/pdf-cli.svg)](https://www.npmjs.com/package/@peculiar/pdf-cli)
11
+
12
+ </div>
2
13
 
3
14
  Command-line interface for PDF document manipulation and analysis.
4
15
 
@@ -8,6 +19,10 @@ Command-line interface for PDF document manipulation and analysis.
8
19
  npm install -g @peculiar/pdf-cli
9
20
  ```
10
21
 
22
+ ## Breaking Changes In v2
23
+
24
+ v2 requires Node.js `^20.19.0 || >=22.12.0` (1.x declared no `engines`). `pvpdf` is an ES module at `build/index.js` (was `build/index.cjs`); the commands are unchanged. See the [full notes](https://github.com/PeculiarVentures/pdf#breaking-changes-in-v2).
25
+
11
26
  ## Commands
12
27
 
13
28
  ### info
@@ -0,0 +1 @@
1
+ import "reflect-metadata";
package/build/index.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import "reflect-metadata";
3
+ import { Crypto } from "@peculiar/webcrypto";
4
+ import * as core from "@peculiar/pdf-core";
5
+ import { Command } from "commander";
6
+ import * as pkijs from "pkijs";
7
+ import { PDFDocument } from "@peculiar/pdf-doc";
8
+ import * as fs from "fs";
9
+ // src/commands/info.ts
10
+ const info = new Command("info").argument("<pdf file>");
11
+ info.description("Prints PDF document information");
12
+ info.action(async (file, _options, _command) => {
13
+ const raw = fs.readFileSync(file);
14
+ const info = await (await PDFDocument.load(raw)).target.toString();
15
+ console.log(info);
16
+ });
17
+ // src/index.ts
18
+ const program = new Command("pdf");
19
+ pkijs.setEngine("pdf", new core.PDFCryptoEngine({
20
+ name: "pdf",
21
+ crypto: new Crypto()
22
+ }));
23
+ program.addCommand(info);
24
+ program.parse();
package/package.json CHANGED
@@ -1,44 +1,49 @@
1
1
  {
2
2
  "name": "@peculiar/pdf-cli",
3
- "version": "1.17.1",
3
+ "version": "2.0.0",
4
4
  "description": "Command-line interface for PDF document manipulation and analysis",
5
- "author": "microshine <microshine@mail.ru>",
6
- "homepage": "https://github.com/PeculiarVentures/pdf/tree/master/packages/pdf-cli#readme",
7
- "license": "AGPL",
8
- "main": "build/peculiar.pdf.cli.js",
5
+ "type": "module",
9
6
  "bin": {
10
- "pvpdf": "build/peculiar.pdf.cli.js"
7
+ "pvpdf": "build/index.js"
11
8
  },
12
- "publishConfig": {
13
- "access": "public",
14
- "registry": "https://registry.npmjs.org/"
9
+ "main": "./build/index.js",
10
+ "module": "./build/index.js",
11
+ "types": "./build/index.d.ts",
12
+ "exports": {
13
+ ".": "./build/index.js",
14
+ "./package.json": "./package.json"
15
15
  },
16
16
  "files": [
17
- "build",
18
- "LICENSE",
19
- "README.md"
17
+ "build/",
18
+ "README.md",
19
+ "LICENSE"
20
20
  ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "engines": {
25
+ "node": "^20.19.0 || >=22.12.0"
26
+ },
27
+ "author": "microshine <microshine@mail.ru>",
28
+ "license": "AGPL",
21
29
  "repository": {
22
30
  "type": "git",
23
- "url": "git+https://github.com/PeculiarVentures/pdf.git"
24
- },
25
- "scripts": {
26
- "test": "echo \"Error: run tests from root\" && exit 1",
27
- "clear": "rimraf build/*",
28
- "build": "yarn run build:module",
29
- "build:module": "rollup -c",
30
- "rebuild": "yarn run clear && yarn run build",
31
- "prepack": "npm run rebuild"
31
+ "url": "https://github.com/PeculiarVentures/pdf",
32
+ "directory": "packages/cli"
32
33
  },
33
34
  "bugs": {
34
35
  "url": "https://github.com/PeculiarVentures/pdf/issues"
35
36
  },
37
+ "homepage": "https://github.com/PeculiarVentures/pdf/tree/main/packages/cli#readme",
36
38
  "dependencies": {
37
- "@peculiar/pdf-core": "^1.17.1",
38
- "@peculiar/pdf-doc": "^1.17.1",
39
- "@peculiar/webcrypto": "^1.5.0",
40
- "commander": "^12.1.0",
41
- "pkijs": "^3.2.4"
42
- },
43
- "gitHead": "5909f25f54def17880f0760a7e33f0c4aaff4bda"
39
+ "@peculiar/asn1-schema": "^3.0.0",
40
+ "@peculiar/pdf-core": "^2.0.0",
41
+ "@peculiar/pdf-doc": "^2.0.0",
42
+ "@peculiar/webcrypto": "^2.0.0",
43
+ "@peculiar/x509": "^3.1.0",
44
+ "asn1js": "^4.0.0",
45
+ "commander": "^14.0.3",
46
+ "pkijs": "^4.0.0",
47
+ "reflect-metadata": "^0.2.2"
48
+ }
44
49
  }
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- var webcrypto = require('@peculiar/webcrypto');
5
- var core = require('@peculiar/pdf-core');
6
- var commander = require('commander');
7
- var pkijs = require('pkijs');
8
- var pdfDoc = require('@peculiar/pdf-doc');
9
- var fs = require('fs');
10
-
11
- function _interopNamespaceDefault(e) {
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n.default = e;
25
- return Object.freeze(n);
26
- }
27
-
28
- var core__namespace = /*#__PURE__*/_interopNamespaceDefault(core);
29
- var pkijs__namespace = /*#__PURE__*/_interopNamespaceDefault(pkijs);
30
- var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
31
-
32
- const info = new commander.Command("info").argument("<pdf file>");
33
- info.description("Prints PDF document information");
34
- info.action(async (file, _options, _command) => {
35
- const raw = fs__namespace.readFileSync(file);
36
- const doc = await pdfDoc.PDFDocument.load(raw);
37
- const info = await doc.target.toString();
38
- console.log(info);
39
- });
40
-
41
- const program = new commander.Command("pdf");
42
- pkijs__namespace.setEngine("pdf", new core__namespace.PDFCryptoEngine({
43
- name: "pdf",
44
- crypto: new webcrypto.Crypto()
45
- }));
46
- program.addCommand(info);
47
- program.parse();