@cmflow/cli 3.3.0 → 3.4.0-alpha.3
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 +102 -298
- package/dist/bin/cm.mjs +83622 -0
- package/dist/bin/cmrelease.mjs +75079 -0
- package/dist/cli-truncate-Bi2MjGwF.mjs +323 -0
- package/dist/cli-truncate-DMcpM5Q7.mjs +2 -0
- package/dist/cli-truncate-DMcpM5Q7.mjs.map +1 -0
- package/dist/cli-truncate-DsW0mgI_.mjs +323 -0
- package/dist/common-BdfXquG0.mjs +61 -0
- package/dist/common-BdfXquG0.mjs.map +1 -0
- package/dist/compile-packages-BB08_q2B.mjs +2 -0
- package/dist/compile-packages-BB08_q2B.mjs.map +1 -0
- package/dist/docker-Cc30aRzl.mjs +34 -0
- package/dist/docker-Cc30aRzl.mjs.map +1 -0
- package/dist/docker-clean-tags-EvFdWykP.mjs +2 -0
- package/dist/docker-clean-tags-EvFdWykP.mjs.map +1 -0
- package/dist/docker-publish-CG0aN9se.mjs +2 -0
- package/dist/docker-publish-CG0aN9se.mjs.map +1 -0
- package/dist/find-packages-611B-66T.mjs +42 -0
- package/dist/find-packages-611B-66T.mjs.map +1 -0
- package/dist/get-config-8ivgd1KC.mjs +9 -0
- package/dist/get-config-8ivgd1KC.mjs.map +1 -0
- package/dist/get-east-asian-width-Tfn8qoqd.mjs +2 -0
- package/dist/get-east-asian-width-Tfn8qoqd.mjs.map +1 -0
- package/dist/get-east-asian-width-wiVWCFXf.mjs +682 -0
- package/dist/log-update-CLbF3iV6.mjs +6 -0
- package/dist/log-update-CLbF3iV6.mjs.map +1 -0
- package/dist/log-update-CTXRtajW.mjs +668 -0
- package/dist/log-update-Dy1vPMGY.mjs +668 -0
- package/dist/npm-VM_GgazT.mjs +2 -0
- package/dist/npm-VM_GgazT.mjs.map +1 -0
- package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
- package/dist/semver-DFjVbN1S.mjs +2 -0
- package/dist/semver-DFjVbN1S.mjs.map +1 -0
- package/dist/source-CwLcYLzI.mjs +7 -0
- package/dist/source-CwLcYLzI.mjs.map +1 -0
- package/dist/wrap-ansi-9ugahFCy.mjs +9 -0
- package/dist/wrap-ansi-9ugahFCy.mjs.map +1 -0
- package/dist/wrap-ansi-BRr0GA6g.mjs +330 -0
- package/dist/wrap-ansi-Cupoo4Yg.mjs +330 -0
- package/dist/wrap-ansi-dwgEjNWf.mjs +2 -0
- package/dist/write-package-cxki9d3K.mjs +8 -0
- package/dist/write-package-cxki9d3K.mjs.map +1 -0
- package/dist/write-packages-CxCAl_AG.mjs +10 -0
- package/dist/write-packages-CxCAl_AG.mjs.map +1 -0
- package/package.json +40 -63
- package/tsdown.config.ts +54 -0
- package/.oxfmtrc.json +0 -11
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.7.0.cjs +0 -935
- package/.yarnrc.yml +0 -3
- package/bin/checkfeatures.js +0 -13
- package/bin/cm-clean.js +0 -8
- package/bin/cm-config.js +0 -15
- package/bin/cm-deploy.js +0 -8
- package/bin/cm-expedit.js +0 -19
- package/bin/cm-fetch.js +0 -12
- package/bin/cm-finish.js +0 -14
- package/bin/cm-jira-releases.js +0 -16
- package/bin/cm-merge.js +0 -12
- package/bin/cm-publish.js +0 -15
- package/bin/cm-push.js +0 -15
- package/bin/cm-rebase.js +0 -15
- package/bin/cm-republish.js +0 -12
- package/bin/cm-start.js +0 -21
- package/bin/cm.js +0 -27
- package/bin/cmpull.js +0 -22
- package/bin/cmrelease.js +0 -5
- package/mise.toml +0 -2
- package/oxlint.json +0 -25
- package/release.config.mjs +0 -39
- package/src/commands/checkfeatures.js +0 -20
- package/src/commands/clean.js +0 -29
- package/src/commands/config.js +0 -23
- package/src/commands/deploy.js +0 -34
- package/src/commands/fetch.js +0 -18
- package/src/commands/finish.js +0 -43
- package/src/commands/index.js +0 -12
- package/src/commands/jira-releases.js +0 -62
- package/src/commands/merge.js +0 -41
- package/src/commands/prompts/branches.js +0 -38
- package/src/commands/pull.js +0 -30
- package/src/commands/push.js +0 -23
- package/src/commands/rebase.js +0 -35
- package/src/commands/release.js +0 -21
- package/src/commands/republish.js +0 -21
- package/src/commands/start.js +0 -109
- package/src/commands/tasks/merge-branch.js +0 -65
- package/src/commands/tasks/push-branch.js +0 -10
- package/src/commands/tasks/rebase-all-branches.js +0 -29
- package/src/commands/tasks/refresh-repository.js +0 -34
- package/src/commands/tasks/run-test.js +0 -21
- package/src/commands/tasks/update-branch.js +0 -43
- package/src/commands/tasks/update-dependencies.js +0 -42
- package/src/commands/utils/check-install.js +0 -31
- package/src/common/back/directus/directus-flow.js +0 -40
- package/src/common/back/directus/directus-flow.test.js +0 -62
- package/src/common/back/http/http-proxy.js +0 -15
- package/src/common/back/http/http-request.js +0 -77
- package/src/common/back/http/http-request.spec.js +0 -49
- package/src/common/back/jira/get-sorted-releases.js +0 -40
- package/src/common/back/jira/interfaces/JiraIIssue.d.ts +0 -100
- package/src/common/back/jira/jira-releases.js +0 -36
- package/src/common/back/jira/jira-request.js +0 -21
- package/src/common/back/jira/jira-request.spec.js +0 -59
- package/src/common/back/jira/jira-search.js +0 -17
- package/src/common/back/jira/jira-search.spec.js +0 -44
- package/src/common/cli/bun.js +0 -33
- package/src/common/cli/bun.test.js +0 -51
- package/src/common/cli/cli.js +0 -110
- package/src/common/cli/docker.js +0 -66
- package/src/common/cli/docker.test.js +0 -133
- package/src/common/cli/git.js +0 -121
- package/src/common/cli/git.test.js +0 -207
- package/src/common/cli/lerna.js +0 -25
- package/src/common/cli/lerna.test.js +0 -51
- package/src/common/cli/npm.js +0 -33
- package/src/common/cli/npm.test.js +0 -51
- package/src/common/cli/pnpm.js +0 -34
- package/src/common/cli/pnpm.test.js +0 -51
- package/src/common/cli/yarn.js +0 -33
- package/src/common/cli/yarn.test.js +0 -53
- package/src/common/configure-git-workspace.js +0 -26
- package/src/common/get-config.js +0 -157
- package/src/common/get-package-json.js +0 -14
- package/src/common/get-package-manager.js +0 -12
- package/src/common/get-release-config.js +0 -8
- package/src/common/index.js +0 -13
- package/src/common/run-command.js +0 -64
- package/src/common/run-command.test.js +0 -65
- package/src/index.js +0 -10
- package/src/semantic/core/analyze-commits.js +0 -17
- package/src/semantic/core/conditional.js +0 -55
- package/src/semantic/core/exit.js +0 -14
- package/src/semantic/core/prepare/bump-version.js +0 -38
- package/src/semantic/core/prepare/commit.js +0 -29
- package/src/semantic/core/prepare/release-info.js +0 -5
- package/src/semantic/core/run.js +0 -22
- package/src/semantic/core/sync-repository.js +0 -52
- package/src/semantic/core/verify-conditions.js +0 -40
- package/src/semantic/core/verify-release.js +0 -9
- package/src/semantic/define-config.js +0 -42
- package/src/semantic/docker/publish.js +0 -5
- package/src/semantic/docker/success.js +0 -9
- package/src/semantic/utils/__mock__/test1/package.json +0 -7
- package/src/semantic/utils/__mock__/test1/packages/a/package.json +0 -9
- package/src/semantic/utils/__mock__/test1/packages/b/package.json +0 -7
- package/src/semantic/utils/__mock__/test2/package.json +0 -4
- package/src/semantic/utils/__mock__/test2/packages/a/package.json +0 -7
- package/src/semantic/utils/__mock__/test2/packages/b/package.json +0 -5
- package/src/semantic/utils/bump-packages-version.js +0 -52
- package/src/semantic/utils/bump-packages-version.test.js +0 -75
- package/src/semantic/utils/calculate-snapshot-version.js +0 -15
- package/src/semantic/utils/calculate-snapshot-version.test.js +0 -67
- package/src/semantic/utils/display-package-info.js +0 -11
- package/src/semantic/utils/display-release-info.js +0 -12
- package/src/semantic/utils/docker-clean-tags.js +0 -51
- package/src/semantic/utils/docker-clean-tags.test.js +0 -61
- package/src/semantic/utils/docker-publish.js +0 -23
- package/src/semantic/utils/docker-publish.test.js +0 -44
- package/src/semantic/utils/log-section.js +0 -5
- package/src/semantic/utils/release-rules.js +0 -15
- package/src/semantic/utils/transform-writer.js +0 -77
- package/src/workflow/index.js +0 -42
- package/tsconfig.json +0 -37
- package/vitest.config.mts +0 -10
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import axiosRetry from "axios-retry";
|
|
3
|
-
|
|
4
|
-
import { getHttpProxy } from "./http-proxy.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {Object} RetryOptions
|
|
8
|
-
* @property {number} [retries=3] - Number of retry attempts
|
|
9
|
-
* @property {number} [retryDelay=1000] - Delay between retries in ms
|
|
10
|
-
* @property {boolean} [retryOnNetworkError=true] - Retry on network errors
|
|
11
|
-
* @property {boolean} [retryOnIdempotentRequests=true] - Retry on 5xx for idempotent requests
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {Object} HttpRequestOptions
|
|
16
|
-
* @property {boolean} [rejectUnauthorized] - Whether to reject unauthorized SSL certificates
|
|
17
|
-
* @property {string} [callee] - The name of the caller
|
|
18
|
-
* @property {Record<string, string>} [params] - Query parameters to be included in the request
|
|
19
|
-
* @property {string} [method] - HTTP method (default: 'get')
|
|
20
|
-
* @property {Record<string, string>} [headers] - Custom headers to be included in the request
|
|
21
|
-
* @property {RetryOptions|boolean} [retry] - Retry configuration (true for defaults, or custom config)
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param endpoint {string}
|
|
27
|
-
* @param options {HttpRequestOptions}
|
|
28
|
-
* @return {Promise<*>}
|
|
29
|
-
*/
|
|
30
|
-
export async function httpRequest(endpoint, options = {}) {
|
|
31
|
-
const { callee, headers, method = "get", params = {}, rejectUnauthorized, ...rest } = options;
|
|
32
|
-
const httpsAgent = getHttpProxy({
|
|
33
|
-
rejectUnauthorized,
|
|
34
|
-
callee
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const instance = axios.create();
|
|
38
|
-
|
|
39
|
-
axiosRetry(instance, options);
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
const response = await instance({
|
|
43
|
-
url: endpoint,
|
|
44
|
-
method,
|
|
45
|
-
params,
|
|
46
|
-
headers: {
|
|
47
|
-
...headers,
|
|
48
|
-
"Content-Type": "application/json"
|
|
49
|
-
},
|
|
50
|
-
httpsAgent,
|
|
51
|
-
...rest
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
console.info({
|
|
55
|
-
message: `Successfully retrieved data from ${callee}`,
|
|
56
|
-
url: endpoint,
|
|
57
|
-
method: method.toUpperCase(),
|
|
58
|
-
status: response.status
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
return response.data;
|
|
62
|
-
} catch (error) {
|
|
63
|
-
const status = error.response?.status;
|
|
64
|
-
const responseData = error.response?.data;
|
|
65
|
-
|
|
66
|
-
console.error({
|
|
67
|
-
...options,
|
|
68
|
-
message: `Fail to retrieved data from ${callee}`,
|
|
69
|
-
url: endpoint,
|
|
70
|
-
method: method.toUpperCase(),
|
|
71
|
-
status,
|
|
72
|
-
response: responseData
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
throw new Error(`HTTP error! status: ${status}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import axiosRetry from "axios-retry";
|
|
3
|
-
|
|
4
|
-
import { getHttpProxy } from "./http-proxy.js";
|
|
5
|
-
import { httpRequest } from "./http-request.js";
|
|
6
|
-
|
|
7
|
-
vi.mock("axios");
|
|
8
|
-
vi.mock("axios-retry");
|
|
9
|
-
vi.mock("./http-proxy.js");
|
|
10
|
-
|
|
11
|
-
describe("httpRequest", () => {
|
|
12
|
-
let mockInstance;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
vi.clearAllMocks();
|
|
16
|
-
mockInstance = vi.fn();
|
|
17
|
-
vi.mocked(axios.create).mockReturnValue(mockInstance);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should create an agent in production with proxy", async () => {
|
|
21
|
-
mockInstance.mockResolvedValue({
|
|
22
|
-
status: 200,
|
|
23
|
-
data: { data: "test" }
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const result = await httpRequest("http://example.com/test-endpoint", {
|
|
27
|
-
callee: "test"
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
expect(getHttpProxy).toHaveBeenCalledWith({
|
|
31
|
-
rejectUnauthorized: undefined,
|
|
32
|
-
callee: "test"
|
|
33
|
-
});
|
|
34
|
-
expect(axios.create).toHaveBeenCalled();
|
|
35
|
-
expect(axiosRetry).toHaveBeenCalled();
|
|
36
|
-
expect(result).toEqual({ data: "test" });
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should throw an error if the response is not ok", async () => {
|
|
40
|
-
const axiosError = new Error("Request failed");
|
|
41
|
-
axiosError.response = {
|
|
42
|
-
status: 500,
|
|
43
|
-
data: { error: "Internal server error" }
|
|
44
|
-
};
|
|
45
|
-
mockInstance.mockRejectedValue(axiosError);
|
|
46
|
-
|
|
47
|
-
await expect(httpRequest("http://example.com/test-endpoint", { callee: "test" })).rejects.toThrow("HTTP error! status: 500");
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import semver from "semver";
|
|
2
|
-
|
|
3
|
-
import { getJiraReleases } from "./jira-releases.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns all releases under the tag version for the given project and component.
|
|
7
|
-
* @param projectId {string}
|
|
8
|
-
* @param component {string}
|
|
9
|
-
* @param tagVersion {string}
|
|
10
|
-
*/
|
|
11
|
-
export async function getSortedReleases(projectId, component, tagVersion) {
|
|
12
|
-
const releases = await getJiraReleases(projectId);
|
|
13
|
-
|
|
14
|
-
const promises = releases
|
|
15
|
-
.filter((release) => {
|
|
16
|
-
release.version = release.name
|
|
17
|
-
.replace(component + "-", "")
|
|
18
|
-
.replace("version-", "")
|
|
19
|
-
.replace("v", "");
|
|
20
|
-
try {
|
|
21
|
-
return semver.lte(release.version, tagVersion);
|
|
22
|
-
} catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
.sort((ra, rb) => {
|
|
27
|
-
return semver.rcompare(ra.version, rb.version);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const [current, ...others] = await Promise.all(promises);
|
|
31
|
-
|
|
32
|
-
return [
|
|
33
|
-
current,
|
|
34
|
-
...others.filter((release) => {
|
|
35
|
-
return !release?.released;
|
|
36
|
-
})
|
|
37
|
-
]
|
|
38
|
-
.filter(Boolean)
|
|
39
|
-
.reverse();
|
|
40
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import type { ADFDocument } from "./ADFDocument.js";
|
|
2
|
-
import type { JiraChangelog } from "./JiraChangelogIssueResponse.js";
|
|
3
|
-
|
|
4
|
-
export interface JiraStatus {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface JiraUser {
|
|
10
|
-
accountId?: string;
|
|
11
|
-
displayName?: string;
|
|
12
|
-
emailAddress?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface CreateJiraComment {
|
|
16
|
-
body: ADFDocument;
|
|
17
|
-
author: JiraUser;
|
|
18
|
-
notifyUsers?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface JiraComment extends CreateJiraComment {
|
|
22
|
-
id: string;
|
|
23
|
-
body: ADFDocument;
|
|
24
|
-
author: JiraUser;
|
|
25
|
-
created: string;
|
|
26
|
-
updated?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface JiraAttachment {
|
|
30
|
-
id: string;
|
|
31
|
-
filename: string;
|
|
32
|
-
content: string; // URL de téléchargement
|
|
33
|
-
size: number;
|
|
34
|
-
mimeType?: string;
|
|
35
|
-
created: string;
|
|
36
|
-
author: JiraUser;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface JiraIssueLink {
|
|
40
|
-
id: string;
|
|
41
|
-
type: {
|
|
42
|
-
id: string;
|
|
43
|
-
name: string; // Ex: "relates to", "blocks"
|
|
44
|
-
inward: string; // Ex: "is blocked by"
|
|
45
|
-
outward: string; // Ex: "blocks"
|
|
46
|
-
};
|
|
47
|
-
inwardIssue?: Partial<JiraIssue>; // Issue liée en amont
|
|
48
|
-
outwardIssue?: Partial<JiraIssue>; // Issue liée en aval
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface CreateJiraFieldsIssue {
|
|
52
|
-
summary: string; // Titre de l'issue
|
|
53
|
-
description?: ADFDocument; // Description détaillée
|
|
54
|
-
labels?: string[]; // Liste des labels
|
|
55
|
-
issuetype: {
|
|
56
|
-
name: string; // Type d'issue (ex: "Bug", "Task")
|
|
57
|
-
};
|
|
58
|
-
project: {
|
|
59
|
-
key: string;
|
|
60
|
-
};
|
|
61
|
-
assignee?: Partial<JiraUser>; // Utilisateur assigné
|
|
62
|
-
reporter?: Partial<JiraUser>; // Créateur de l'issue
|
|
63
|
-
status?: Omit<JiraStatus, "name">;
|
|
64
|
-
components?: { name: string }[];
|
|
65
|
-
|
|
66
|
-
[customFieldId: `customfield_${string}`]: unknown; // Autres champs personnalisés
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface CreateJiraIssue {
|
|
70
|
-
fields: CreateJiraFieldsIssue;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface JiraIssue {
|
|
74
|
-
id: string; // ID unique de l'issue
|
|
75
|
-
key: string; // Clé de l'issue (ex: "PROJ-123")
|
|
76
|
-
self: string; // URL de l'issue
|
|
77
|
-
|
|
78
|
-
fields: CreateJiraFieldsIssue & {
|
|
79
|
-
issuetype: {
|
|
80
|
-
id: string;
|
|
81
|
-
name: string; // Type d'issue (ex: "Bug", "Task")
|
|
82
|
-
};
|
|
83
|
-
project: {
|
|
84
|
-
id: string;
|
|
85
|
-
key: string;
|
|
86
|
-
name: string;
|
|
87
|
-
};
|
|
88
|
-
comment?: {
|
|
89
|
-
comments: JiraComment[];
|
|
90
|
-
total: number;
|
|
91
|
-
};
|
|
92
|
-
status: JiraStatus;
|
|
93
|
-
attachment?: JiraAttachment[]; // Liste des pièces jointes
|
|
94
|
-
issuelinks?: JiraIssueLink[]; // Relations avec d'autres issues
|
|
95
|
-
created: string; // Date de création
|
|
96
|
-
updated: string; // Dernière mise à jour
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export type JiraIssueWithChangelog = JiraIssue & { changelog: JiraChangelog };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { jiraRequest } from "./jira-request.js";
|
|
2
|
-
|
|
3
|
-
export async function getJiraReleases(projectId) {
|
|
4
|
-
const endpoint = `/rest/api/3/project/${projectId}/versions?expand`;
|
|
5
|
-
const response = await jiraRequest(endpoint);
|
|
6
|
-
|
|
7
|
-
if (!response || !Array.isArray(response)) {
|
|
8
|
-
return [];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return response;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function updateJiraRelease(release) {
|
|
15
|
-
const endpoint = `/rest/api/3/version/${release.id}`;
|
|
16
|
-
try {
|
|
17
|
-
await jiraRequest(endpoint, {
|
|
18
|
-
method: "put",
|
|
19
|
-
headers: {
|
|
20
|
-
"Content-Type": "application/json",
|
|
21
|
-
Accept: "application/json"
|
|
22
|
-
},
|
|
23
|
-
data: {
|
|
24
|
-
id: release.id,
|
|
25
|
-
description: release.description,
|
|
26
|
-
name: release.name,
|
|
27
|
-
archived: release.archived,
|
|
28
|
-
released: release.released,
|
|
29
|
-
projectId: release.projectId,
|
|
30
|
-
releaseDate: release.releaseDate
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
} catch (er) {
|
|
34
|
-
console.log(`Error while updating jira release ${release.id}`, er);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import axiosRetry from "axios-retry";
|
|
2
|
-
|
|
3
|
-
import { getConfig } from "../../get-config.js";
|
|
4
|
-
import { httpRequest } from "../http/http-request.js";
|
|
5
|
-
|
|
6
|
-
export async function jiraRequest(endpoint, opts = {}) {
|
|
7
|
-
const { JIRA_API, JIRA_TOKEN, JIRA_EMAIL } = getConfig();
|
|
8
|
-
const jiraUrl = `${JIRA_API}${endpoint}`;
|
|
9
|
-
const auth = Buffer.from(`${JIRA_EMAIL}:${JIRA_TOKEN}`).toString("base64");
|
|
10
|
-
|
|
11
|
-
return httpRequest(jiraUrl, {
|
|
12
|
-
...opts,
|
|
13
|
-
callee: "JIRA",
|
|
14
|
-
headers: {
|
|
15
|
-
...opts.headers,
|
|
16
|
-
Authorization: `Basic ${auth}`
|
|
17
|
-
},
|
|
18
|
-
retries: 3,
|
|
19
|
-
retryDelay: axiosRetry.exponentialDelay
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { httpRequest } from "../http/http-request.js";
|
|
2
|
-
import { jiraRequest } from "./jira-request.js";
|
|
3
|
-
|
|
4
|
-
vi.mock("../http/http-request.js");
|
|
5
|
-
vi.mock("axios-retry");
|
|
6
|
-
|
|
7
|
-
describe("jiraRequest", () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
vi.clearAllMocks();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should make a GET request to the JIRA API", async () => {
|
|
13
|
-
const mockResponse = { data: "test" };
|
|
14
|
-
vi.mocked(httpRequest).mockResolvedValue(mockResponse);
|
|
15
|
-
|
|
16
|
-
const result = await jiraRequest("/test-endpoint");
|
|
17
|
-
|
|
18
|
-
expect(httpRequest).toHaveBeenCalledWith(
|
|
19
|
-
expect.stringContaining("/test-endpoint"),
|
|
20
|
-
expect.objectContaining({
|
|
21
|
-
headers: expect.objectContaining({
|
|
22
|
-
Authorization: expect.stringContaining("Basic ")
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
expect(result).toEqual(mockResponse);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should make a POST request to the JIRA API", async () => {
|
|
30
|
-
const mockResponse = { data: "test" };
|
|
31
|
-
vi.mocked(httpRequest).mockResolvedValue(mockResponse);
|
|
32
|
-
|
|
33
|
-
const result = await jiraRequest("/test-endpoint", {
|
|
34
|
-
method: "post",
|
|
35
|
-
params: { key: "value" },
|
|
36
|
-
headers: { "Content-Type": "application/json" },
|
|
37
|
-
data: { key: "value" }
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
expect(httpRequest).toHaveBeenCalledWith(expect.stringContaining("/test-endpoint"), {
|
|
41
|
-
callee: "JIRA",
|
|
42
|
-
method: "post",
|
|
43
|
-
params: { key: "value" },
|
|
44
|
-
data: { key: "value" },
|
|
45
|
-
headers: expect.objectContaining({
|
|
46
|
-
Authorization: expect.stringContaining("Basic ")
|
|
47
|
-
}),
|
|
48
|
-
retries: 3,
|
|
49
|
-
retryDelay: expect.any(Function)
|
|
50
|
-
});
|
|
51
|
-
expect(result).toEqual(mockResponse);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should throw an error if the httpRequest fails", async () => {
|
|
55
|
-
vi.mocked(httpRequest).mockRejectedValue(new Error("Request failed"));
|
|
56
|
-
|
|
57
|
-
await expect(jiraRequest("test-endpoint")).rejects.toThrow("Request failed");
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jiraRequest } from "./jira-request.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Search JIRA issues using JQL (JIRA Query Language).
|
|
5
|
-
* @template Expand
|
|
6
|
-
* @param jql {string} JIRA Query Language
|
|
7
|
-
* @param opts {object} Options
|
|
8
|
-
* @returns {Promise<{issues: (import("./interfaces/JiraIIssue.d.ts").JiraIssue & Expand)[], total: number, maxResults: number}>}
|
|
9
|
-
*/
|
|
10
|
-
export function jiraSearch(jql, opts) {
|
|
11
|
-
return jiraRequest("/rest/api/3/search/jql", {
|
|
12
|
-
params: {
|
|
13
|
-
...opts,
|
|
14
|
-
jql
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jiraRequest } from "./jira-request.js";
|
|
2
|
-
import { jiraSearch } from "./jira-search.js";
|
|
3
|
-
|
|
4
|
-
vi.mock("./jira-request.js");
|
|
5
|
-
vi.mock("axios-retry");
|
|
6
|
-
|
|
7
|
-
describe("jiraSearch", () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
vi.clearAllMocks();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should call jiraRequest with the correct JQL", async () => {
|
|
13
|
-
const mockResponse = { issues: [] };
|
|
14
|
-
vi.mocked(jiraRequest).mockResolvedValue(mockResponse);
|
|
15
|
-
|
|
16
|
-
const jql = "project = TEST";
|
|
17
|
-
const result = await jiraSearch(jql);
|
|
18
|
-
|
|
19
|
-
expect(jiraRequest).toHaveBeenCalledWith("/rest/api/3/search/jql", {
|
|
20
|
-
params: {
|
|
21
|
-
jql
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
expect(result).toEqual(mockResponse);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should call jiraRequest with the correct JQL and expend option", async () => {
|
|
28
|
-
const mockResponse = { issues: [] };
|
|
29
|
-
vi.mocked(jiraRequest).mockResolvedValue(mockResponse);
|
|
30
|
-
|
|
31
|
-
const jql = "project = TEST";
|
|
32
|
-
const result = await jiraSearch(jql, {
|
|
33
|
-
expand: "changelog"
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
expect(jiraRequest).toHaveBeenCalledWith("/rest/api/3/search/jql", {
|
|
37
|
-
params: {
|
|
38
|
-
expand: "changelog",
|
|
39
|
-
jql
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
expect(result).toEqual(mockResponse);
|
|
43
|
-
});
|
|
44
|
-
});
|
package/src/common/cli/bun.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Cli } from "./cli.js";
|
|
2
|
-
|
|
3
|
-
class BunCli extends Cli {
|
|
4
|
-
constructor() {
|
|
5
|
-
super("bun");
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
newVersion(version) {
|
|
9
|
-
return this.pm("version", "--no-git-tag-version", version);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
pm(...args) {
|
|
13
|
-
return this.sync("pm", ...args);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
run(...args) {
|
|
17
|
-
return super.run("run", ...args);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
install(...args) {
|
|
21
|
-
return super.run("install", ...args);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Reinstall dependencies without bun.lock mutation
|
|
26
|
-
* @returns {Promise<unknown>}
|
|
27
|
-
*/
|
|
28
|
-
restore() {
|
|
29
|
-
return super.run("install", "--frozen-lockfile");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const bun = new BunCli();
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
vi.mock("execa", () => {
|
|
2
|
-
const execaMock = vi.fn();
|
|
3
|
-
execaMock.sync = vi.fn();
|
|
4
|
-
return { default: execaMock };
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
const { default: execa } = await import("execa");
|
|
8
|
-
const { bun } = await import("./bun.js");
|
|
9
|
-
const { Cli } = await import("./cli.js");
|
|
10
|
-
|
|
11
|
-
execa.sync.mockImplementation((...args) => {
|
|
12
|
-
return {
|
|
13
|
-
stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
execa.mockReturnValue({});
|
|
17
|
-
|
|
18
|
-
describe("BunCli", () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
|
|
21
|
-
return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe("newVersion", () => {
|
|
25
|
-
it("should run newVersion cmd", () => {
|
|
26
|
-
const result = bun.newVersion("1.0.0");
|
|
27
|
-
|
|
28
|
-
expect(result.stdout).toEqual("CMD: bun pm version --no-git-tag-version 1.0.0");
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe("run", () => {
|
|
32
|
-
it('should run "run" cmd', async () => {
|
|
33
|
-
await bun.run("run-arg");
|
|
34
|
-
|
|
35
|
-
expect(execa).toHaveBeenCalledWith("bun", ["run", "run-arg"], {
|
|
36
|
-
cwd: process.cwd(),
|
|
37
|
-
stdio: "inherit"
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe("install", () => {
|
|
42
|
-
it('should run "install" cmd', async () => {
|
|
43
|
-
await bun.install("install-arg");
|
|
44
|
-
|
|
45
|
-
expect(execa).toHaveBeenCalledWith("bun", ["install", "install-arg"], {
|
|
46
|
-
cwd: process.cwd(),
|
|
47
|
-
stdio: "inherit"
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
package/src/common/cli/cli.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import "any-observable/register/rxjs-all.js";
|
|
2
|
-
|
|
3
|
-
import { spawnSync } from "child_process";
|
|
4
|
-
import execa from "execa";
|
|
5
|
-
import { filter, fromEvent, map, merge, takeUntil } from "rxjs";
|
|
6
|
-
export class Cli {
|
|
7
|
-
constructor(cmd) {
|
|
8
|
-
this.cmd = cmd;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
sync(...args) {
|
|
12
|
-
return Cli.run(this.cmd, args).sync();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
run(...args) {
|
|
16
|
-
return Cli.run(this.cmd, args);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get(...args) {
|
|
20
|
-
return Cli.run(this.cmd, args).get();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static run(cmd, args = [], options = {}) {
|
|
24
|
-
const run = (opt = {}) => {
|
|
25
|
-
return execa(cmd, args, {
|
|
26
|
-
cwd: process.cwd(),
|
|
27
|
-
...opt,
|
|
28
|
-
...options
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
let isPromise = true;
|
|
33
|
-
|
|
34
|
-
const promise = new Promise((resolve, reject) => {
|
|
35
|
-
setTimeout(async () => {
|
|
36
|
-
if (isPromise) {
|
|
37
|
-
try {
|
|
38
|
-
const result = await run({
|
|
39
|
-
stdio: "inherit"
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
resolve(result);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
reject(err);
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
resolve();
|
|
48
|
-
}
|
|
49
|
-
}, 10);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
promise.toObservable = (opt) => {
|
|
53
|
-
isPromise = false;
|
|
54
|
-
const cp = run(opt);
|
|
55
|
-
const end$ = fromEvent(cp, "close");
|
|
56
|
-
const stdout$ = fromEvent(cp.stdout, "data").pipe(
|
|
57
|
-
takeUntil(end$),
|
|
58
|
-
map((data) => data.toString())
|
|
59
|
-
);
|
|
60
|
-
const stderr$ = fromEvent(cp.stderr, "data").pipe(
|
|
61
|
-
takeUntil(end$),
|
|
62
|
-
map((data) => data.toString())
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return merge(stdout$, stderr$).pipe(filter(Boolean));
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
promise.toStream = (opt) => {
|
|
69
|
-
isPromise = false;
|
|
70
|
-
|
|
71
|
-
return run(opt);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
promise.cwd = (cwd) => {
|
|
75
|
-
options.cwd = cwd;
|
|
76
|
-
return promise;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
promise.sync = (opt) => {
|
|
80
|
-
isPromise = false;
|
|
81
|
-
return execa.sync(cmd, args, {
|
|
82
|
-
cwd: process.cwd(),
|
|
83
|
-
stdio: "inherit",
|
|
84
|
-
...options,
|
|
85
|
-
...opt
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
promise.getRaw = (opt) => {
|
|
90
|
-
isPromise = false;
|
|
91
|
-
return Cli.getRaw(cmd, args, {
|
|
92
|
-
cwd: process.cwd(),
|
|
93
|
-
...options,
|
|
94
|
-
...opt
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
promise.get = promise.getRaw;
|
|
99
|
-
|
|
100
|
-
return promise;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
static getRaw(cmd, args, options) {
|
|
104
|
-
return spawnSync(cmd, args, options)
|
|
105
|
-
.output.filter((o) => !!o)
|
|
106
|
-
.map((o) => o.toString())
|
|
107
|
-
.join("\n")
|
|
108
|
-
.trim();
|
|
109
|
-
}
|
|
110
|
-
}
|