certops 1.0.16 → 1.1.7

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/version.js CHANGED
@@ -1,18 +1,19 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
- function isPackageJson(value) {
5
- return (typeof value === 'object' &&
6
- value !== null &&
7
- 'version' in value &&
8
- typeof value.version === 'string');
9
- }
10
4
  function readCliVersion() {
11
- const dir = dirname(fileURLToPath(import.meta.url));
12
- const path = join(dir, '..', 'package.json');
13
- const raw = JSON.parse(readFileSync(path, 'utf8'));
14
- if (!isPackageJson(raw))
15
- throw new Error('package.json is missing a valid version field');
16
- return raw.version;
5
+ // Injected at compile time by Bun build --define
6
+ if (process.env.CLI_VERSION)
7
+ return process.env.CLI_VERSION;
8
+ // JS mode (npm package with dist/): read from package.json
9
+ try {
10
+ const dir = dirname(fileURLToPath(import.meta.url));
11
+ const path = join(dir, '..', 'package.json');
12
+ const raw = JSON.parse(readFileSync(path, 'utf8'));
13
+ return raw.version;
14
+ }
15
+ catch {
16
+ return '0.0.0';
17
+ }
17
18
  }
18
19
  export const CLI_VERSION = readCliVersion();
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "certops",
3
- "version": "1.0.16",
4
- "description": "SSL Pilot CLI — download and manage your SSL certificates",
3
+ "version": "1.1.7",
4
+ "description": "CertOps CLI — download and manage your SSL certificates",
5
5
  "type": "module",
6
6
  "files": [
7
- "dist"
7
+ "dist",
8
+ "scripts"
8
9
  ],
9
10
  "bin": {
10
11
  "certops": "./dist/index.js"
@@ -12,7 +13,15 @@
12
13
  "scripts": {
13
14
  "build": "tsc",
14
15
  "dev": "tsx src/index.ts",
15
- "typecheck": "tsc --noEmit"
16
+ "typecheck": "tsc --noEmit",
17
+ "postinstall": "node scripts/postinstall.cjs",
18
+ "preuninstall": "node scripts/preuninstall.cjs"
19
+ },
20
+ "optionalDependencies": {
21
+ "certops-linux-x64": "1.1.7",
22
+ "certops-linux-arm64": "1.1.7",
23
+ "certops-darwin-x64": "1.1.7",
24
+ "certops-darwin-arm64": "1.1.7"
16
25
  },
17
26
  "publishConfig": {
18
27
  "access": "public"
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ // Only run on global installs (sudo npm install -g certops)
5
+ if (!process.env.npm_config_global) {
6
+ process.exit(0)
7
+ }
8
+
9
+ const { copyFileSync, chmodSync } = require('fs')
10
+ const { join, dirname } = require('path')
11
+
12
+ const INSTALL_PATH = '/usr/local/bin/certops'
13
+
14
+ const platformMap = { linux: 'linux', darwin: 'darwin' }
15
+ const archMap = { x64: 'x64', arm64: 'arm64' }
16
+ const plat = platformMap[process.platform]
17
+ const arc = archMap[process.arch]
18
+
19
+ if (!plat || !arc) {
20
+ console.warn(`[certops] Unsupported platform ${process.platform}-${process.arch} — skipping binary install.`)
21
+ process.exit(0)
22
+ }
23
+
24
+ const pkgName = `certops-${plat}-${arc}`
25
+
26
+ let binarySrc
27
+ try {
28
+ const pkgDir = dirname(require.resolve(`${pkgName}/package.json`))
29
+ binarySrc = join(pkgDir, 'bin', 'certops')
30
+ } catch {
31
+ console.warn(`[certops] Platform package ${pkgName} not found — skipping binary install.`)
32
+ process.exit(0)
33
+ }
34
+
35
+ const isRoot = typeof process.getuid === 'function' && process.getuid() === 0
36
+
37
+ if (!isRoot) {
38
+ console.warn(`[certops] Not root — binary not installed to ${INSTALL_PATH}.`)
39
+ console.warn(`[certops] Re-run: sudo npm install -g certops`)
40
+ process.exit(0)
41
+ }
42
+
43
+ try {
44
+ copyFileSync(binarySrc, INSTALL_PATH)
45
+ chmodSync(INSTALL_PATH, 0o755)
46
+ console.log(`[certops] ✓ Installed to ${INSTALL_PATH}`)
47
+ } catch (err) {
48
+ console.error(`[certops] Install failed: ${err.message}`)
49
+ process.exit(0)
50
+ }
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ const { unlinkSync, existsSync } = require('fs')
5
+
6
+ const INSTALL_PATH = '/usr/local/bin/certops'
7
+
8
+ try {
9
+ if (existsSync(INSTALL_PATH)) {
10
+ unlinkSync(INSTALL_PATH)
11
+ console.log(`[certops] ✓ Removed ${INSTALL_PATH}`)
12
+ }
13
+ } catch (err) {
14
+ console.warn(`[certops] Could not remove ${INSTALL_PATH}: ${err.message}`)
15
+ }