Skip to content

Commit

Permalink
feat(root): fix homepage fields on packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sabinmarcu committed Aug 26, 2024
1 parent 9b0585e commit 8a6ca95
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion workspaces/components/moving-mesh-background/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@
"type": "git",
"directory": "workspaces/components/moving-mesh-background"
},
"homepage": "https://sabinmarcu.dev//api/moving-mesh-background"
"homepage": "https:/sabinmarcu.dev/api/moving-mesh-background"
}
2 changes: 1 addition & 1 deletion workspaces/components/mui-material-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"type": "git",
"directory": "workspaces/components/mui-material-theme"
},
"homepage": "https://sabinmarcu.dev//api/mui-material-theme",
"homepage": "https:/sabinmarcu.dev/api/mui-material-theme",
"optionalDependencies": {
"@mui/icons-material": "^5.16.6",
"@mui/material": "^5.16.6"
Expand Down
2 changes: 1 addition & 1 deletion workspaces/hooks/useDuplicateRef/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@
"type": "git",
"directory": "workspaces/hooks/useDuplicateRef"
},
"homepage": "https://sabinmarcu.dev//api/use-duplicate-ref"
"homepage": "https:/sabinmarcu.dev/api/use-duplicate-ref"
}
2 changes: 1 addition & 1 deletion workspaces/hooks/useLocalStorage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
"type": "git",
"directory": "workspaces/hooks/useLocalStorage"
},
"homepage": "https://sabinmarcu.dev//api/use-local-storage"
"homepage": "https:/sabinmarcu.dev/api/use-local-storage"
}
2 changes: 1 addition & 1 deletion workspaces/hooks/useMatchMedia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
"type": "git",
"directory": "workspaces/hooks/useMatchMedia"
},
"homepage": "https://sabinmarcu.dev//api/use-match-media"
"homepage": "https:/sabinmarcu.dev/api/use-match-media"
}
2 changes: 1 addition & 1 deletion workspaces/hooks/usePrefersReducedMotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@
"type": "git",
"directory": "workspaces/hooks/usePrefersReducedMotion"
},
"homepage": "https://sabinmarcu.dev//api/use-prefers-reduced-motion"
"homepage": "https:/sabinmarcu.dev/api/use-prefers-reduced-motion"
}
2 changes: 1 addition & 1 deletion workspaces/libs/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
"type": "git",
"directory": "workspaces/libs/config"
},
"homepage": "https://sabinmarcu.dev//api/config"
"homepage": "https:/sabinmarcu.dev/api/config"
}
2 changes: 1 addition & 1 deletion workspaces/libs/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@
"type": "git",
"directory": "workspaces/libs/debug"
},
"homepage": "https://sabinmarcu.dev//api/debug"
"homepage": "https:/sabinmarcu.dev/api/debug"
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
"directory": "workspaces/libs/eslint-plugin-logical-properties",
"type": "git"
},
"homepage": "https://sabinmarcu.dev//api/undefined"
"homepage": "https:/sabinmarcu.dev/api/eslint-plugin-logical-properties"
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@
"type": "git",
"directory": "workspaces/libs/jotai-storage-adapter-querystring"
},
"homepage": "https://sabinmarcu.dev//api/jotai-storage-adapter-querystring"
"homepage": "https:/sabinmarcu.dev/api/jotai-storage-adapter-querystring"
}
2 changes: 1 addition & 1 deletion workspaces/libs/observable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
"type": "git",
"directory": "workspaces/libs/observable"
},
"homepage": "https://sabinmarcu.dev//api/observable"
"homepage": "https:/sabinmarcu.dev/api/observable"
}
2 changes: 1 addition & 1 deletion workspaces/libs/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@
"type": "git",
"directory": "workspaces/libs/types"
},
"homepage": "https://sabinmarcu.dev//api/types"
"homepage": "https:/sabinmarcu.dev/api/types"
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
"type": "git",
"directory": "workspaces/personal/commitlint-config-workspaces"
},
"homepage": "https://sabinmarcu.dev//api/commitlint-config-workspaces"
"homepage": "https:/sabinmarcu.dev/api/commitlint-config-workspaces"
}
2 changes: 1 addition & 1 deletion workspaces/personal/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@
"type": "git",
"directory": "workspaces/personal/eslint-config"
},
"homepage": "https://sabinmarcu.dev//api/eslint-config"
"homepage": "https:/sabinmarcu.dev/api/eslint-config"
}
2 changes: 1 addition & 1 deletion workspaces/repo/omnicli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@
"type": "git",
"directory": "workspaces/repo/omnicli"
},
"homepage": "https://sabinmarcu.dev//api/omnicli"
"homepage": "https:/sabinmarcu.dev/api/omnicli"
}
2 changes: 1 addition & 1 deletion workspaces/utils/utils-fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
"type": "git",
"directory": "workspaces/utils/utils-fs"
},
"homepage": "https://sabinmarcu.dev//api/utils-fs"
"homepage": "https:/sabinmarcu.dev/api/utils-fs"
}
2 changes: 1 addition & 1 deletion workspaces/utils/utils-path/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
"type": "git",
"directory": "workspaces/utils/utils-path"
},
"homepage": "https://sabinmarcu.dev//api/utils-path"
"homepage": "https:/sabinmarcu.dev/api/utils-path"
}
2 changes: 1 addition & 1 deletion workspaces/utils/utils-primitives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
"type": "git",
"directory": "workspaces/utils/utils-primitives"
},
"homepage": "https://sabinmarcu.dev//api/utils-primitives"
"homepage": "https:/sabinmarcu.dev/api/utils-primitives"
}
2 changes: 1 addition & 1 deletion workspaces/utils/utils-repo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
"type": "git",
"directory": "workspaces/utils/utils-repo"
},
"homepage": "https://sabinmarcu.dev//api/utils-repo"
"homepage": "https:/sabinmarcu.dev/api/utils-repo"
}
2 changes: 1 addition & 1 deletion workspaces/utils/utils-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@
"type": "git",
"directory": "workspaces/utils/utils-test"
},
"homepage": "https://sabinmarcu.dev//api/utils-test"
"homepage": "https:/sabinmarcu.dev/api/utils-test"
}
21 changes: 11 additions & 10 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const {
FIELD_TSCMONO_PRESET_KEY,
FIELD_TSCMONO_PRESETS_KEY,
MODULE_DEPENDENCY_ENFORCEMENT_FIELD_LIST,
FIELD_REMOVE_MAP,
TREAT_AS_CJS,
CJS_FIELD_UPDATE_MAP,
} = require('./.config/manifest.cjs');
Expand All @@ -33,6 +32,7 @@ const { WORKSPACE_PROTOCOL_RANGE } = require('./.config/yarn.cjs');

