mirror of
https://github.com/pezkuwichain/pezkuwi-dev.git
synced 2026-11-14 02:37:07 +00:00
build-ts: keep a package homepage that points outside the repository (0.86.9) (#34)
* build-ts: keep a package homepage that points outside the repository orderPackageJson derived homepage from repository.url on every build, so a package could not link its npm page to its API reference: the build put the repository readme back and the clean-tree check failed. A homepage inside the repository, or none, is still derived as before. * Release dev, dev-test and dev-ts together as 0.86.9
This commit is contained in:
1 parent
07e75fff9b
commit
467c8b99bd
10 files changed
+74
-14
No files matched your search
@@ -9,7 +9,7 @@ import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import ts from 'typescript';
|
||||
|
||||
import { copyDirSync, copyFileSync, DENO_EXT_PRE, DENO_LND_PRE, DENO_POL_PRE, engineVersionCmp, execPm, exitFatal, exitFatalEngine, logBin, mkdirpSync, PATHS_BUILD, readdirSync, rimrafSync } from './util.mjs';
|
||||
import { copyDirSync, copyFileSync, DENO_EXT_PRE, DENO_LND_PRE, DENO_POL_PRE, engineVersionCmp, execPm, exitFatal, exitFatalEngine, logBin, mkdirpSync, packageHomepage, PATHS_BUILD, readdirSync, rimrafSync } from './util.mjs';
|
||||
|
||||
/** @typedef {'babel' | 'esbuild' | 'swc' | 'tsc'} CompileType */
|
||||
/** @typedef {{ bin?: Record<string, string>; browser?: string; bugs?: string; deno?: string; denoDependencies?: Record<string, string>; dependencies?: Record<string, string>; devDependencies?: Record<string, string>; electron?: string; engines?: { node?: string }; exports?: Record<string, unknown>; license?: string; homepage?: string; main?: string; module?: string; name?: string; optionalDependencies?: Record<string, string>; peerDependencies?: Record<string, string>; repository?: { directory?: string; type: 'git'; url: string; }; 'react-native'?: string; resolutions?: Record<string, string>; sideEffects?: boolean | string[]; scripts?: Record<string, string>; type?: 'module' | 'commonjs'; types?: string; version?: string; }} PkgJson */
|
||||
@@ -973,7 +973,7 @@ function repoBaseFromUrl (url) {
|
||||
*/
|
||||
function orderPackageJson (repoBase, dir, json) {
|
||||
json.bugs = `${repoBase}/issues`;
|
||||
json.homepage = `${repoBase}${dir ? `/tree/master/packages/${dir}` : ''}#readme`;
|
||||
json.homepage = packageHomepage(repoBase, dir, json.homepage);
|
||||
json.license = !json.license || json.license === 'Apache-2'
|
||||
? 'Apache-2.0'
|
||||
: json.license;
|
||||
|
||||
@@ -146,6 +146,24 @@ export function engineVersionSplit (ver) {
|
||||
return [parseInt(parts[0] || '0', 10), parseInt(parts[1] || '0', 10), parseInt(parts[2] || '0', 10)];
|
||||
}
|
||||
|
||||
/**
|
||||
* The homepage written into a package.json. One the author pointed outside the
|
||||
* repository (an API reference, a product site) is kept; anything else, and an
|
||||
* absent one, is derived from the repository.
|
||||
*
|
||||
* @param {string} repoBase e.g. https://git.example.org/owner/repo
|
||||
* @param {string | null} dir package directory under packages/, null for the root
|
||||
* @param {string} [current] the homepage the package.json carries now
|
||||
* @returns {string}
|
||||
*/
|
||||
export function packageHomepage (repoBase, dir, current) {
|
||||
const inRepo = !current || current === repoBase || current.startsWith(`${repoBase}/`) || current.startsWith(`${repoBase}#`);
|
||||
|
||||
return inRepo
|
||||
? `${repoBase}${dir ? `/tree/master/packages/${dir}` : ''}#readme`
|
||||
: current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process execution
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user