-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle platform specific provides yml
- Loading branch information
Showing
5 changed files
with
51 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
#!/usr/bin/env -S pkgx deno run --allow-read=. --allow-net | ||
|
||
import * as yaml from "https://deno.land/[email protected]/yaml/mod.ts"; | ||
import { isArray, isString } from "https://deno.land/x/[email protected]/src/index.ts"; | ||
import get_pkg_name from "./utils/get-name.ts" | ||
import get_provides from "./utils/get-provides.ts" | ||
import { basename } from "node:path"; | ||
|
||
interface Package { | ||
project: string | ||
|
@@ -24,7 +25,8 @@ export async function getKettleRemoteMetadata() { | |
} | ||
|
||
function get_name(yml: any, project: string) { | ||
return get_pkg_name({ project, display_name: yml['display-name'], provides: yml['provides'] }) | ||
const provides = get_provides(yml) | ||
return get_pkg_name({ project, display_name: yml['display-name'], provides }) | ||
} | ||
|
||
|
||
|
@@ -37,11 +39,8 @@ for (const obj of rv as Package[]) { | |
const txt = await Deno.readTextFileSync(yaml_path) | ||
const yml = await yaml.parse(txt) as Record<string, any> | ||
|
||
const node = yml['provides'] | ||
const provides: string[] = isArray(node) ? node : isString(node) ? [node] : [] | ||
|
||
obj.displayName = get_name(yaml_path, obj.project) | ||
obj.programs = provides.map(x => x.slice(4)) | ||
obj.programs = get_provides(yml).map(x => basename(x)) | ||
} catch (err) { | ||
console.warn(`::warning::${err.message}`) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,12 +75,14 @@ console.log(JSON.stringify(pkgs, null, 2)); | |
|
||
////////////////////////////////////////////////////// | ||
import { parse } from "https://deno.land/[email protected]/yaml/mod.ts"; | ||
import get_provides from "./utils/get-provides.ts"; | ||
import get_pkg_name from "./utils/get-name.ts"; | ||
|
||
async function get_name(path: string, project: string): Promise<string | undefined> { | ||
const txt = await Deno.readTextFileSync(path) | ||
const yml = await parse(txt) as Record<string, any> | ||
return get_pkg_name({ project, display_name: yml['display-name'], provides: yml['provides'] }) | ||
const provides = get_provides(yml) | ||
return get_pkg_name({ project, display_name: yml['display-name'], provides }) | ||
} | ||
|
||
import { parse_pkgs_node } from "https://deno.land/x/[email protected]/src/hooks/usePantry.ts" | ||
|
@@ -107,8 +109,6 @@ async function get_labels(path: string) { | |
} | ||
})) | ||
|
||
console.error(path) | ||
|
||
if (yml.build?.dependencies) for (const dep of parse_pkgs_node(yml.build.dependencies)) { | ||
switch (dep.project) { | ||
case 'rust-lang.org': | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { isString, isPlainObject } from "https://deno.land/x/[email protected]/src/index.ts"; | ||
|
||
export default function get_provides(yml: any): string[] { | ||
let provides = yml['provides'] | ||
if (isString(provides)) { | ||
return [provides] | ||
} | ||
if (isPlainObject(provides)) { | ||
const { darwin, linux, windows } = provides | ||
provides = [] | ||
const set = new Set() | ||
for (const x of [darwin, linux, windows].flatMap(x => x)) { | ||
if (!set.has(x)) { | ||
provides.push(x) | ||
set.add(x) | ||
} | ||
} | ||
} | ||
return provides ?? [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters