mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Fix previous feat
This commit is contained in:
parent
a685911c7b
commit
42b51ab7b0
3 changed files with 33 additions and 20 deletions
7
dist/index.js
vendored
7
dist/index.js
vendored
|
|
@ -321,12 +321,15 @@ exports.action = action;
|
||||||
function getPackageJsonVersion(params) {
|
function getPackageJsonVersion(params) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { owner, repo, branch, github_token } = params;
|
const { owner, repo, branch, github_token } = params;
|
||||||
const version = yield node_fetch_1.default(urlJoin(`https://raw.github.com`, owner, repo, branch, "package.json"), {
|
const version = yield node_fetch_1.default(`https://api.github.com/repos/${owner}/${repo}/contents/package.json?ref=${branch}`, {
|
||||||
"headers": {
|
"headers": {
|
||||||
"Authorization": `token ${github_token}`
|
"Authorization": `token ${github_token}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(res => res.text())
|
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const { content } = JSON.parse(yield res.text());
|
||||||
|
return Buffer.from(content, "base64").toString("utf-8");
|
||||||
|
}))
|
||||||
.then(text => JSON.parse(text))
|
.then(text => JSON.parse(text))
|
||||||
.then(({ version }) => version)
|
.then(({ version }) => version)
|
||||||
.catch(() => undefined);
|
.catch(() => undefined);
|
||||||
|
|
|
||||||
|
|
@ -110,27 +110,32 @@ async function getPackageJsonVersion(params: {
|
||||||
github_token: string;
|
github_token: string;
|
||||||
}): Promise<NpmModuleVersion | undefined> {
|
}): Promise<NpmModuleVersion | undefined> {
|
||||||
|
|
||||||
const { owner, repo, branch, github_token } = params;
|
const {
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
branch,
|
||||||
|
github_token
|
||||||
|
} = params;
|
||||||
|
|
||||||
const version = await fetch(
|
const version = await fetch(
|
||||||
urlJoin(
|
`https://api.github.com/repos/${owner}/${repo}/contents/package.json?ref=${branch}`,
|
||||||
`https://raw.github.com`,
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
branch,
|
|
||||||
"package.json"
|
|
||||||
),
|
|
||||||
{
|
{
|
||||||
"headers": {
|
"headers": {
|
||||||
"Authorization": `token ${github_token}`
|
"Authorization": `token ${github_token}`
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
})
|
||||||
.then(res => res.text())
|
.then(async res => {
|
||||||
|
|
||||||
|
const { content }= JSON.parse(await res.text()) as { content: string; };
|
||||||
|
|
||||||
|
return Buffer.from(content, "base64").toString("utf-8");
|
||||||
|
|
||||||
|
})
|
||||||
.then(text => JSON.parse(text))
|
.then(text => JSON.parse(text))
|
||||||
|
|
||||||
.then(({ version }) => version as string)
|
.then(({ version }) => version as string)
|
||||||
.catch(() => undefined)
|
.catch(() => undefined)
|
||||||
;
|
|
||||||
|
|
||||||
if (version === undefined) {
|
if (version === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,21 @@
|
||||||
|
|
||||||
|
|
||||||
import { action } from "../is_package_json_version_upgraded";
|
import { action } from "../is_package_json_version_upgraded";
|
||||||
|
import { assert } from "tsafe/assert";
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
||||||
const repo = "keycloakify-demo-app";
|
const repo = "tss-react";
|
||||||
|
|
||||||
|
const github_token = process.env.GITHUB_TOKEN
|
||||||
|
|
||||||
|
assert(github_token !== undefined);
|
||||||
|
|
||||||
const result = await action("is_package_json_version_upgraded", {
|
const result = await action("is_package_json_version_upgraded", {
|
||||||
"owner": "InseeFrLab",
|
"owner": "garronej",
|
||||||
repo,
|
repo,
|
||||||
"branch": "4fc0ccb46bdb3912e0a215ca3ae45aed458ea6a4",
|
"branch": "main",
|
||||||
"github_token": ""
|
github_token
|
||||||
}, { "debug": console.log });
|
}, { "debug": console.log });
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue