-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
973 additions
and
915 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@pkgr/browser": minor | ||
"@pkgr/core": minor | ||
"@pkgr/utils": minor | ||
--- | ||
|
||
feat: split `@pkgr/utils` into `@pkgr/core` and `@pkgr/browser` |
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,5 +1,5 @@ | ||
{ | ||
"node": "16", | ||
"node": "18", | ||
"packages": [ | ||
"packages/*" | ||
], | ||
|
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
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
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
"workspaces": [ | ||
"packages/**" | ||
], | ||
"packageManager": "[email protected].19", | ||
"packageManager": "[email protected].21", | ||
"scripts": { | ||
"build": "run-s build:ts build:r", | ||
"build:r": "tsx packages/rollup/src/cli.ts -f cjs -d false", | ||
|
@@ -27,24 +27,24 @@ | |
"typecov": "type-coverage" | ||
}, | ||
"devDependencies": { | ||
"@1stg/common-config": "^9.0.0", | ||
"@changesets/changelog-github": "^0.4.8", | ||
"@changesets/cli": "^2.26.2", | ||
"@types/cross-spawn": "^6.0.2", | ||
"@types/debug": "^4.1.8", | ||
"@types/imagemin": "^8.0.1", | ||
"@types/is-glob": "^4.0.2", | ||
"@types/jest": "^29.5.3", | ||
"@types/lodash-es": "^4.17.8", | ||
"@types/micromatch": "^4.0.2", | ||
"@types/node": "^20.4.6", | ||
"jest": "^29.6.2", | ||
"@1stg/common-config": "^9.0.1", | ||
"@changesets/changelog-github": "^0.5.0", | ||
"@changesets/cli": "^2.27.1", | ||
"@types/cross-spawn": "^6.0.6", | ||
"@types/debug": "^4.1.12", | ||
"@types/imagemin": "^8.0.5", | ||
"@types/is-glob": "^4.0.4", | ||
"@types/jest": "^29.5.11", | ||
"@types/lodash-es": "^4.17.12", | ||
"@types/micromatch": "^4.0.6", | ||
"@types/node": "^20.10.5", | ||
"jest": "^29.7.0", | ||
"patch-package": "^8.0.0", | ||
"rimraf": "^5.0.1", | ||
"rimraf": "^5.0.5", | ||
"ts-jest": "^29.1.1", | ||
"tsx": "^3.12.7", | ||
"type-coverage": "^2.26.0", | ||
"typescript": "^5.1.6", | ||
"tsx": "^4.7.0", | ||
"type-coverage": "^2.27.1", | ||
"typescript": "^5.3.3", | ||
"yarn-deduplicate": "^6.0.2" | ||
}, | ||
"resolutions": { | ||
|
File renamed without changes.
File renamed without changes.
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,36 @@ | ||
{ | ||
"name": "@pkgr/browser", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"description": "Shared browser utils for `@pkgr` packages or any package else", | ||
"repository": "git+https://github.com/un-ts/pkgr.git", | ||
"homepage": "https://github.com/un-ts/pkgr/blob/master/packages/browser", | ||
"author": "JounQin (https://www.1stG.me) <[email protected]>", | ||
"funding": "https://opencollective.com/unts", | ||
"license": "MIT", | ||
"engines": { | ||
"node": "^12.20.0 || ^14.18.0 || >=16.0.0" | ||
}, | ||
"main": "./lib/index.cjs", | ||
"module": "./lib/index.js", | ||
"exports": { | ||
"types": "./lib/index.d.ts", | ||
"import": "./lib/index.js", | ||
"require": "./lib/index.cjs" | ||
}, | ||
"types": "./lib/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"openChrome.applescript" | ||
], | ||
"dependencies": { | ||
"cross-spawn": "^7.0.3", | ||
"open": "^8.4.2 || ^9.1.0 || ^10.0.1", | ||
"picocolors": "^1.0.0", | ||
"tslib": "^2.6.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"sideEffects": false | ||
} |
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,9 @@ | ||
{ | ||
"extends": "@1stg/tsconfig/lib", | ||
"compilerOptions": { | ||
"composite": true, | ||
"outDir": "lib", | ||
"rootDir": "." | ||
}, | ||
"exclude": ["lib", "test"] | ||
} |
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,29 @@ | ||
{ | ||
"name": "@pkgr/core", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"description": "Shared core module for `@pkgr` packages or any package else", | ||
"repository": "git+https://github.com/un-ts/pkgr.git", | ||
"homepage": "https://github.com/un-ts/pkgr/blob/master/packages/core", | ||
"author": "JounQin (https://www.1stG.me) <[email protected]>", | ||
"funding": "https://opencollective.com/unts", | ||
"license": "MIT", | ||
"engines": { | ||
"node": "^12.20.0 || ^14.18.0 || >=16.0.0" | ||
}, | ||
"main": "./lib/index.cjs", | ||
"module": "./lib/index.js", | ||
"exports": { | ||
"types": "./lib/index.d.ts", | ||
"import": "./lib/index.js", | ||
"require": "./lib/index.cjs" | ||
}, | ||
"types": "./lib/index.d.ts", | ||
"files": [ | ||
"lib" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"sideEffects": false | ||
} |
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,9 @@ | ||
import { createRequire } from 'node:module' | ||
|
||
export const CWD = process.cwd() | ||
|
||
export const cjsRequire = | ||
typeof require === 'undefined' ? createRequire(import.meta.url) : require | ||
|
||
// eslint-disable-next-line n/no-deprecated-api, sonar/deprecation | ||
export const EXTENSIONS = ['.ts', '.tsx', ...Object.keys(cjsRequire.extensions)] |
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,61 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
|
||
import { CWD, EXTENSIONS, cjsRequire } from './constants.js' | ||
|
||
export const tryPkg = (pkg: string) => { | ||
try { | ||
return cjsRequire.resolve(pkg) | ||
} catch {} | ||
} | ||
|
||
export const isPkgAvailable = (pkg: string) => !!tryPkg(pkg) | ||
|
||
export const tryFile = (filePath?: string[] | string, includeDir = false) => { | ||
if (typeof filePath === 'string') { | ||
return fs.existsSync(filePath) && | ||
(includeDir || fs.statSync(filePath).isFile()) | ||
? filePath | ||
: '' | ||
} | ||
|
||
for (const file of filePath ?? []) { | ||
if (tryFile(file, includeDir)) { | ||
return file | ||
} | ||
} | ||
|
||
return '' | ||
} | ||
|
||
export const tryExtensions = (filepath: string, extensions = EXTENSIONS) => { | ||
const ext = [...extensions, ''].find(ext => tryFile(filepath + ext)) | ||
return ext == null ? '' : filepath + ext | ||
} | ||
|
||
export const findUp = (searchEntry: string, searchFile = 'package.json') => { | ||
console.assert(path.isAbsolute(searchEntry)) | ||
|
||
if ( | ||
!tryFile(searchEntry, true) || | ||
(searchEntry !== CWD && !searchEntry.startsWith(CWD + path.sep)) | ||
) { | ||
return '' | ||
} | ||
|
||
searchEntry = path.resolve( | ||
fs.statSync(searchEntry).isDirectory() | ||
? searchEntry | ||
: path.resolve(searchEntry, '..'), | ||
) | ||
|
||
do { | ||
const searched = tryFile(path.resolve(searchEntry, searchFile)) | ||
if (searched) { | ||
return searched | ||
} | ||
searchEntry = path.resolve(searchEntry, '..') | ||
} while (searchEntry === CWD || searchEntry.startsWith(CWD + path.sep)) | ||
|
||
return '' | ||
} |
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,2 @@ | ||
export * from './constants.js' | ||
export * from './helpers.js' |
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,9 @@ | ||
{ | ||
"extends": "@1stg/tsconfig/lib", | ||
"compilerOptions": { | ||
"composite": true, | ||
"outDir": "lib", | ||
"rootDir": "src" | ||
}, | ||
"exclude": ["lib", "test"] | ||
} |
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
Oops, something went wrong.