Skip to content

Commit 5ca6e5c

Browse files
committed
bump hcastc00/dummy to v0.2.0
1 parent 35150c4 commit 5ca6e5c

6 files changed

Lines changed: 46 additions & 14 deletions

File tree

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"lint": "eslint . --ext .ts --fix",
1313
"build": "tsc",
1414
"prepublish": "npm run build",
15-
"pre-commit": "npm run lint && npm run test"
15+
"pre-commit": "npm run lint && npm run test",
16+
"cli": "node dist/dappnodesdk.js",
17+
"start": "yarn cli"
1618
},
1719
"repository": {
1820
"type": "git",
@@ -94,4 +96,4 @@
9496
"engines": {
9597
"node": ">=20.0.0"
9698
}
97-
}
99+
}
Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
11
import { Github } from "../../../../providers/github/Github.js";
22
import { isValidRelease } from "./isValidRelease.js";
3+
import { components } from '@octokit/openapi-types';
34

5+
type Release = components["schemas"]["release"];
46
export async function fetchGithubUpstreamVersion(
57
repo: string
68
): Promise<string | null> {
79
try {
810
const newVersion = await fetchGithubLatestTag(repo);
911
if (!isValidRelease(newVersion)) {
1012
console.log(
11-
`This is not a valid release (probably a release candidate) - ${repo}: ${newVersion}`
13+
`This is not a valid release (probably a release candidate) - ${repo}: ${newVersion.tag_name}`
1214
);
1315
return null;
1416
}
1517

16-
console.log(`Fetch latest version(s) - ${repo}: ${newVersion}`);
17-
return newVersion;
18+
console.log(`Fetch latest version(s) - ${repo}: ${newVersion.tag_name}`);
19+
return newVersion.tag_name;
1820
} catch (e) {
1921
console.error("Error fetching upstream repo versions:", e);
2022
throw e;
2123
}
2224
}
2325

24-
async function fetchGithubLatestTag(repo: string): Promise<string> {
26+
async function fetchGithubLatestTag(repo: string): Promise<Release> {
2527
const [owner, repoName] = repo.split("/");
2628
const githubRepo = new Github({ owner, repo: repoName });
2729

2830
const releases = await githubRepo.listReleases();
29-
const latestRelease = releases[0];
30-
if (!latestRelease) throw Error(`No release found for ${repo}`);
3131

32-
return latestRelease.tag_name;
32+
console.log(`Releases found for ${repo}:`, releases);
33+
// Check if is empty
34+
if (!releases || releases.length === 0) {
35+
throw Error(`No releases found for ${repo}`);
36+
}
37+
38+
// Filter out draft and prerelease
39+
const validReleases = releases.filter(
40+
release => !release.draft && !release.prerelease
41+
);
42+
if (validReleases.length === 0) {
43+
throw Error(`No valid releases found for ${repo}`);
44+
}
45+
46+
const latestRelease = validReleases[0];
47+
48+
return latestRelease;
3349
}

src/commands/githubActions/bumpUpstream/github/isValidRelease.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import semver from "semver";
2+
import type { components } from "@octokit/openapi-types";
23

3-
export function isValidRelease(version: string): boolean {
4+
export function isValidRelease(version: components["schemas"]["release"]): boolean {
5+
const tagName = version.tag_name;
46
// Nightly builds are not considered valid releases (not taken into account by semver)
5-
if (version.includes("nightly")) return false;
7+
if (tagName.includes("nightly")) return false;
68

7-
if (semver.valid(version)) {
8-
const preReleases = semver.prerelease(version);
9+
if (semver.valid(tagName)) {
10+
const preReleases = semver.prerelease(tagName);
911

1012
// A version is considered a valid release if it has no pre-release components.
1113
return preReleases === null || preReleases.length === 0;

src/commands/githubActions/bumpUpstream/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ async function gaBumpUpstreamHandler({
8181
variants_dir: variantsDir,
8282
skip_build: skipBuild
8383
}: CliCommandOptions): Promise<void> {
84+
console.log("🚀 Starting bump-upstream");
85+
console.log(`dir: ${dir}`);
86+
console.log(`eth_provider: ${userEthProvider}`);
87+
console.log(`use_fallback: ${useFallback}`);
88+
console.log(`use_variants: ${useVariants}`);
89+
console.log(`variants_dir: ${variantsDir}`);
90+
console.log(`skip_build: ${skipBuild}`);
8491
const {
8592
upstreamSettings,
8693
manifestData: { manifest, format: manifestFormat },

src/files/manifest/readManifest.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ function loadManifest(
8585
* @return path = './dappnode_package.json'
8686
*/
8787
function findManifestPath(paths?: ManifestPaths): string {
88-
const dirPath = paths?.dir || defaultDir;
88+
console.log("Finding manifest path...");
89+
console.log("Paths provided:", paths);
90+
const dirPath = paths?.dir || process.env.INIT_CWD || defaultDir;
91+
console.log("Directory path:", dirPath);
8992
if (paths?.manifestFileName) {
9093
return path.join(dirPath, paths?.manifestFileName);
9194
} else {

src/providers/github/Github.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class Github {
4848

4949
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
5050
async getRepo() {
51+
console.log("getRepo() - owner:", this.owner, "repo:", this.repo);
5152
try {
5253
const repoResponse = await this.octokit.rest.repos.get({
5354
owner: this.owner,
@@ -60,6 +61,7 @@ export class Github {
6061
return repoResponse.data;
6162
} catch (e) {
6263
if (e instanceof RequestError && e.status === 404) {
64+
console.log(e);
6365
throw new Error(`Repo does not exist: ${this.repoSlug}`);
6466
}
6567

0 commit comments

Comments
 (0)