addons-scanner-utils 8.0.0 → 8.2.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.
@@ -3,20 +3,20 @@
3
3
  import fs from 'fs';
4
4
  import { Request, RequestHandler } from 'express';
5
5
  import fetch from 'node-fetch';
6
- declare type ApiError = Error & {
6
+ type ApiError = Error & {
7
7
  extraInfo?: string;
8
8
  status?: number;
9
9
  };
10
- declare type CreateApiErrorParams = {
10
+ type CreateApiErrorParams = {
11
11
  message: string;
12
12
  extraInfo?: string;
13
13
  status?: number;
14
14
  };
15
15
  export declare const createApiError: ({ message, extraInfo, status, }: CreateApiErrorParams) => ApiError;
16
- export declare type RequestWithFiles = Request & {
16
+ export type RequestWithFiles = Request & {
17
17
  xpiFilepath?: string;
18
18
  };
19
- export declare type FunctionConfig = {
19
+ export type FunctionConfig = {
20
20
  _console?: typeof console;
21
21
  _fetch?: typeof fetch;
22
22
  _process?: typeof process;
package/dist/functions.js CHANGED
@@ -16,9 +16,8 @@ exports.createExpressApp = exports.createApiError = void 0;
16
16
  const fs_1 = __importDefault(require("fs"));
17
17
  const os_1 = __importDefault(require("os"));
18
18
  const path_1 = __importDefault(require("path"));
19
- const node_fs_1 = require("node:fs");
20
- const node_stream_1 = require("node:stream");
21
- const node_util_1 = require("node:util");
19
+ const stream_1 = __importDefault(require("stream"));
20
+ const util_1 = __importDefault(require("util"));
22
21
  const express_1 = __importDefault(require("express"));
23
22
  const body_parser_1 = __importDefault(require("body-parser"));
24
23
  const node_fetch_1 = __importDefault(require("node-fetch"));
@@ -94,12 +93,12 @@ const createExpressApp = ({ _console = console, _fetch = node_fetch_1.default, _
94
93
  }
95
94
  try {
96
95
  const xpiFilepath = path_1.default.join(tmpDir, xpiFilename);
97
- const streamPipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
96
+ const streamPipeline = util_1.default.promisify(stream_1.default.pipeline);
98
97
  const response = yield _fetch(downloadURL);
99
98
  if (!response.ok) {
100
99
  throw new Error(`unexpected response ${response.statusText}`);
101
100
  }
102
- yield streamPipeline(response.body, (0, node_fs_1.createWriteStream)(xpiFilepath));
101
+ yield streamPipeline(response.body, fs_1.default.createWriteStream(xpiFilepath));
103
102
  req.xpiFilepath = xpiFilepath;
104
103
  // Add a listener that will run code after the response is sent.
105
104
  res.on('finish', () => {
package/dist/io/base.d.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  /// <reference types="node" />
3
3
  import { Readable } from 'stream';
4
4
  import { Stderr } from '../stdio';
5
- declare type ScanFileFunction = (_path: string, isDirectory: boolean) => boolean;
6
- declare type Files = Record<string, unknown>;
7
- export declare type IOBaseConstructorParams = {
5
+ type ScanFileFunction = (_path: string, isDirectory: boolean) => boolean;
6
+ type Files = Record<string, unknown>;
7
+ export type IOBaseConstructorParams = {
8
8
  filePath: string;
9
9
  stderr: Stderr;
10
10
  };
package/dist/io/crx.d.ts CHANGED
@@ -5,7 +5,7 @@ import yauzl, { ZipFile } from 'yauzl';
5
5
  import { IOBaseConstructorParams } from './base';
6
6
  import { Xpi } from './xpi';
7
7
  export declare function defaultParseCRX(buf: Buffer): Buffer;
8
- declare type CrxConstructorParams = IOBaseConstructorParams & {
8
+ type CrxConstructorParams = IOBaseConstructorParams & {
9
9
  fs?: typeof defaultFs;
10
10
  parseCRX?: typeof defaultParseCRX;
11
11
  zipLib?: typeof yauzl;
@@ -3,12 +3,12 @@
3
3
  import { Readable } from 'stream';
4
4
  import { IOBase, IOBaseConstructorParams } from './base';
5
5
  import { walkPromise } from './utils';
6
- declare type Files = {
6
+ type Files = {
7
7
  [filename: string]: {
8
8
  size: number;
9
9
  };
10
10
  };
11
- declare type DirectoryConstructorParams = IOBaseConstructorParams;
11
+ type DirectoryConstructorParams = IOBaseConstructorParams;
12
12
  export declare class Directory extends IOBase {
13
13
  files: Files;
14
14
  constructor({ filePath, stderr }: DirectoryConstructorParams);
@@ -4,7 +4,7 @@ import { Stderr } from '../stdio';
4
4
  export declare const lstat: typeof fs.lstat.__promisify__;
5
5
  export declare const readFile: typeof fs.readFile.__promisify__;
6
6
  export declare const readdir: typeof fs.readdir.__promisify__;
7
- export declare type WalkPromiseOptions = {
7
+ export type WalkPromiseOptions = {
8
8
  shouldIncludePath?: (_path: string, isDirectory: boolean) => boolean;
9
9
  stderr: Stderr;
10
10
  };
package/dist/io/xpi.d.ts CHANGED
@@ -3,10 +3,10 @@
3
3
  import { Readable } from 'stream';
4
4
  import yauzl, { Entry, ZipFile } from 'yauzl';
5
5
  import { IOBaseConstructorParams, IOBase } from './base';
6
- declare type Files = {
6
+ type Files = {
7
7
  [filename: string]: Entry;
8
8
  };
9
- declare type XpiConstructorParams = IOBaseConstructorParams & {
9
+ type XpiConstructorParams = IOBaseConstructorParams & {
10
10
  autoClose?: boolean;
11
11
  zipLib?: typeof yauzl;
12
12
  };
package/dist/stdio.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export declare type Stderr = {
1
+ export type Stderr = {
2
2
  debug: (message: string) => void;
3
3
  error: (message: string) => void;
4
4
  info: (message: string) => void;
5
5
  };
6
- declare type CreateConsoleStderrParams = {
6
+ type CreateConsoleStderrParams = {
7
7
  _console?: typeof console;
8
8
  programName: string;
9
9
  verboseLevel: number;
10
10
  };
11
11
  export declare const createConsoleStderr: ({ _console, programName, verboseLevel, }: CreateConsoleStderrParams) => Stderr;
12
- export declare type InMemoryStderr = Stderr & {
12
+ export type InMemoryStderr = Stderr & {
13
13
  messages: {
14
14
  debug: string[];
15
15
  error: string[];
@@ -17,13 +17,13 @@ export declare type InMemoryStderr = Stderr & {
17
17
  };
18
18
  };
19
19
  export declare const createInMemoryStderr: () => InMemoryStderr;
20
- export declare type Stdout = {
20
+ export type Stdout = {
21
21
  write: (message: string) => void;
22
22
  };
23
23
  export declare const createConsoleStdout: ({ _console }?: {
24
24
  _console?: Console | undefined;
25
25
  }) => Stdout;
26
- export declare type InMemoryStdout = Stdout & {
26
+ export type InMemoryStdout = Stdout & {
27
27
  output: string;
28
28
  };
29
29
  export declare const createInMemoryStdout: () => InMemoryStdout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "addons-scanner-utils",
3
- "version": "8.0.0",
3
+ "version": "8.2.0",
4
4
  "description": "Various addons related helpers to build CLIs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,9 +39,9 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/common-tags": "^1.8.0",
42
- "@types/express": "4.17.14",
42
+ "@types/express": "4.17.15",
43
43
  "@types/jest": "^29.0.0",
44
- "@types/node": "^14.0.0",
44
+ "@types/node": "^18.0.0",
45
45
  "@types/node-fetch": "^2.6.2",
46
46
  "@types/safe-compare": "^1.1.0",
47
47
  "@types/sinon": "^10.0.0",
@@ -55,11 +55,11 @@
55
55
  "express": "4.18.2",
56
56
  "jest": "^29.0.0",
57
57
  "node-fetch": "2.6.7",
58
- "prettier": "2.7.1",
58
+ "prettier": "2.8.1",
59
59
  "pretty-quick": "^3.0.0",
60
60
  "rimraf": "^3.0.0",
61
61
  "safe-compare": "1.1.4",
62
- "sinon": "^14.0.0",
62
+ "sinon": "^15.0.0",
63
63
  "supertest": "^6.0.0",
64
64
  "ts-jest": "^29.0.0",
65
65
  "type-coverage": "^2.3.0",