Skip to content

Commit

Permalink
add logo_url and logo_alt to package_meta
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Jul 16, 2024
1 parent 333fe69 commit b3387d8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-foxes-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ryanatkn/gro': patch
---

add `logo_url` and `logo_alt` to `package_meta`
30 changes: 22 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"typescript"
],
"dependencies": {
"@ryanatkn/belt": "^0.24.7",
"@ryanatkn/belt": "^0.24.9",
"chokidar": "^3.6.0",
"dotenv": "^16.4.5",
"es-module-lexer": "^1.5.4",
Expand All @@ -68,7 +68,7 @@
"devDependencies": {
"@changesets/changelog-git": "^0.2.0",
"@changesets/types": "^6.0.0",
"@ryanatkn/eslint-config": "^0.4.1",
"@ryanatkn/eslint-config": "^0.4.2",
"@ryanatkn/fuz": "^0.110.4",
"@ryanatkn/moss": "^0.8.0",
"@sveltejs/adapter-static": "^3.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const package_json = {
'typescript',
],
dependencies: {
'@ryanatkn/belt': '^0.24.7',
'@ryanatkn/belt': '^0.24.9',
chokidar: '^3.6.0',
dotenv: '^16.4.5',
'es-module-lexer': '^1.5.4',
Expand All @@ -60,7 +60,7 @@ export const package_json = {
devDependencies: {
'@changesets/changelog-git': '^0.2.0',
'@changesets/types': '^6.0.0',
'@ryanatkn/eslint-config': '^0.4.1',
'@ryanatkn/eslint-config': '^0.4.2',
'@ryanatkn/fuz': '^0.110.4',
'@ryanatkn/moss': '^0.8.0',
'@sveltejs/adapter-static': '^3.0.2',
Expand Down
23 changes: 17 additions & 6 deletions src/lib/package_meta.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {strip_start, strip_end} from '@ryanatkn/belt/string.js';
import {strip_start, strip_end, ensure_end} from '@ryanatkn/belt/string.js';

import type {Package_Json, Url} from './package_json.js';
import type {Src_Json} from './src_json.js';
Expand All @@ -8,15 +8,17 @@ export interface Package_Meta {
url: Url;
package_json: Package_Json;
src_json: Src_Json;
name: string; // '@ryanatkn/fuz_library';
name: string; // '@ryanatkn/fuz_library'
repo_name: string; // fuz_library
repo_url: Url | null; // 'https://github.com/ryanatkn/fuz';
repo_url: Url | null; // 'https://github.com/ryanatkn/fuz'
/**
* the is the github user/org, not npm
*/
owner_name: string | null; // 'fuz-dev';
homepage_url: Url | null; // 'https://www.fuz.dev/';
npm_url: Url | null; // 'https://npmjs.com/package/@ryanatkn/fuz_library';
owner_name: string | null; // 'fuz-dev'
homepage_url: Url | null; // 'https://www.fuz.dev/'
logo_url: Url | null; // 'https://www.fuz.dev/logo.svg' falling back to 'https://www.fuz.dev/favicon.png'
logo_alt: string; // 'icon for gro'
npm_url: Url | null; // 'https://npmjs.com/package/@ryanatkn/fuz_library'
changelog_url: Url | null;
published: boolean;
}
Expand Down Expand Up @@ -56,6 +58,13 @@ export const parse_package_meta = (

const owner_name = repo_url ? strip_start(repo_url, 'https://github.com/').split('/')[0] : null;

const logo_url = homepage_url
? ensure_end(homepage_url, '/') +
(package_json.logo ? strip_start(package_json.logo, '/') : 'favicon.png')
: null;

const logo_alt = package_json.logo_alt ?? `logo for ${repo_name}`;

return {
url,
package_json,
Expand All @@ -65,6 +74,8 @@ export const parse_package_meta = (
repo_url,
owner_name,
homepage_url,
logo_url,
logo_alt,
npm_url,
changelog_url,
published,
Expand Down

0 comments on commit b3387d8

Please sign in to comment.