const getMoonConfigOf = moize.promise(async (path) => {
const { readFileSync } = await import('node:fs');
// eslint-disable-next-line unicorn/import-style
const { resolve } = await import('node:path');
const { parse } = await import('yaml');

Expand Down Expand Up @@ -64,7 +64,8 @@ const shouldSkipConsistentDependencyEnforcement = (dependency) => {
if (!dependency.workspace.pkg[dependency.type]?.[dependency.ident]) {
return true;
}
}
return false;
};
/**
* This rule will enforce that a workspace MUST depend on the same version of
* a dependency as the one used by the other workspaces.
Expand Down Expand Up @@ -106,7 +107,7 @@ async function ensureFieldConsistency({ Yarn }) {
}

if (matches.length > 0) {
const [[,match]] = matches.sort(([a], [b]) => b.length - a.length);
const [[, match]] = matches.sort(([a], [b]) => b.length - a.length);
if (Array.isArray(match)) {
for (const [index, value] of Object.entries(match)) {
workspace.set(`${FIELD_TSCMONO_PRESETS_KEY}[${index}]`, value);
Expand Down Expand Up @@ -160,24 +161,22 @@ async function ensureDocsDependencies({ Yarn }) {
if (DOCS_WORKSPACE_EXCLUDES.includes(workspace.ident)) {
continue;
}
// eslint-disable-next-line no-await-in-loop

const moonConfig = await getMoonConfigOf(workspace.cwd);
if (moonConfig.type === 'library') {
docsWorkspace.set(`devDependencies.${workspace.ident}`, WORKSPACE_PROTOCOL_RANGE);
}
}
}

// eslint-disable-next-line unicorn/prevent-abbreviations
async function ensureStorybookDependencies({ Yarn }) {
// eslint-disable-next-line unicorn/prevent-abbreviations
const storybookWorkspace = Yarn.workspace({ ident: STORYBOOK_WORKSPACE_NAME });
for (const workspace of Yarn.workspaces()) {
if (workspace.ident === storybookWorkspace.ident) {
continue;
}
if (!STORYBOOK_WORKSPACE_PATHS.some(
(workspacePath) => workspace.cwd.includes(workspacePath)
(workspacePath) => workspace.cwd.includes(workspacePath),
)) {
continue;
}
Expand All @@ -195,15 +194,17 @@ async function ensureStorybookDependencies({ Yarn }) {
*/
async function ensureHomepageAndRepository({ Yarn }) {
const rootWorkspace = Yarn.workspace({ ident: 'root' });
const {homepage,repository}= rootWorkspace?.manifest;
const { homepage, repository } = rootWorkspace?.manifest ?? {};
for (const workspace of Yarn.workspaces()) {
if (workspace.ident !== 'root' && !workspace.cwd.includes('apps')) {
const workspaceHomepage = `${homepage}/api/${workspace.ident?.split('/')[1]}`;
const workspaceSplit = workspace.ident?.split('/') ?? [];
const workspaceHomepage = `${homepage}/api/${workspaceSplit.at(-1)}`
.replaceAll(/\/{2,}/g, '/');
workspace.set('repository.url', repository.url);
workspace.set('repository.directory', workspace.cwd);
workspace.set('repository.type', repository.type);
workspace.set('homepage', workspaceHomepage);
}
}
}
}

Expand Down

0 comments on commit 8a6ca95

Please sign in to comment.