@oclif/test 3.0.2 → 3.0.4

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/lib/command.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { Interfaces } from '@oclif/core';
2
2
  import { loadConfig } from './load-config';
3
- export declare function command(args: string[] | string, opts?: loadConfig.Options): {
4
- run(ctx: {
5
- config: Interfaces.Config;
6
- expectation: string;
7
- returned: unknown;
8
- }): Promise<void>;
3
+ type Context = {
4
+ config: Interfaces.Config;
5
+ expectation: string;
6
+ returned: unknown;
9
7
  };
8
+ export declare function command(args: string | string[], opts?: loadConfig.Options): {
9
+ run(ctx: Context): Promise<void>;
10
+ };
11
+ export {};
package/lib/command.js CHANGED
@@ -17,7 +17,7 @@ function command(args, opts = {}) {
17
17
  const [id, ...extra] = args;
18
18
  const cmdId = (0, core_1.toStandardizedId)(id, ctx.config);
19
19
  ctx.expectation = ctx.expectation || `runs ${args.join(' ')}`;
20
- await ctx.config.runHook('init', { id: cmdId, argv: extra });
20
+ await ctx.config.runHook('init', { argv: extra, id: cmdId });
21
21
  ctx.returned = await ctx.config.runCommand(cmdId, extra);
22
22
  },
23
23
  };
package/lib/exit.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  /// <reference types="mocha" />
2
+ import { Errors } from '@oclif/core';
2
3
  /**
3
4
  * ensures that a oclif command or hook exits
4
5
  */
5
6
  declare const _default: (code?: number) => {
6
- run(): never;
7
7
  catch(ctx: {
8
- error: any;
8
+ error: Errors.CLIError;
9
9
  }): void;
10
+ run(): never;
10
11
  };
11
12
  export default _default;
package/lib/exit.js CHANGED
@@ -6,13 +6,13 @@ const chai_1 = require("chai");
6
6
  * ensures that a oclif command or hook exits
7
7
  */
8
8
  exports.default = (code = 0) => ({
9
- run() {
10
- (0, chai_1.expect)(process.exitCode).to.equal(code);
11
- throw new Error(`Expected to exit with code ${code} but it ran without exiting`);
12
- },
13
9
  catch(ctx) {
14
10
  if (!ctx.error.oclif || ctx.error.oclif.exit === undefined)
15
11
  throw ctx.error;
16
12
  (0, chai_1.expect)(ctx.error.oclif.exit).to.equal(code);
17
13
  },
14
+ run() {
15
+ (0, chai_1.expect)(process.exitCode).to.equal(code);
16
+ throw new Error(`Expected to exit with code ${code} but it ran without exiting`);
17
+ },
18
18
  });
package/lib/hook.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  /// <reference types="mocha" />
2
2
  import { Interfaces } from '@oclif/core';
3
3
  import { loadConfig } from './load-config';
4
+ type Context = {
5
+ config: Interfaces.Config;
6
+ expectation: string;
7
+ returned: unknown;
8
+ };
4
9
  /**
5
10
  * tests a oclif hook
6
11
  *
@@ -13,10 +18,6 @@ import { loadConfig } from './load-config';
13
18
  * @param {object} hookOpts options to pass to hook. Config object will be passed automatically.
14
19
  */
15
20
  declare const _default: (event: string, hookOpts?: Record<string, unknown>, options?: loadConfig.Options) => {
16
- run(ctx: {
17
- config: Interfaces.Config;
18
- expectation: string;
19
- returned: unknown;
20
- }): Promise<void>;
21
+ run(ctx: Context): Promise<void>;
21
22
  };
22
23
  export default _default;
package/lib/index.d.ts CHANGED
@@ -96,7 +96,7 @@ export declare const test: import("fancy-test/lib/types").Base<import("fancy-tes
96
96
  } & {
97
97
  exit: {
98
98
  output: {
99
- error: any;
99
+ error: import("@oclif/core/lib/errors").CLIError;
100
100
  };
101
101
  args: [code?: number | undefined];
102
102
  };
@@ -111,6 +111,6 @@ export declare const test: import("fancy-test/lib/types").Base<import("fancy-tes
111
111
  };
112
112
  }>;
113
113
  export default test;
114
- export { Config } from '@oclif/core';
115
- export { expect, FancyTypes } from 'fancy-test';
116
114
  export { command } from './command';
115
+ export { Config } from '@oclif/core';
116
+ export { FancyTypes, expect } from 'fancy-test';
package/lib/index.js CHANGED
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
- var _a, _b;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
3
5
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.command = exports.FancyTypes = exports.expect = exports.Config = exports.test = void 0;
5
- const tslib_1 = require("tslib");
6
- const node_path_1 = require("node:path");
6
+ exports.expect = exports.FancyTypes = exports.Config = exports.command = exports.test = void 0;
7
7
  const fancy_test_1 = require("fancy-test");
8
+ const node_path_1 = require("node:path");
8
9
  const command_1 = require("./command");
