@contrail/cli 3.8.0-alpha.8de44ff → 3.8.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.
- package/README.md +83 -244
- package/dist/auth/login.js +1 -2
- package/dist/auth/login.spec.js +0 -17
- package/dist/baseFlags.d.ts +0 -4
- package/dist/baseFlags.js +1 -9
- package/dist/basecommand.d.ts +0 -2
- package/dist/basecommand.js +1 -7
- package/dist/commands/app/create.d.ts +0 -1
- package/dist/commands/app/delete.d.ts +0 -1
- package/dist/commands/app/extension/deploy.d.ts +0 -1
- package/dist/commands/app/extension/deployment/list.d.ts +0 -1
- package/dist/commands/app/getApiKey.d.ts +0 -1
- package/dist/commands/app/init.d.ts +0 -1
- package/dist/commands/app/install.d.ts +0 -1
- package/dist/commands/app/publish.d.ts +0 -1
- package/dist/commands/app/uninstall.d.ts +0 -1
- package/dist/commands/app/upgrade.d.ts +0 -1
- package/dist/commands/app/version/major.d.ts +0 -1
- package/dist/commands/app/version/minor.d.ts +0 -1
- package/dist/commands/app/version/patch.d.ts +0 -1
- package/dist/commands/app/version/premajor.d.ts +0 -1
- package/dist/commands/app/version/preminor.d.ts +0 -1
- package/dist/commands/app/version/prepatch.d.ts +0 -1
- package/dist/commands/app/version/prerelease.d.ts +0 -1
- package/dist/commands/config/create.d.ts +0 -2
- package/dist/commands/config/create.js +0 -1
- package/dist/commands/config/describe.d.ts +0 -2
- package/dist/commands/config/describe.js +4 -7
- package/dist/commands/config/list.d.ts +0 -2
- package/dist/commands/config/list.js +3 -2
- package/dist/commands/config/set.d.ts +0 -1
- package/dist/commands/config/set.js +6 -11
- package/dist/commands/config/use.d.ts +0 -2
- package/dist/commands/config/use.js +0 -4
- package/dist/commands/entities/create.d.ts +0 -1
- package/dist/commands/entities/delete.d.ts +0 -1
- package/dist/commands/entities/get.d.ts +0 -1
- package/dist/commands/entities/update.d.ts +0 -1
- package/dist/commands/feature-flags/export.d.ts +0 -1
- package/dist/commands/feature-flags/import.d.ts +0 -1
- package/dist/commands/file/upload.d.ts +0 -1
- package/dist/commands/groups/export.d.ts +0 -1
- package/dist/commands/groups/import.d.ts +0 -1
- package/dist/commands/instance/export.d.ts +0 -1
- package/dist/commands/instance/import.d.ts +0 -1
- package/dist/commands/load/colors.d.ts +0 -1
- package/dist/commands/load/custom-entity.d.ts +0 -1
- package/dist/commands/load/line-sheet.d.ts +0 -1
- package/dist/commands/load/upload-and-load.d.ts +0 -1
- package/dist/commands/load-local/index.d.ts +0 -1
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/org-config/export.d.ts +0 -1
- package/dist/commands/org-config/import.d.ts +0 -1
- package/dist/commands/projects/export.d.ts +0 -1
- package/dist/commands/projects/list.d.ts +0 -1
- package/dist/commands/projects/load.d.ts +0 -1
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +0 -1
- package/dist/commands/types/getAll.d.ts +0 -1
- package/dist/commands/types/getOptionSets.d.ts +0 -1
- package/dist/commands/types/loadAll.d.ts +0 -1
- package/dist/commands/types/mergeOptionSets.d.ts +0 -1
- package/dist/commands/types/mergeTypeProperties.d.ts +0 -1
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +0 -1
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +0 -1
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +0 -1
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +0 -1
- package/dist/commands/types/parseTypesFromFiles.d.ts +0 -1
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +0 -1
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +0 -1
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +0 -1
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +0 -1
- package/dist/commands/types/uploadOptionSets.d.ts +0 -1
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +0 -1
- package/dist/commands/types/uploadRuleSets.d.ts +0 -1
- package/dist/commands/types/uploadTypeOverrides.d.ts +0 -1
- package/dist/commands/types/uploadTypePolicies.d.ts +0 -1
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +0 -1
- package/dist/commands/types/uploadTypes.d.ts +0 -1
- package/dist/commands/users/export.d.ts +0 -1
- package/dist/commands/users/import.d.ts +0 -1
- package/dist/commands/webhooks/create.d.ts +0 -1
- package/dist/commands/webhooks/delete.d.ts +0 -1
- package/dist/commands/webhooks/getWebhookTrigger.d.ts +0 -1
- package/dist/commands/webhooks/list.d.ts +0 -1
- package/dist/commands/workflow-template-definitions/install.d.ts +0 -1
- package/dist/commands/workflow-template-definitions/list.d.ts +0 -1
- package/dist/commands/workflow-templates/delete.d.ts +0 -1
- package/dist/commands/workflow-templates/export.d.ts +0 -1
- package/dist/commands/workflow-templates/list.d.ts +0 -1
- package/dist/commands/workflow-templates/load.d.ts +0 -1
- package/dist/helpers/config/config.d.ts +2 -3
- package/dist/helpers/config/config.js +42 -49
- package/oclif.manifest.json +9 -549
- package/package.json +1 -1
- package/dist/basecommand.spec.d.ts +0 -1
- package/dist/basecommand.spec.js +0 -69
- package/dist/helpers/config/config.spec.d.ts +0 -1
- package/dist/helpers/config/config.spec.js +0 -79
- package/dist/helpers/config/redact-tokens.d.ts +0 -1
- package/dist/helpers/config/redact-tokens.js +0 -14
- package/dist/helpers/config/redact-tokens.spec.d.ts +0 -1
- package/dist/helpers/config/redact-tokens.spec.js +0 -24
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/basecommand.spec.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const os_1 = require("os");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const basecommand_1 = require("./basecommand");
|
|
8
|
-
const set_1 = tslib_1.__importDefault(require("./commands/config/set"));
|
|
9
|
-
const config_1 = require("./helpers/config/config");
|
|
10
|
-
jest.mock('node:os', () => {
|
|
11
|
-
const actualOs = jest.requireActual('node:os');
|
|
12
|
-
return {
|
|
13
|
-
...actualOs,
|
|
14
|
-
homedir: () => `${actualOs.tmpdir()}/contrail-cli-basecommand-${process.pid}`,
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
jest.mock('./logger', () => ({
|
|
18
|
-
__esModule: true,
|
|
19
|
-
default: { debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() },
|
|
20
|
-
}));
|
|
21
|
-
class ConfigNameCommand extends basecommand_1.BaseCommand {
|
|
22
|
-
skipConfirmEnv = true;
|
|
23
|
-
static flags = { ...basecommand_1.BaseCommand.baseFlags };
|
|
24
|
-
async run() {
|
|
25
|
-
return (0, config_1.fetchConfigNameForRun)();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const PACKAGE_ROOT = (0, path_1.resolve)(__dirname, '..');
|
|
29
|
-
const home = (0, path_1.join)((0, os_1.tmpdir)(), `contrail-cli-basecommand-${process.pid}`);
|
|
30
|
-
describe('config selection on a command', () => {
|
|
31
|
-
const originalConfigEnv = process.env.CONTRAIL_CLI_CONFIG;
|
|
32
|
-
let configDir;
|
|
33
|
-
const writeJson = (name, content) => (0, fs_1.writeFileSync)((0, path_1.join)(configDir, `${name}.json`), JSON.stringify(content));
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
configDir = (0, path_1.join)(home, '.vibeiq', 'configs');
|
|
36
|
-
(0, fs_1.mkdirSync)(configDir, { recursive: true });
|
|
37
|
-
writeJson('config', { configInUse: 'pointer' });
|
|
38
|
-
for (const name of ['pointer', 'from-env', 'from-flag']) {
|
|
39
|
-
writeJson(name, { orgSlug: name });
|
|
40
|
-
}
|
|
41
|
-
delete process.env.CONTRAIL_CLI_CONFIG;
|
|
42
|
-
});
|
|
43
|
-
afterEach(() => {
|
|
44
|
-
if (originalConfigEnv === undefined) {
|
|
45
|
-
delete process.env.CONTRAIL_CLI_CONFIG;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
process.env.CONTRAIL_CLI_CONFIG = originalConfigEnv;
|
|
49
|
-
}
|
|
50
|
-
(0, fs_1.rmSync)(home, { recursive: true, force: true });
|
|
51
|
-
});
|
|
52
|
-
it('should use the config chosen with config use when no flag or env var is set', async () => {
|
|
53
|
-
expect(await ConfigNameCommand.run([], PACKAGE_ROOT)).toBe('pointer');
|
|
54
|
-
});
|
|
55
|
-
it('should use CONTRAIL_CLI_CONFIG over the config chosen with config use', async () => {
|
|
56
|
-
process.env.CONTRAIL_CLI_CONFIG = 'from-env';
|
|
57
|
-
expect(await ConfigNameCommand.run([], PACKAGE_ROOT)).toBe('from-env');
|
|
58
|
-
});
|
|
59
|
-
it('should use --config over CONTRAIL_CLI_CONFIG', async () => {
|
|
60
|
-
process.env.CONTRAIL_CLI_CONFIG = 'from-env';
|
|
61
|
-
expect(await ConfigNameCommand.run(['--config', 'from-flag'], PACKAGE_ROOT)).toBe('from-flag');
|
|
62
|
-
});
|
|
63
|
-
it('should create the named config when config set names one that does not exist', async () => {
|
|
64
|
-
await set_1.default.run(['--orgSlug', 'acme', '--config', 'new-config'], PACKAGE_ROOT);
|
|
65
|
-
expect(JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(configDir, 'new-config.json')).toString())).toEqual({
|
|
66
|
-
orgSlug: 'acme',
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs_1 = require("fs");
|
|
4
|
-
const os_1 = require("os");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
let mockHome;
|
|
7
|
-
jest.mock('node:os', () => ({
|
|
8
|
-
...jest.requireActual('node:os'),
|
|
9
|
-
homedir: () => mockHome,
|
|
10
|
-
}));
|
|
11
|
-
jest.mock('../../logger', () => ({
|
|
12
|
-
__esModule: true,
|
|
13
|
-
default: { debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() },
|
|
14
|
-
}));
|
|
15
|
-
const DEV = { apiGateway: 'https://api.dev.vibeiq.com/dev/api', orgSlug: 'adam-zone-1' };
|
|
16
|
-
const PROD = { apiGateway: 'https://api.vibeiq.com/prod/api', orgSlug: 'adam-prod-1' };
|
|
17
|
-
describe('config selection', () => {
|
|
18
|
-
let configDir;
|
|
19
|
-
let config;
|
|
20
|
-
const writeJson = (name, content) => (0, fs_1.writeFileSync)((0, path_1.join)(configDir, `${name}.json`), JSON.stringify(content));
|
|
21
|
-
const readJson = (name) => JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(configDir, `${name}.json`)).toString());
|
|
22
|
-
const switchPointerTo = (name) => writeJson('config', { configInUse: name });
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
mockHome = (0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), 'contrail-cli-config-'));
|
|
25
|
-
configDir = (0, path_1.join)(mockHome, '.vibeiq', 'configs');
|
|
26
|
-
(0, fs_1.mkdirSync)(configDir, { recursive: true });
|
|
27
|
-
writeJson('dev', DEV);
|
|
28
|
-
writeJson('prod', PROD);
|
|
29
|
-
switchPointerTo('dev');
|
|
30
|
-
jest.isolateModules(() => {
|
|
31
|
-
config = require('./config');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
afterEach(() => {
|
|
35
|
-
jest.restoreAllMocks();
|
|
36
|
-
(0, fs_1.rmSync)(mockHome, { recursive: true, force: true });
|
|
37
|
-
});
|
|
38
|
-
it('should use the config chosen with config use when none is named', async () => {
|
|
39
|
-
config.selectConfigForRun(undefined);
|
|
40
|
-
expect(await config.getConfig()).toEqual(DEV);
|
|
41
|
-
});
|
|
42
|
-
it('should use the named config over the one chosen with config use', async () => {
|
|
43
|
-
config.selectConfigForRun('prod');
|
|
44
|
-
expect(await config.getConfig()).toEqual(PROD);
|
|
45
|
-
});
|
|
46
|
-
it('should keep reading and saving the config it started with after another terminal switches', async () => {
|
|
47
|
-
config.selectConfigForRun(undefined);
|
|
48
|
-
await config.getConfig();
|
|
49
|
-
switchPointerTo('prod');
|
|
50
|
-
await config.storeConfig({ apiUserToken: 'refreshed-dev-token' });
|
|
51
|
-
expect(await config.getConfig()).toEqual({ ...DEV, apiUserToken: 'refreshed-dev-token' });
|
|
52
|
-
expect(readJson('prod')).toEqual(PROD);
|
|
53
|
-
});
|
|
54
|
-
it('should fail when no config is named and none is chosen with config use', async () => {
|
|
55
|
-
writeJson('config', {});
|
|
56
|
-
config.selectConfigForRun(undefined);
|
|
57
|
-
await expect(config.getConfig()).rejects.toThrow('No config selected.');
|
|
58
|
-
});
|
|
59
|
-
it('should fail and list the configs when the named config does not exist', async () => {
|
|
60
|
-
config.selectConfigForRun('staging');
|
|
61
|
-
await expect(config.getConfig()).rejects.toThrow('No config named "staging". Pass --config or set CONTRAIL_CLI_CONFIG to one of: dev, prod');
|
|
62
|
-
});
|
|
63
|
-
it('should leave the previous config intact when a save dies partway', async () => {
|
|
64
|
-
config.selectConfigForRun('dev');
|
|
65
|
-
const realWriteFile = fs_1.promises.writeFile;
|
|
66
|
-
jest.spyOn(fs_1.promises, 'writeFile').mockImplementationOnce(async (path) => {
|
|
67
|
-
await realWriteFile(path, '{"apiGatew');
|
|
68
|
-
throw new Error('ENOSPC: no space left on device');
|
|
69
|
-
});
|
|
70
|
-
await expect(config.storeConfig({ apiUserToken: 'new-token' })).rejects.toThrow('ENOSPC');
|
|
71
|
-
expect(readJson('dev')).toEqual(DEV);
|
|
72
|
-
expect((0, fs_1.readdirSync)(configDir).filter((file) => file.endsWith('.tmp'))).toEqual([]);
|
|
73
|
-
});
|
|
74
|
-
it('should keep a saved config readable only by its owner', async () => {
|
|
75
|
-
config.selectConfigForRun('dev');
|
|
76
|
-
await config.storeConfig({ apiUserToken: 'new-token' });
|
|
77
|
-
expect((0, fs_1.statSync)((0, path_1.join)(configDir, 'dev.json')).mode & 0o777).toBe(0o600);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function redactTokens(config: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.redactTokens = void 0;
|
|
4
|
-
const TOKEN_FIELDS = ['apiUserToken', 'apiRefreshToken'];
|
|
5
|
-
function redactTokens(config) {
|
|
6
|
-
const redacted = { ...config };
|
|
7
|
-
for (const field of TOKEN_FIELDS) {
|
|
8
|
-
if (redacted[field]) {
|
|
9
|
-
redacted[field] = '[redacted]';
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return redacted;
|
|
13
|
-
}
|
|
14
|
-
exports.redactTokens = redactTokens;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const redact_tokens_1 = require("./redact-tokens");
|
|
4
|
-
describe('redactTokens', () => {
|
|
5
|
-
it('should hide the access and refresh tokens and keep the org and environment', () => {
|
|
6
|
-
expect((0, redact_tokens_1.redactTokens)({
|
|
7
|
-
apiGateway: 'https://api.dev.vibeiq.com/dev/api',
|
|
8
|
-
orgSlug: 'adam-zone-1',
|
|
9
|
-
apiUserToken: 'secret-access',
|
|
10
|
-
apiRefreshToken: 'secret-refresh',
|
|
11
|
-
})).toEqual({
|
|
12
|
-
apiGateway: 'https://api.dev.vibeiq.com/dev/api',
|
|
13
|
-
orgSlug: 'adam-zone-1',
|
|
14
|
-
apiUserToken: '[redacted]',
|
|
15
|
-
apiRefreshToken: '[redacted]',
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
it('should leave a config without tokens unchanged', () => {
|
|
19
|
-
expect((0, redact_tokens_1.redactTokens)({ orgSlug: 'adam-zone-1', apiRefreshToken: null })).toEqual({
|
|
20
|
-
orgSlug: 'adam-zone-1',
|
|
21
|
-
apiRefreshToken: null,
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
});
|