@heroku/heroku-cli-util 9.0.1-beta.2 → 9.0.2
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/index.d.ts +0 -11
- package/dist/index.js +1 -14
- package/package.json +4 -6
- package/dist/test-helpers/expect-output.d.ts +0 -2
- package/dist/test-helpers/expect-output.js +0 -16
- package/dist/test-helpers/init.d.ts +0 -1
- package/dist/test-helpers/init.js +0 -17
- package/dist/test-helpers/run-command.d.ts +0 -9
- package/dist/test-helpers/run-command.js +0 -43
- package/dist/test-helpers/stub-output.d.ts +0 -4
- package/dist/test-helpers/stub-output.js +0 -35
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { initCliTest } from './test-helpers/init';
|
|
2
|
-
import { restoreStdoutStderr, setupStdoutStderr, stderr, stdout } from './test-helpers/stub-output';
|
|
3
1
|
import { AmbiguousError } from './types/errors/ambiguous';
|
|
4
2
|
import { NotFound } from './types/errors/not-found';
|
|
5
3
|
import { AddOnAttachmentWithConfigVarsAndPlan, AddOnWithRelatedData, Link } from './types/pg/data-api';
|
|
@@ -14,15 +12,6 @@ import { styledJSON } from './ux/styled-json';
|
|
|
14
12
|
import { styledObject } from './ux/styled-object';
|
|
15
13
|
import { table } from './ux/table';
|
|
16
14
|
import { wait } from './ux/wait';
|
|
17
|
-
export declare const testHelpers: {
|
|
18
|
-
expectOutput: (actual: string, expected: string) => Chai.Assertion;
|
|
19
|
-
initCliTest: typeof initCliTest;
|
|
20
|
-
restoreStdoutStderr: typeof restoreStdoutStderr;
|
|
21
|
-
runCommand: (Cmd: import("./test-helpers/run-command").GenericCmd, args?: string[], printStd?: boolean) => Promise<any>;
|
|
22
|
-
setupStdoutStderr: typeof setupStdoutStderr;
|
|
23
|
-
stderr: typeof stderr;
|
|
24
|
-
stdout: typeof stdout;
|
|
25
|
-
};
|
|
26
15
|
export declare const types: {
|
|
27
16
|
errors: {
|
|
28
17
|
AmbiguousError: typeof AmbiguousError;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hux = exports.utils = exports.types =
|
|
4
|
-
const expect_output_1 = require("./test-helpers/expect-output");
|
|
5
|
-
const init_1 = require("./test-helpers/init");
|
|
6
|
-
const run_command_1 = require("./test-helpers/run-command");
|
|
7
|
-
const stub_output_1 = require("./test-helpers/stub-output");
|
|
3
|
+
exports.hux = exports.utils = exports.types = void 0;
|
|
8
4
|
const ambiguous_1 = require("./types/errors/ambiguous");
|
|
9
5
|
const not_found_1 = require("./types/errors/not-found");
|
|
10
6
|
const databases_1 = require("./utils/pg/databases");
|
|
@@ -17,15 +13,6 @@ const styled_json_1 = require("./ux/styled-json");
|
|
|
17
13
|
const styled_object_1 = require("./ux/styled-object");
|
|
18
14
|
const table_1 = require("./ux/table");
|
|
19
15
|
const wait_1 = require("./ux/wait");
|
|
20
|
-
exports.testHelpers = {
|
|
21
|
-
expectOutput: expect_output_1.default,
|
|
22
|
-
initCliTest: init_1.initCliTest,
|
|
23
|
-
restoreStdoutStderr: stub_output_1.restoreStdoutStderr,
|
|
24
|
-
runCommand: run_command_1.runCommand,
|
|
25
|
-
setupStdoutStderr: stub_output_1.setupStdoutStderr,
|
|
26
|
-
stderr: stub_output_1.stderr,
|
|
27
|
-
stdout: stub_output_1.stdout,
|
|
28
|
-
};
|
|
29
16
|
exports.types = {
|
|
30
17
|
errors: {
|
|
31
18
|
AmbiguousError: ambiguous_1.AmbiguousError,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "commonjs",
|
|
3
3
|
"name": "@heroku/heroku-cli-util",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.2",
|
|
5
5
|
"description": "Set of helpful CLI utilities",
|
|
6
6
|
"author": "Heroku",
|
|
7
7
|
"license": "ISC",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"devDependencies": {
|
|
14
|
+
"@heroku-cli/test-utils": "0.1.1",
|
|
14
15
|
"@heroku-cli/schema": "^2.0.0",
|
|
15
16
|
"@types/chai": "^4.3.13",
|
|
16
17
|
"@types/chai-as-promised": "^8.0.2",
|
|
@@ -27,8 +28,10 @@
|
|
|
27
28
|
"eslint-plugin-import": "^2.31.0",
|
|
28
29
|
"eslint-plugin-mocha": "^10.4.3",
|
|
29
30
|
"mocha": "^10.8.2",
|
|
31
|
+
"nock": "^13.2.9",
|
|
30
32
|
"nyc": "^17.1.0",
|
|
31
33
|
"sinon": "^18.0.1",
|
|
34
|
+
"stdout-stderr": "^0.1.13",
|
|
32
35
|
"strip-ansi": "^6",
|
|
33
36
|
"ts-node": "^10.9.2",
|
|
34
37
|
"tsconfig-paths": "^4.2.0",
|
|
@@ -41,8 +44,6 @@
|
|
|
41
44
|
"@heroku/http-call": "^5.4.0",
|
|
42
45
|
"@oclif/core": "^2.16.0",
|
|
43
46
|
"debug": "^4.4.0",
|
|
44
|
-
"nock": "^13.2.9",
|
|
45
|
-
"stdout-stderr": "^0.1.13",
|
|
46
47
|
"tunnel-ssh": "4.1.6"
|
|
47
48
|
},
|
|
48
49
|
"engines": {
|
|
@@ -54,9 +55,6 @@
|
|
|
54
55
|
"source-map-support/register",
|
|
55
56
|
"test/hooks.ts"
|
|
56
57
|
],
|
|
57
|
-
"file": [
|
|
58
|
-
"src/test-helpers/stub-output.ts"
|
|
59
|
-
],
|
|
60
58
|
"watch-extensions": "ts",
|
|
61
59
|
"recursive": true,
|
|
62
60
|
"reporter": "spec",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const chai_1 = require("chai");
|
|
4
|
-
function stripIndents(str) {
|
|
5
|
-
str = str.trim().replace(/\s+$/gm, '');
|
|
6
|
-
const indent = (str.match(/^\s+[^$]/m) || [''])[0].length - 1;
|
|
7
|
-
const regexp = new RegExp(`^s{${indent}}`, 'mg');
|
|
8
|
-
return str.replace(regexp, '');
|
|
9
|
-
}
|
|
10
|
-
const expectOutput = function (actual, expected) {
|
|
11
|
-
// it can be helpful to strip all hyphens & spaces when migrating tests before perfecting
|
|
12
|
-
// use `.replace(/[\s─]/g, '')` on both actual & expected until tests pass, then remove, and paste actual into expected
|
|
13
|
-
return (0, chai_1.expect)(actual.trim().replace(/\s+$/gm, ''))
|
|
14
|
-
.to.equal(stripIndents(expected));
|
|
15
|
-
};
|
|
16
|
-
exports.default = expectOutput;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function initCliTest(): void;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initCliTest = initCliTest;
|
|
4
|
-
const path = require('node:path');
|
|
5
|
-
const { color } = require('@heroku-cli/color');
|
|
6
|
-
const nock = require('nock');
|
|
7
|
-
function initCliTest() {
|
|
8
|
-
// eslint-disable-next-line no-multi-assign
|
|
9
|
-
process.env.TS_NODE_PROJECT = path.resolve('test/tsconfig.json');
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
-
global.columns = '120';
|
|
12
|
-
color.enabled = false;
|
|
13
|
-
nock.disableNetConnect();
|
|
14
|
-
if (process.env.ENABLE_NET_CONNECT === 'true') {
|
|
15
|
-
nock.enableNetConnect();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Command } from '@heroku-cli/command';
|
|
2
|
-
import { APIClient } from '@heroku-cli/command';
|
|
3
|
-
import { Config } from '@oclif/core';
|
|
4
|
-
type CmdConstructorParams = ConstructorParameters<typeof Command>;
|
|
5
|
-
export type GenericCmd = new (...args: CmdConstructorParams) => Command;
|
|
6
|
-
export declare const runCommand: (Cmd: GenericCmd, args?: string[], printStd?: boolean) => Promise<any>;
|
|
7
|
-
export declare const getConfig: () => Promise<Config>;
|
|
8
|
-
export declare const getHerokuAPI: () => Promise<APIClient>;
|
|
9
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHerokuAPI = exports.getConfig = exports.runCommand = void 0;
|
|
4
|
-
const command_1 = require("@heroku-cli/command");
|
|
5
|
-
const core_1 = require("@oclif/core");
|
|
6
|
-
const stdout_stderr_1 = require("stdout-stderr");
|
|
7
|
-
const stopMock = () => {
|
|
8
|
-
stdout_stderr_1.stdout.stop();
|
|
9
|
-
stdout_stderr_1.stderr.stop();
|
|
10
|
-
};
|
|
11
|
-
const runCommand = async (Cmd, args = [], printStd = false) => {
|
|
12
|
-
const conf = await (0, exports.getConfig)();
|
|
13
|
-
const instance = new Cmd(args, conf);
|
|
14
|
-
if (printStd) {
|
|
15
|
-
stdout_stderr_1.stdout.print = true;
|
|
16
|
-
stdout_stderr_1.stderr.print = true;
|
|
17
|
-
}
|
|
18
|
-
stdout_stderr_1.stdout.start();
|
|
19
|
-
stdout_stderr_1.stderr.start();
|
|
20
|
-
return instance
|
|
21
|
-
.run()
|
|
22
|
-
.then(args => {
|
|
23
|
-
stopMock();
|
|
24
|
-
return args;
|
|
25
|
-
})
|
|
26
|
-
.catch((error) => {
|
|
27
|
-
stopMock();
|
|
28
|
-
throw error;
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
exports.runCommand = runCommand;
|
|
32
|
-
const getConfig = async () => {
|
|
33
|
-
const pjsonPath = require.resolve('../../package.json');
|
|
34
|
-
const conf = new core_1.Config({ root: pjsonPath });
|
|
35
|
-
await conf.load();
|
|
36
|
-
return conf;
|
|
37
|
-
};
|
|
38
|
-
exports.getConfig = getConfig;
|
|
39
|
-
const getHerokuAPI = async () => {
|
|
40
|
-
const conf = await (0, exports.getConfig)();
|
|
41
|
-
return new command_1.APIClient(conf);
|
|
42
|
-
};
|
|
43
|
-
exports.getHerokuAPI = getHerokuAPI;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupStdoutStderr = setupStdoutStderr;
|
|
4
|
-
exports.restoreStdoutStderr = restoreStdoutStderr;
|
|
5
|
-
exports.stdout = stdout;
|
|
6
|
-
exports.stderr = stderr;
|
|
7
|
-
const sinon = require("sinon");
|
|
8
|
-
let stdoutWriteStub;
|
|
9
|
-
let stdoutOutput = '';
|
|
10
|
-
let stderrWriteStub;
|
|
11
|
-
let stderrOutput = '';
|
|
12
|
-
function setupStdoutStderr() {
|
|
13
|
-
stdoutOutput = '';
|
|
14
|
-
stdoutWriteStub = sinon.stub(process.stdout, 'write').callsFake((str) => {
|
|
15
|
-
stdoutOutput += str.toString();
|
|
16
|
-
return true;
|
|
17
|
-
});
|
|
18
|
-
stderrOutput = '';
|
|
19
|
-
stderrWriteStub = sinon.stub(process.stderr, 'write').callsFake((str) => {
|
|
20
|
-
stderrOutput += str.toString();
|
|
21
|
-
return true;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function restoreStdoutStderr() {
|
|
25
|
-
stdoutWriteStub.restore();
|
|
26
|
-
stdoutOutput = '';
|
|
27
|
-
stderrWriteStub.restore();
|
|
28
|
-
stderrOutput = '';
|
|
29
|
-
}
|
|
30
|
-
function stdout() {
|
|
31
|
-
return stdoutOutput;
|
|
32
|
-
}
|
|
33
|
-
function stderr() {
|
|
34
|
-
return stderrOutput;
|
|
35
|
-
}
|