9
- const exit_1 = tslib_1.__importDefault(require("./exit"));
10
- const hook_1 = tslib_1.__importDefault(require("./hook"));
10
+ const exit_1 = __importDefault(require("./exit"));
11
+ const hook_1 = __importDefault(require("./hook"));
11
12
  const load_config_1 = require("./load-config");
12
13
  function traverseFilePathUntil(filename, predicate) {
13
14
  let current = filename;
@@ -18,7 +19,7 @@ function traverseFilePathUntil(filename, predicate) {
18
19
  }
19
20
  // Update to path.dirname(url.fileURLToPath(import.meta.url)) whenever we update tsconfig target to ES2020
20
21
  // eslint-disable-next-line unicorn/prefer-module
21
- load_config_1.loadConfig.root = traverseFilePathUntil((_b = (_a = require.main) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : module.path, p => !p.includes('node_modules'));
22
+ load_config_1.loadConfig.root = traverseFilePathUntil(require.main?.path ?? module.path, (p) => !p.includes('node_modules'));
22
23
  exports.test = fancy_test_1.fancy
23
24
  .register('loadConfig', load_config_1.loadConfig)
24
25
  .register('command', command_1.command)
@@ -26,10 +27,10 @@ exports.test = fancy_test_1.fancy
26
27
  .register('hook', hook_1.default)
27
28
  .env({ NODE_ENV: 'test' });
28
29
  exports.default = exports.test;
30
+ var command_2 = require("./command");
31
+ Object.defineProperty(exports, "command", { enumerable: true, get: function () { return command_2.command; } });
29
32
  var core_1 = require("@oclif/core");
30
33
  Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return core_1.Config; } });
31
34
  var fancy_test_2 = require("fancy-test");
32
- Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return fancy_test_2.expect; } });
33
35
  Object.defineProperty(exports, "FancyTypes", { enumerable: true, get: function () { return fancy_test_2.FancyTypes; } });
34
- var command_2 = require("./command");
35
- Object.defineProperty(exports, "command", { enumerable: true, get: function () { return command_2.command; } });
36
+ Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return fancy_test_2.expect; } });
@@ -12,7 +12,7 @@ export declare function loadConfig(opts?: loadConfig.Options): {
12
12
  export declare namespace loadConfig {
13
13
  let root: string;
14
14
  interface Options {
15
- root?: string;
16
15
  reset?: boolean;
16
+ root?: string;
17
17
  }
18
18
  }
@@ -16,5 +16,6 @@ function loadConfig(opts = {}) {
16
16
  };
17
17
  }
18
18
  exports.loadConfig = loadConfig;
19
+ // eslint-disable-next-line @typescript-eslint/no-namespace
19
20
  (function (loadConfig) {
20
21
  })(loadConfig || (exports.loadConfig = loadConfig = {}));
package/package.json CHANGED
@@ -1,26 +1,33 @@
1
1
  {
2
2
  "name": "@oclif/test",
3
3
  "description": "test helpers for oclif components",
4
- "version": "3.0.2",
4
+ "version": "3.0.4",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/test/issues",
7
7
  "dependencies": {
8
- "@oclif/core": "^3.0.0-beta.19",
8
+ "@oclif/core": "^3.9.1",
9
9
  "chai": "^4.3.10",
10
10
  "fancy-test": "^3.0.1"
11
11
  },
12
12
  "devDependencies": {
13
+ "@commitlint/config-conventional": "^18.0.0",
14
+ "@oclif/prettier-config": "^0.2.1",
15
+ "@types/cli-progress": "^3.11.4",
13
16
  "@types/mocha": "^10",
14
17
  "@types/node": "^18",
15
- "eslint": "^8.49.0",
18
+ "commitlint": "^18.0.0",
19
+ "eslint": "^8.52.0",
16
20
  "eslint-config-oclif": "^5.0.0",
17
- "eslint-config-oclif-typescript": "^2.0.1",
21
+ "eslint-config-oclif-typescript": "^3.0.8",
22
+ "eslint-config-prettier": "^9.0.0",
18
23
  "globby": "^11.0.1",
24
+ "husky": "^8.0.3",
25
+ "lint-staged": "^15.0.2",
19
26
  "mocha": "^10",
20
- "nock": "^13.3.3",
27
+ "nock": "^13.3.6",
28
+ "prettier": "^3.0.3",
21
29
  "shx": "^0.3.3",
22
30
  "ts-node": "^10.9.1",
23
- "tslib": "^2.6.2",
24
31
  "typescript": "^5"
25
32
  },
26
33
  "engines": {
@@ -40,9 +47,10 @@
40
47
  "build": "shx rm -rf lib && tsc",
41
48
  "lint": "eslint . --ext .ts",
42
49
  "posttest": "yarn lint",
50
+ "prepare": "husky install",
43
51
  "prepublishOnly": "yarn run build",
44
- "test": "mocha --forbid-only \"test/**/*.test.ts\"",
45
- "pretest": "yarn build --noEmit && tsc -p test --noEmit"
52
+ "pretest": "yarn build --noEmit && tsc -p test --noEmit",
53
+ "test": "mocha --forbid-only \"test/**/*.test.ts\""
46
54
  },
47
55
  "types": "lib/index.d.ts"
48
56
  }