addons-scanner-utils 8.1.0 → 8.3.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/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,16 +3,17 @@
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
+ export 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
  };
13
13
  export declare class Xpi extends IOBase {
14
14
  autoClose: boolean;
15
15
  files: Files;
16
+ processed: boolean;
16
17
  zipLib: typeof yauzl;
17
18
  zipfile: ZipFile | undefined;
18
19
  constructor({ autoClose, filePath, stderr, zipLib, }: XpiConstructorParams);
package/dist/io/xpi.js CHANGED
@@ -31,8 +31,9 @@ const errors_1 = require("../errors");
31
31
  class Xpi extends base_1.IOBase {
32
32
  constructor({ autoClose = true, filePath, stderr, zipLib = yauzl_1.default, }) {
33
33
  super({ filePath, stderr });
34
- this.files = {};
35
34
  this.autoClose = autoClose;
35
+ this.files = {};
36
+ this.processed = false;
36
37
  this.zipLib = zipLib;
37
38
  }
38
39
  open() {
@@ -85,7 +86,7 @@ class Xpi extends base_1.IOBase {
85
86
  return __awaiter(this, void 0, void 0, function* () {
86
87
  // If we have already processed the file and have data on this instance
87
88
  // return that.
88
- if (Object.keys(this.files).length) {
89
+ if (this.processed) {
89
90
  const wantedFiles = {};
90
91
  Object.keys(this.files).forEach((fileName) => {
91
92
  if (this.shouldScanFile(fileName, false)) {
@@ -114,6 +115,7 @@ class Xpi extends base_1.IOBase {
114
115
  //
115
116
  // See: https://github.com/mozilla/addons-linter/pull/43
116
117
  zipfile.on('end', () => {
118
+ this.processed = true;
117
119
  resolve(this.files);
118
120
  });
119
121
  if (_onEventsSubscribed) {
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.1.0",
3
+ "version": "8.3.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",