codefresh 1.2.3 → 1.2.5
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/interface/cli/completion/completion.spec.js +107 -75
- package/lib/interface/cli/completion/tree.json +1 -1
- package/lib/interface/cli/helpers/cli-config.js +4 -2
- package/lib/interface/cli/helpers/general.js +1 -1
- package/lib/interface/cli/helpers/validation.js +1 -1
- package/lib/logic/cli-config/Manager.js +3 -3
- package/lib/logic/cli-config/manager.spec.js +4 -4
- package/lib/logic/entities/Entity.js +1 -1
- package/lib/output/types/yaml.output.js +2 -2
- package/package.json +3 -3
|
@@ -68,86 +68,118 @@ jest.mock('./context/create.completion', () => { // eslint-disable-line
|
|
|
68
68
|
};
|
|
69
69
|
}, { virtual: true });
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
const existsSync = (p) => {
|
|
73
|
-
if (p.startsWith(`${mockCwd()}/`)) {
|
|
74
|
-
p = p.replace(`${mockCwd()}/`, '');
|
|
75
|
-
}
|
|
76
|
-
if (p.startsWith(mockCwd())) {
|
|
77
|
-
p = p.replace(mockCwd(), '');
|
|
78
|
-
}
|
|
79
|
-
switch (p) {
|
|
80
|
-
case '':
|
|
81
|
-
case 'libe/':
|
|
82
|
-
case 'libe':
|
|
83
|
-
case 'another':
|
|
84
|
-
case 'another/':
|
|
85
|
-
case 'libe/cli':
|
|
86
|
-
case 'libe/cli/':
|
|
87
|
-
return true;
|
|
88
|
-
default:
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const lstatSync = (p) => {
|
|
93
|
-
let isFile = false;
|
|
94
|
-
let isDir = true;
|
|
95
|
-
if (p.startsWith(`${mockCwd()}/`)) {
|
|
96
|
-
p = p.replace(`${mockCwd()}/`, '');
|
|
97
|
-
}
|
|
98
|
-
if (p.startsWith(mockCwd())) {
|
|
99
|
-
p = p.replace(mockCwd(), '');
|
|
100
|
-
}
|
|
101
|
-
switch (p) {
|
|
102
|
-
case 'some.yaml':
|
|
103
|
-
case 'libe/another.yaml':
|
|
104
|
-
isFile = true;
|
|
105
|
-
isDir = false;
|
|
106
|
-
break;
|
|
107
|
-
default:
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
isFile: () => isFile,
|
|
112
|
-
isDirectory: () => isDir,
|
|
113
|
-
};
|
|
114
|
-
};
|
|
71
|
+
// Mock fs locally to not break SDK loading
|
|
115
72
|
|
|
116
|
-
|
|
117
|
-
const result = lstatSync(p);
|
|
118
|
-
return callback(null, result);
|
|
119
|
-
};
|
|
73
|
+
process.argv = []; // completion is sensitive to process args
|
|
120
74
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
case '':
|
|
130
|
-
return ['libe', 'like', 'another', 'some.yaml'];
|
|
131
|
-
case 'libe':
|
|
132
|
-
case 'libe/':
|
|
133
|
-
return ['cli', 'clo', 'another.yaml'];
|
|
134
|
-
default:
|
|
135
|
-
return [];
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
return Object.assign(jest.requireActual('fs'), {
|
|
139
|
-
lstat: (p, callback) => callback(null, lstatSync(p)),
|
|
140
|
-
stat: (p, callback) => callback(null, lstatSync(p)),
|
|
141
|
-
access: (path, c) => c(null, true),
|
|
142
|
-
readdirSync,
|
|
143
|
-
existsSync,
|
|
144
|
-
lstatSync,
|
|
75
|
+
describe('codefresh completions', () => {
|
|
76
|
+
let originalArgv;
|
|
77
|
+
let originalEnv;
|
|
78
|
+
|
|
79
|
+
beforeAll(() => {
|
|
80
|
+
// Save original state
|
|
81
|
+
originalArgv = [...process.argv];
|
|
82
|
+
originalEnv = { ...process.env };
|
|
145
83
|
});
|
|
146
|
-
});
|
|
147
84
|
|
|
148
|
-
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
// Reset to clean state for each test
|
|
87
|
+
process.argv = [...originalArgv];
|
|
88
|
+
|
|
89
|
+
// Mock fs methods for completion tests
|
|
90
|
+
const fs = require('fs');
|
|
91
|
+
const originalFs = jest.requireActual('fs');
|
|
92
|
+
|
|
93
|
+
// Mock readdirSync
|
|
94
|
+
jest.spyOn(fs, 'readdirSync').mockImplementation((p) => {
|
|
95
|
+
// Allow SDK to load properly - use real fs for node_modules
|
|
96
|
+
if (p.includes('node_modules') || p.includes('codefresh-sdk')) {
|
|
97
|
+
return originalFs.readdirSync(p);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Completion test logic for local paths
|
|
101
|
+
let testPath = p;
|
|
102
|
+
if (testPath.startsWith(`${mockCwd()}/`)) {
|
|
103
|
+
testPath = testPath.replace(`${mockCwd()}/`, '');
|
|
104
|
+
}
|
|
105
|
+
if (testPath.startsWith(mockCwd())) {
|
|
106
|
+
testPath = testPath.replace(mockCwd(), '');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
switch (testPath) {
|
|
110
|
+
case '':
|
|
111
|
+
return ['libe', 'like', 'another', 'some.yaml'];
|
|
112
|
+
case 'libe':
|
|
113
|
+
case 'libe/':
|
|
114
|
+
return ['cli', 'clo', 'another.yaml'];
|
|
115
|
+
default:
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
149
119
|
|
|
150
|
-
|
|
120
|
+
// Mock existsSync
|
|
121
|
+
jest.spyOn(fs, 'existsSync').mockImplementation((p) => {
|
|
122
|
+
let testPath = p;
|
|
123
|
+
if (testPath.startsWith(`${mockCwd()}/`)) {
|
|
124
|
+
testPath = testPath.replace(`${mockCwd()}/`, '');
|
|
125
|
+
}
|
|
126
|
+
if (testPath.startsWith(mockCwd())) {
|
|
127
|
+
testPath = testPath.replace(mockCwd(), '');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
switch (testPath) {
|
|
131
|
+
case '':
|
|
132
|
+
case 'libe/':
|
|
133
|
+
case 'libe':
|
|
134
|
+
case 'another':
|
|
135
|
+
case 'another/':
|
|
136
|
+
case 'libe/cli':
|
|
137
|
+
case 'libe/cli/':
|
|
138
|
+
return true;
|
|
139
|
+
default:
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Mock lstatSync
|
|
145
|
+
jest.spyOn(fs, 'lstatSync').mockImplementation((p) => {
|
|
146
|
+
let isFile = false;
|
|
147
|
+
let isDir = true;
|
|
148
|
+
let testPath = p;
|
|
149
|
+
if (testPath.startsWith(`${mockCwd()}/`)) {
|
|
150
|
+
testPath = testPath.replace(`${mockCwd()}/`, '');
|
|
151
|
+
}
|
|
152
|
+
if (testPath.startsWith(mockCwd())) {
|
|
153
|
+
testPath = testPath.replace(mockCwd(), '');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
switch (testPath) {
|
|
157
|
+
case 'some.yaml':
|
|
158
|
+
case 'libe/another.yaml':
|
|
159
|
+
isFile = true;
|
|
160
|
+
isDir = false;
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
isFile: () => isFile,
|
|
168
|
+
isDirectory: () => isDir,
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
afterEach(() => {
|
|
174
|
+
// Restore real fs methods
|
|
175
|
+
jest.restoreAllMocks();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
afterAll(() => {
|
|
179
|
+
// Restore original state
|
|
180
|
+
process.argv = originalArgv;
|
|
181
|
+
process.env = originalEnv;
|
|
182
|
+
});
|
|
151
183
|
describe('static', () => {
|
|
152
184
|
it('should not display any completions when no word is entered', async () => {
|
|
153
185
|
const result = await getCompletion([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"codefresh":{"analyze":{},"completion":{},"completions":{"alias":"completion"},"tag":{},"untag":{},"run":{"__optionHandlers":["../commands/pipeline/run.completion.js"]},"offline-logs":{"ensure-index":{},"offload-to-collection":{},"offload-to-file":{}},"add":{"repository":{},"repo":{"alias":"repository"}},"annotate":{"image":{},"img":{"alias":"image"}},"patch":{"__optionHandlers":["../commands/root/apply.completion.js"],"agent":{"__optionHandlers":["../commands/root/apply.completion.js"]},"board":{"__optionHandlers":["../commands/root/apply.completion.js"]},"project":{"__optionHandlers":["../commands/root/apply.completion.js"]},"section":{"__optionHandlers":["../commands/root/apply.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"tokens":{"__optionHandlers":["../commands/root/apply.completion.js"]},"token":{"alias":"tokens"},"system-runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/apply.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"helm-repo":{"__optionHandlers":["../commands/root/apply.completion.js"]},"context":{"__optionHandlers":["../commands/root/apply.completion.js"]},"ctx":{"alias":"context"}},"assign":{"system-runtime-environments":{},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"auth":{"create-context":{},"current-context":{},"get-contexts":{},"use-context":{}},"components":{"download":{},"update":{}},"create":{"__optionHandlers":["../commands/root/create.completion.js"],"agent":{"__optionHandlers":["../commands/root/create.completion.js"]},"clusters":{"__optionHandlers":["../commands/root/create.completion.js"]},"cluster":{"alias":"clusters"},"board":{"__optionHandlers":["../commands/root/create.completion.js"]},"annotation":{"__optionHandlers":["../commands/root/create.completion.js"]},"composition":{"__optionHandlers":["../commands/composition/create.completion.js","../commands/root/create.completion.js"]},"com":{"alias":"composition"},"project":{"__optionHandlers":["../commands/root/create.completion.js"]},"section":{"__optionHandlers":["../commands/root/create.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/create.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"token":{"__optionHandlers":["../commands/root/create.completion.js"]},"teams":{"__optionHandlers":["../commands/root/create.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"helm-repo":{"__optionHandlers":["../commands/root/create.completion.js"]},"registry":{"__optionHandlers":["../commands/root/create.completion.js"],"standard":{"__optionHandlers":["../commands/root/create.completion.js"]}},"trigger":{"__optionHandlers":["../commands/root/create.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/create.completion.js"]},"te":{"alias":"trigger-event"},"workflow-data-item":{"__optionHandlers":["../commands/root/create.completion.js"]},"wdi":{"alias":"workflow-data-item"},"context":{"__optionHandlers":["../commands/root/create.completion.js"],"config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}}},"ctx":{"alias":"context","config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}}}},"delete":{"__optionHandlers":["../commands/root/delete.completion.js"],"agent":{"__optionHandlers":["../commands/root/delete.completion.js"]},"board":{"__optionHandlers":["../commands/root/delete.completion.js"]},"annotation":{"__optionHandlers":["../commands/root/delete.completion.js"]},"environment":{"__optionHandlers":["../commands/root/delete.completion.js"]},"env":{"alias":"environment"},"composition":{"__optionHandlers":["../commands/root/delete.completion.js"]},"com":{"alias":"composition"},"cluster":{"__optionHandlers":["../commands/root/delete.completion.js"]},"clusters":{"alias":"cluster"},"pipeline":{"__optionHandlers":["../commands/root/delete.completion.js"]},"pip":{"alias":"pipeline"},"project":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repository":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repo":{"alias":"repository"},"section":{"__optionHandlers":["../commands/root/delete.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"step-type":{"__optionHandlers":["../commands/root/delete.completion.js"]},"tokens":{"__optionHandlers":["../commands/root/delete.completion.js"]},"token":{"alias":"tokens"},"system-runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/delete.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"helm-repo":{"__optionHandlers":["../commands/root/delete.completion.js"]},"registry":{"__optionHandlers":["../commands/root/delete.completion.js"]},"trigger":{"__optionHandlers":["../commands/root/delete.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/delete.completion.js"]},"te":{"alias":"trigger-event"},"context":{"__optionHandlers":["../commands/root/delete.completion.js"]},"ctx":{"alias":"context"}},"diff":{"__optionHandlers":["../commands/root/diff.completion.js"],"runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"system-runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"download":{"audit":{}},"generate":{"image-pull-secret":{}},"get":{"__optionHandlers":["../commands/root/get.completion.js"],"runtime-environment-base-images":{"__optionHandlers":["../commands/root/get.completion.js"]},"re-base-images":{"alias":"runtime-environment-base-images"},"agents":{"__optionHandlers":["../commands/root/get.completion.js"]},"agent":{"alias":"agents"},"boards":{"__optionHandlers":["../commands/root/get.completion.js"]},"board":{"alias":"boards"},"annotation":{"__optionHandlers":["../commands/root/get.completion.js"]},"environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"env":{"alias":"environments"},"environment":{"alias":"environments"},"compositions":{"__optionHandlers":["../commands/root/get.completion.js"]},"com":{"alias":"compositions"},"composition":{"alias":"compositions"},"clusters":{"__optionHandlers":["../commands/root/get.completion.js"]},"cluster":{"alias":"clusters"},"images":{"__optionHandlers":["../commands/root/get.completion.js"]},"img":{"alias":"images"},"image":{"alias":"images"},"pipelines":{"__positionalHandler":"../commands/pipeline/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"pip":{"alias":"pipelines"},"pipeline":{"alias":"pipelines"},"projects":{"__optionHandlers":["../commands/root/get.completion.js"]},"project":{"alias":"projects"},"repository":{"__optionHandlers":["../commands/root/get.completion.js"]},"repo":{"alias":"repository"},"sections":{"__optionHandlers":["../commands/root/get.completion.js"]},"section":{"alias":"sections"},"runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"step-types":{"__positionalHandler":"../commands/step/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"step-type":{"alias":"step-types"},"tokens":{"__optionHandlers":["../commands/root/get.completion.js"]},"token":{"alias":"tokens"},"system-runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"teams":{"__optionHandlers":["../commands/root/get.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"helm-repo":{"__optionHandlers":["../commands/root/get.completion.js"]},"registry":{"__optionHandlers":["../commands/root/get.completion.js"]},"triggers":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger":{"alias":"triggers"},"t":{"alias":"triggers"},"trigger-events":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-event":{"alias":"trigger-events"},"te":{"alias":"trigger-events"},"trigger-types":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-type":{"alias":"trigger-types"},"tt":{"alias":"trigger-types"},"builds":{"__optionHandlers":["../commands/root/get.completion.js"]},"build":{"alias":"builds"},"workflow-data-item":{"__optionHandlers":["../commands/root/get.completion.js"]},"wdi":{"alias":"workflow-data-item"},"contexts":{"__optionHandlers":["../commands/root/get.completion.js"]},"ctx":{"alias":"contexts"},"context":{"alias":"contexts"}},"install":{"app-proxy":{},"runtime":{},"agent":{},"monitor":{},"gitops":{}},"replace":{"__optionHandlers":["../commands/root/replace.completion.js"],"composition":{"__optionHandlers":["../commands/composition/replace.completion.js","../commands/root/replace.completion.js"]},"com":{"alias":"composition"}},"runner":{"delete":{},"execute-test-pipeline":{},"init":{},"info":{},"upgrade":{}},"synchronize":{"teams":{},"team":{"alias":"teams"},"tm":{"alias":"teams"}},"unassign":{"system-runtime-environments":{},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"uninstall":{"app-proxy":{},"agent":{},"runtime":{},"monitor":{},"gitops":{}},"upgrade":{"app-proxy":{},"gitops":{}},"validate":{"__positionalHandler":"../commands/root/validate.completion.js"},"version":{},"attach":{},"cli-config":{"get":{},"help":{},"profile":{},"set":{}},"set-helm-config":{},"install-chart":{},"helm-promotion":{},"delete-release":{},"rollback-release":{},"test-release":{},"approve":{},"deny":{},"logs":{},"restart":{},"terminate":{},"wait":{}}}
|
|
1
|
+
{"codefresh":{"analyze":{},"tag":{},"untag":{},"completion":{},"completions":{"alias":"completion"},"offline-logs":{"ensure-index":{},"offload-to-collection":{},"offload-to-file":{}},"run":{"__optionHandlers":["../commands/pipeline/run.completion.js"]},"attach":{},"add":{"repository":{},"repo":{"alias":"repository"}},"annotate":{"image":{},"img":{"alias":"image"}},"patch":{"__optionHandlers":["../commands/root/apply.completion.js"],"agent":{"__optionHandlers":["../commands/root/apply.completion.js"]},"board":{"__optionHandlers":["../commands/root/apply.completion.js"]},"project":{"__optionHandlers":["../commands/root/apply.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/apply.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/apply.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"tokens":{"__optionHandlers":["../commands/root/apply.completion.js"]},"token":{"alias":"tokens"},"teams":{"__optionHandlers":["../commands/root/apply.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"helm-repo":{"__optionHandlers":["../commands/root/apply.completion.js"]},"context":{"__optionHandlers":["../commands/root/apply.completion.js"]},"ctx":{"alias":"context"}},"assign":{"system-runtime-environments":{},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"auth":{"create-context":{},"current-context":{},"get-contexts":{},"use-context":{}},"components":{"download":{},"update":{}},"create":{"__optionHandlers":["../commands/root/create.completion.js"],"agent":{"__optionHandlers":["../commands/root/create.completion.js"]},"clusters":{"__optionHandlers":["../commands/root/create.completion.js"]},"cluster":{"alias":"clusters"},"board":{"__optionHandlers":["../commands/root/create.completion.js"]},"annotation":{"__optionHandlers":["../commands/root/create.completion.js"]},"composition":{"__optionHandlers":["../commands/composition/create.completion.js","../commands/root/create.completion.js"]},"com":{"alias":"composition"},"project":{"__optionHandlers":["../commands/root/create.completion.js"]},"runtime-environments":{"__optionHandlers":["../commands/root/create.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/create.completion.js"]},"token":{"__optionHandlers":["../commands/root/create.completion.js"]},"teams":{"__optionHandlers":["../commands/root/create.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"helm-repo":{"__optionHandlers":["../commands/root/create.completion.js"]},"registry":{"__optionHandlers":["../commands/root/create.completion.js"],"standard":{"__optionHandlers":["../commands/root/create.completion.js"]}},"trigger":{"__optionHandlers":["../commands/root/create.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/create.completion.js"]},"te":{"alias":"trigger-event"},"workflow-data-item":{"__optionHandlers":["../commands/root/create.completion.js"]},"wdi":{"alias":"workflow-data-item"},"context":{"__optionHandlers":["../commands/root/create.completion.js"],"config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}}},"ctx":{"alias":"context","config":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret":{"__optionHandlers":["../commands/root/create.completion.js"]},"secret-yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"yaml":{"__optionHandlers":["../commands/root/create.completion.js"]},"git":{"__optionHandlers":["../commands/root/create.completion.js"],"bitbucket":{"__optionHandlers":["../commands/root/create.completion.js"]},"github":{"__optionHandlers":["../commands/root/create.completion.js"]},"gitlab":{"__optionHandlers":["../commands/root/create.completion.js"]},"stash":{"__optionHandlers":["../commands/root/create.completion.js"]}},"helm-repository":{"__optionHandlers":["../commands/root/create.completion.js"],"http":{"__optionHandlers":["../commands/root/create.completion.js"]},"s3":{"__optionHandlers":["../commands/root/create.completion.js"]}},"secret-store":{"__optionHandlers":["../commands/root/create.completion.js"],"hashicorp-vault":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes-runtime":{"__optionHandlers":["../commands/root/create.completion.js"]},"kubernetes":{"__optionHandlers":["../commands/root/create.completion.js"]}}}},"delete":{"__optionHandlers":["../commands/root/delete.completion.js"],"agent":{"__optionHandlers":["../commands/root/delete.completion.js"]},"board":{"__optionHandlers":["../commands/root/delete.completion.js"]},"cluster":{"__optionHandlers":["../commands/root/delete.completion.js"]},"clusters":{"alias":"cluster"},"annotation":{"__optionHandlers":["../commands/root/delete.completion.js"]},"composition":{"__optionHandlers":["../commands/root/delete.completion.js"]},"com":{"alias":"composition"},"environment":{"__optionHandlers":["../commands/root/delete.completion.js"]},"env":{"alias":"environment"},"project":{"__optionHandlers":["../commands/root/delete.completion.js"]},"pipeline":{"__optionHandlers":["../commands/root/delete.completion.js"]},"pip":{"alias":"pipeline"},"repository":{"__optionHandlers":["../commands/root/delete.completion.js"]},"repo":{"alias":"repository"},"runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"section":{"__optionHandlers":["../commands/root/delete.completion.js"]},"system-runtime-environments":{"__optionHandlers":["../commands/root/delete.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"tokens":{"__optionHandlers":["../commands/root/delete.completion.js"]},"token":{"alias":"tokens"},"step-type":{"__optionHandlers":["../commands/root/delete.completion.js"]},"teams":{"__optionHandlers":["../commands/root/delete.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"helm-repo":{"__optionHandlers":["../commands/root/delete.completion.js"]},"registry":{"__optionHandlers":["../commands/root/delete.completion.js"]},"trigger":{"__optionHandlers":["../commands/root/delete.completion.js"]},"t":{"alias":"trigger"},"trigger-event":{"__optionHandlers":["../commands/root/delete.completion.js"]},"te":{"alias":"trigger-event"},"context":{"__optionHandlers":["../commands/root/delete.completion.js"]},"ctx":{"alias":"context"}},"diff":{"__optionHandlers":["../commands/root/diff.completion.js"],"runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"system-runtime-environments":{"__optionHandlers":["../commands/root/diff.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"download":{"audit":{}},"generate":{"image-pull-secret":{}},"get":{"__optionHandlers":["../commands/root/get.completion.js"],"runtime-environment-base-images":{"__optionHandlers":["../commands/root/get.completion.js"]},"re-base-images":{"alias":"runtime-environment-base-images"},"agents":{"__optionHandlers":["../commands/root/get.completion.js"]},"agent":{"alias":"agents"},"boards":{"__optionHandlers":["../commands/root/get.completion.js"]},"board":{"alias":"boards"},"clusters":{"__optionHandlers":["../commands/root/get.completion.js"]},"cluster":{"alias":"clusters"},"annotation":{"__optionHandlers":["../commands/root/get.completion.js"]},"compositions":{"__optionHandlers":["../commands/root/get.completion.js"]},"com":{"alias":"compositions"},"composition":{"alias":"compositions"},"environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"env":{"alias":"environments"},"environment":{"alias":"environments"},"images":{"__optionHandlers":["../commands/root/get.completion.js"]},"img":{"alias":"images"},"image":{"alias":"images"},"projects":{"__optionHandlers":["../commands/root/get.completion.js"]},"project":{"alias":"projects"},"pipelines":{"__positionalHandler":"../commands/pipeline/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"pip":{"alias":"pipelines"},"pipeline":{"alias":"pipelines"},"repository":{"__optionHandlers":["../commands/root/get.completion.js"]},"repo":{"alias":"repository"},"runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"re":{"alias":"runtime-environments"},"runtime-environment":{"alias":"runtime-environments"},"sections":{"__optionHandlers":["../commands/root/get.completion.js"]},"section":{"alias":"sections"},"system-runtime-environments":{"__optionHandlers":["../commands/root/get.completion.js"]},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"},"tokens":{"__optionHandlers":["../commands/root/get.completion.js"]},"token":{"alias":"tokens"},"step-types":{"__positionalHandler":"../commands/step/get.completion.js","__optionHandlers":["../commands/root/get.completion.js"]},"step-type":{"alias":"step-types"},"teams":{"__optionHandlers":["../commands/root/get.completion.js"]},"team":{"alias":"teams"},"tm":{"alias":"teams"},"helm-repo":{"__optionHandlers":["../commands/root/get.completion.js"]},"registry":{"__optionHandlers":["../commands/root/get.completion.js"]},"triggers":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger":{"alias":"triggers"},"t":{"alias":"triggers"},"trigger-events":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-event":{"alias":"trigger-events"},"te":{"alias":"trigger-events"},"trigger-types":{"__optionHandlers":["../commands/root/get.completion.js"]},"trigger-type":{"alias":"trigger-types"},"tt":{"alias":"trigger-types"},"builds":{"__optionHandlers":["../commands/root/get.completion.js"]},"build":{"alias":"builds"},"workflow-data-item":{"__optionHandlers":["../commands/root/get.completion.js"]},"wdi":{"alias":"workflow-data-item"},"contexts":{"__optionHandlers":["../commands/root/get.completion.js"]},"ctx":{"alias":"contexts"},"context":{"alias":"contexts"}},"install":{"runtime":{},"agent":{},"app-proxy":{},"monitor":{},"gitops":{}},"replace":{"__optionHandlers":["../commands/root/replace.completion.js"],"composition":{"__optionHandlers":["../commands/composition/replace.completion.js","../commands/root/replace.completion.js"]},"com":{"alias":"composition"}},"runner":{"delete":{},"execute-test-pipeline":{},"info":{},"init":{},"upgrade":{}},"synchronize":{"teams":{},"team":{"alias":"teams"},"tm":{"alias":"teams"}},"unassign":{"system-runtime-environments":{},"sys-re":{"alias":"system-runtime-environments"},"system-runtime-environment":{"alias":"system-runtime-environments"}},"uninstall":{"agent":{},"app-proxy":{},"runtime":{},"monitor":{},"gitops":{}},"upgrade":{"app-proxy":{},"gitops":{}},"validate":{"__positionalHandler":"../commands/root/validate.completion.js"},"version":{},"cli-config":{"get":{},"help":{},"profile":{},"set":{}},"set-helm-config":{},"install-chart":{},"helm-promotion":{},"delete-release":{},"rollback-release":{},"test-release":{},"approve":{},"deny":{},"logs":{},"restart":{},"terminate":{},"wait":{}}}
|
|
@@ -3,7 +3,9 @@ const flatten = require('flat');
|
|
|
3
3
|
const columnify = require('columnify');
|
|
4
4
|
const yaml = require('js-yaml');
|
|
5
5
|
const Style = require('../../../output/Style');
|
|
6
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
NoPropertyError, MultiplePropertiesError, NotFullPropertyError, SchemaValidationError,
|
|
8
|
+
} = require('../../../logic/cli-config/errors');
|
|
7
9
|
|
|
8
10
|
const _jsonFormatter = data => JSON.stringify(data, null, 4);
|
|
9
11
|
const COLUMNIFY_OPTS = { columnSplitter: ' ', headingTransform: Style.bold.uppercase };
|
|
@@ -38,7 +40,7 @@ function _defaultOutput(data) {
|
|
|
38
40
|
function _formatter(format) {
|
|
39
41
|
switch (format) {
|
|
40
42
|
case 'yaml':
|
|
41
|
-
return yaml.
|
|
43
|
+
return yaml.dump;
|
|
42
44
|
case 'json':
|
|
43
45
|
return _jsonFormatter;
|
|
44
46
|
default:
|
|
@@ -129,7 +129,7 @@ const crudFilenameOption = (yargs, options = {}) => {
|
|
|
129
129
|
return options.raw ? rawFile : JSON.parse(rawFile);
|
|
130
130
|
}
|
|
131
131
|
if (arg.endsWith('.yml') || arg.endsWith('yaml')) {
|
|
132
|
-
return options.raw ? rawFile : yaml.
|
|
132
|
+
return options.raw ? rawFile : yaml.load(rawFile);
|
|
133
133
|
}
|
|
134
134
|
throw new CFError('File extension is not recognized');
|
|
135
135
|
} catch (err) {
|
|
@@ -40,7 +40,7 @@ async function validatePipelineSpec(data) {
|
|
|
40
40
|
if (specTemplate) { // CR-6414 Using specTemplate - skip check spec/stages - they are not used
|
|
41
41
|
return { valid: true, message: 'Using specTemplate' };
|
|
42
42
|
}
|
|
43
|
-
const validatedYaml = yaml.
|
|
43
|
+
const validatedYaml = yaml.dump(yamlObj);
|
|
44
44
|
const result = await sdk.pipelines.validateYaml({ yaml: validatedYaml, outputFormat: 'lint' });
|
|
45
45
|
let message;
|
|
46
46
|
if (result.summarize) {
|
|
@@ -47,11 +47,11 @@ function _loadFullConfig() {
|
|
|
47
47
|
},
|
|
48
48
|
};
|
|
49
49
|
const file = fs.openSync(filePath, 'w');
|
|
50
|
-
fs.writeSync(file, yaml.
|
|
50
|
+
fs.writeSync(file, yaml.dump(fullConfig));
|
|
51
51
|
fs.closeSync(file);
|
|
52
52
|
return fullConfig;
|
|
53
53
|
}
|
|
54
|
-
return yaml.
|
|
54
|
+
return yaml.load(fs.readFileSync(filePath));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
function _validate(properties, propertyName) {
|
|
@@ -127,7 +127,7 @@ class CliConfigManager {
|
|
|
127
127
|
static persistConfig() {
|
|
128
128
|
this._preloadConfig();
|
|
129
129
|
const file = fs.openSync(filePath, 'w');
|
|
130
|
-
fs.writeSync(file, yaml.
|
|
130
|
+
fs.writeSync(file, yaml.dump(FULL_CONFIG));
|
|
131
131
|
fs.closeSync(file);
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -46,11 +46,11 @@ jest.mock('fs', () => { // eslint-disable-line
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
jest.mock('js-yaml', () => {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
49
|
+
const load = (d) => d;
|
|
50
|
+
const dump = (d) => d;
|
|
51
51
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
load,
|
|
53
|
+
dump,
|
|
54
54
|
};
|
|
55
55
|
});
|
|
56
56
|
|
|
@@ -22,9 +22,9 @@ function output(data) {
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
if (yamlArray.items.length === 1) {
|
|
25
|
-
return yaml.
|
|
25
|
+
return yaml.dump(yamlArray.items[0]);
|
|
26
26
|
}
|
|
27
|
-
return yaml.
|
|
27
|
+
return yaml.dump(yamlArray);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
module.exports = output;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codefresh",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Codefresh command line utility",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"preferGlobal": true,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"generate-completion": "node ./lib/interface/cli/completion/generate",
|
|
9
|
-
"test": "jest .spec.js --coverage",
|
|
9
|
+
"test": "rm -rf ./temp && jest .spec.js --runInBand --ci --color --coverage --silent",
|
|
10
10
|
"e2e": "bash e2e/e2e.spec.sh",
|
|
11
11
|
"eslint": "eslint --fix lib/logic/**",
|
|
12
12
|
"pkg": "npx pkg . -t node20-alpine-x64,node20-alpine-arm64,node20-macos-x64,node20-linux-x64,node20-win-x64,node20-linux-arm64 --out-path ./dist",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"firebase": "git+https://github.com/codefresh-io/firebase.git#80b2ed883ff281cd67b53bd0f6a0bbd6f330fed5",
|
|
69
69
|
"flat": "^5.0.2",
|
|
70
70
|
"inquirer": "^12.11.1",
|
|
71
|
-
"js-yaml": "^3.
|
|
71
|
+
"js-yaml": "^4.3.0",
|
|
72
72
|
"kefir": "^3.8.1",
|
|
73
73
|
"kubernetes-client": "^9.0.0",
|
|
74
74
|
"lodash": "^4.17.23",
|