Skip to content

Commit

Permalink
Merge branch 'SukkaW:master' into es6-promise
Browse files Browse the repository at this point in the history
  • Loading branch information
asukaminato0721 authored Oct 20, 2024
2 parents ffd7c85 + 165d9da commit d135b75
Show file tree
Hide file tree
Showing 34 changed files with 1,568 additions and 1,738 deletions.
2 changes: 1 addition & 1 deletion create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { fileExists, compareAndWriteFile } from '@nolyfill/internal';
import { transform } from '@swc/core';
import type { Options as SwcOptions } from '@swc/core';

import type { PackageJson } from 'type-fest';
import type { PackageJson } from '@package-json/types';

/**
* The package.json inside the project has a non-nullable "version" field,
Expand Down
41 changes: 20 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nolyfill-monorepo",
"version": "1.0.39",
"version": "1.0.41",
"private": true,
"files": [],
"scripts": {
Expand All @@ -12,29 +12,28 @@
"release": "bumpp --all --commit \"release: %s\" --tag \"%s\""
},
"devDependencies": {
"@eslint-sukka/node": "^6.1.6",
"@eslint-sukka/ts": "^5.1.2",
"@eslint-sukka/node": "^6.7.0",
"@jsdevtools/ez-spawn": "^3.0.4",
"@nolyfill/internal": "workspace:*",
"@package-json/types": "^0.0.11",
"@swc-node/register": "^1.10.9",
"@swc/core": "^1.7.0",
"@types/node": "^20.14.11",
"@swc/core": "^1.7.36",
"@types/node": "^20.16.11",
"bumpp": "^9.4.1",
"dequal": "2.0.3",
"eslint": "^9.7.0",
"eslint-config-sukka": "^6.1.6",
"eslint-formatter-sukka": "^6.1.6",
"path-scurry": "^1.11.1",
"picocolors": "^1.0.1",
"eslint": "^9.12.0",
"eslint-config-sukka": "^6.7.0",
"eslint-formatter-sukka": "^6.7.0",
"path-scurry": "^2.0.0",
"picocolors": "^1.1.0",
"rimraf": "^6.0.1",
"rollup": "^4.19.0",
"rollup": "^4.24.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-swc3": "^0.11.2",
"turbo": "^2.0.9",
"type-fest": "^4.22.1",
"typescript": "^5.5.3"
"rollup-plugin-swc3": "^0.12.1",
"turbo": "^2.1.3",
"typescript": "^5.6.3"
},
"packageManager": "pnpm@9.5.0",
"packageManager": "pnpm@9.12.1",
"engines": {
"node": ">=16.8.0"
},
Expand Down Expand Up @@ -146,13 +145,13 @@
"which-typed-array": "workspace:@nolyfill/which-typed-array@*"
},
"patchedDependencies": {
"@types/[email protected]": "patches/@[email protected]",
"@npmcli/[email protected]": "patches/@[email protected]",
"[email protected]": "patches/[email protected]",
"@yarnpkg/[email protected]": "patches/@[email protected]",
"@pnpm/[email protected]": "patches/@[email protected]",
"@pnpm/[email protected]": "patches/@[email protected]",
"@pnpm/[email protected]": "patches/@[email protected]"
"@pnpm/[email protected]": "patches/@[email protected]",
"@pnpm/[email protected]": "patches/@[email protected]",
"@yarnpkg/parsers": "patches/@yarnpkg__parsers.patch",
"@npmcli/arborist": "patches/@npmcli__arborist.patch",
"@types/npmcli__arborist": "patches/@types__npmcli__arborist.patch"
}
},
"overrides": {
Expand Down
2 changes: 1 addition & 1 deletion packages/data/es-shim-like/src/function.prototype.name.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { defineEsShim } from '@nolyfill/shared';

export default defineEsShim(Function.prototype.name);
export default defineEsShim<Function, (this: Function) => string>(function functionPrototypeName() { return this.name; });
3 changes: 2 additions & 1 deletion packages/data/single-file/src/safe-buffer.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export default Buffer;
// eslint-disable-next-line n/no-deprecated-api -- ignore deprecation
export * from 'node:buffer';
3 changes: 2 additions & 1 deletion packages/data/single-file/src/safer-buffer.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export default Buffer;
// eslint-disable-next-line n/no-deprecated-api -- ignore deprecation
export * from 'node:buffer';
2 changes: 1 addition & 1 deletion packages/generated/function.prototype.name/entry.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e}});const e=(0,require("@nolyfill/shared").defineEsShim)(Function.prototype.name);
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e}});const e=(0,require("@nolyfill/shared").defineEsShim)(function(){return this.name});
Object.assign(exports.default, exports); module.exports = exports.default;
2 changes: 1 addition & 1 deletion packages/generated/function.prototype.name/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nolyfill/function.prototype.name",
"version": "1.0.28",
"version": "1.0.40",
"repository": {
"type": "git",
"url": "https://github.com/SukkaW/nolyfill",
Expand Down
2 changes: 1 addition & 1 deletion packages/generated/safe-buffer/index.js

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

2 changes: 1 addition & 1 deletion packages/generated/safe-buffer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nolyfill/safe-buffer",
"version": "1.0.40",
"version": "1.0.41",
"repository": {
"type": "git",
"url": "https://github.com/SukkaW/nolyfill",
Expand Down
2 changes: 1 addition & 1 deletion packages/generated/safer-buffer/index.js

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

2 changes: 1 addition & 1 deletion packages/generated/safer-buffer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nolyfill/safer-buffer",
"version": "1.0.40",
"version": "1.0.41",
"repository": {
"type": "git",
"url": "https://github.com/SukkaW/nolyfill",
Expand Down
8 changes: 4 additions & 4 deletions packages/manual/assert/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"browserify-util": "^0.12.6"
},
"devDependencies": {
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-replace": "^6.0.1",
"commonjs-assert": "npm:assert@^2.1.0",
"resolve-pkg": "^2.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/manual/assert/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PackageJson } from 'type-fest';
import type { PackageJson } from '@package-json/types';

import resolve from 'resolve-pkg';
import fs from 'fs';
Expand Down
8 changes: 4 additions & 4 deletions packages/manual/es-iterator-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
"@nolyfill/shared": "workspace:*"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"ljharb-es-iterator-helpers": "npm:es-iterator-helpers@^1.0.19",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-replace": "^6.0.1",
"ljharb-es-iterator-helpers": "npm:es-iterator-helpers@^1.1.0",
"resolve-pkg": "^2.0.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/manual/es-iterator-helpers/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PackageJson } from 'type-fest';
import type { PackageJson } from '@package-json/types';

import resolve from 'resolve-pkg';
import fs from 'fs';
Expand Down
2 changes: 1 addition & 1 deletion packages/manual/is-core-module/index.js

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

8 changes: 4 additions & 4 deletions packages/manual/is-core-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
},
"license": "MIT",
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"ljharb-is-core-module": "npm:is-core-module@^2.15.0",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-replace": "^6.0.1",
"ljharb-is-core-module": "npm:is-core-module@^2.15.1",
"resolve-pkg": "^2.0.0"
},
"engines": {
Expand Down
23 changes: 12 additions & 11 deletions packages/tools/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nolyfill",
"version": "1.0.39",
"version": "1.0.41",
"homepage": "https://github.com/SukkaW/nolyfill",
"repository": "https://github.com/SukkaW/nolyfill",
"main": "./dist/index.js",
Expand All @@ -21,23 +21,24 @@
"@napi-rs/magic-string": "^0.3.4",
"@nolyfill/internal": "workspace:*",
"@nolyfill/promise.any": "workspace:*",
"@npmcli/arborist": "^6.3.0",
"@pnpm/list": "^10.1.2",
"@pnpm/list--old": "npm:@pnpm/list@^9.1.10",
"@pnpm/workspace.find-packages": "^2.0.5",
"@rollup/plugin-commonjs": "^26.0.1",
"@npmcli/arborist": "^6.5.1",
"@pnpm/list": "^10.2.1",
"@pnpm/list--old": "npm:@pnpm/list@^9.1.12",
"@pnpm/workspace.find-packages": "^2.1.1",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-node-resolve": "^15.3.0",
"@swc-node/register": "^1.10.9",
"@swc/helpers": "^0.5.12",
"@types/npmcli__arborist": "^5.6.1",
"@swc/helpers": "^0.5.13",
"@types/npmcli__arborist": "^5.6.11",
"@types/treeverse": "^3.0.5",
"@types/yarnpkg__lockfile": "^1.1.9",
"@yarnpkg/parsers": "3.0.0",
"@yarnpkg/parsers": "3.0.2",
"commander": "^11.1.0",
"detect-indent": "^6.1.0",
"fast-npm-meta": "^0.2.2",
"picocolors": "^1.0.1",
"package-manager-detector": "^0.2.2",
"picocolors": "^1.1.0",
"rollup-plugin-visualizer": "^5.12.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/cli/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import fs from 'fs';
import { builtinModules } from 'module';
import { MagicString } from '@napi-rs/magic-string';

import type { PackageJson } from 'type-fest';
import type { PackageJson } from '@package-json/types';

const builtinModulesSet = new Set(builtinModules);

Expand Down
9 changes: 5 additions & 4 deletions packages/tools/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import path from 'path';
import picocolors from 'picocolors';
import { Command, Option } from 'commander';
import handleError from './handle-error';
import { detectPackageManager, type PackageManager } from './package-manager';
import { renderTree } from './renderTree';

import { overridesPackageJson } from './lib/json';
Expand All @@ -11,6 +10,7 @@ import { handleSigTerm } from './lib/handle-sigterm';
import { findPackagesCoveredByNolyfill, findPackagesNotCoveredByNolyfill } from './find-coverable-packages';
import { checkForUpdates } from './check-update';
import { generateIssue } from './generate-issue';
import { detectPackageManager, type PackageManager } from './package-manager';

interface CliOptions {
/** see full error messages, mostly for debugging */
Expand All @@ -32,7 +32,7 @@ const pmCommandOption = new Option('--pm [package manager]', 'specify which pack

handleSigTerm();

// eslint-disable-next-line @typescript-eslint/no-var-requires -- version
// eslint-disable-next-line @typescript-eslint/no-require-imports -- TBD
const { version } = require('../package.json') as PKG;

const checkUnsupportedPM = (packageManager: PackageManager) => {
Expand Down Expand Up @@ -78,10 +78,10 @@ const program = new Command('nolyfill');
.addOption(pmCommandOption)
.addOption(new Option('-f --format [format]', 'output format for console')
.choices(['humanreadable', 'json'])
.default('humanreadable')
)
.default('humanreadable'))
.action(async (source: string | undefined, option: CheckCommandOptions) => {
const projectPath = path.resolve(source ?? process.cwd());
// TODO: use `package-manager-detector` agent option
const packageManager = option.pm === 'auto' ? await detectPackageManager(projectPath) : option.pm;
const format = option.format;

Expand Down Expand Up @@ -120,6 +120,7 @@ const program = new Command('nolyfill');
.addOption(pmCommandOption)
.action(async (source: string | undefined, option: PmCommandOptions) => {
const projectPath = path.resolve(source ?? process.cwd());
// TODO: use `package-manager-detector` agent option
const packageManager = option.pm === 'auto' ? await detectPackageManager(projectPath) : option.pm;

if (checkUnsupportedPM(packageManager)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
export { allPackages } from './all-packages';
export { findPackagesCoveredByNolyfill, findPackagesNotCoveredByNolyfill } from './find-coverable-packages';
export { overridesPackageJson } from './lib/json';
export { detectPackageManager, type PackageManager } from './package-manager';
export { type PackageManager } from './package-manager';
export * from './types';
10 changes: 5 additions & 5 deletions packages/tools/cli/src/lockfile/pnpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const buildPNPMDepTree = cache(async (dirPath: string): Promise<PackageNo
optionalDependencies: false
},
virtualStoreDirMaxLength: Infinity
})
});

const searchOld = () => searchForPackages_Old(['*'], dirPaths, {
depth: Infinity,
Expand All @@ -33,12 +33,12 @@ export const buildPNPMDepTree = cache(async (dirPath: string): Promise<PackageNo
dependencies: true,
devDependencies: true,
optionalDependencies: false
},
})
}
});

const lockfileVersion = await getPNPMLockfileVersion(dirPath)
const lockfileVersion = await getPNPMLockfileVersion(dirPath);

const result = await ((+lockfileVersion) < 6 ? searchOld() : searchNew())
const result = await ((+lockfileVersion) < 6 ? searchOld() : searchNew());

return result.flatMap((dep) => {
return [...(dep.dependencies ?? []), ...(dep.devDependencies ?? [])];
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/cli/src/lockfile/yarn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fsp from 'fs/promises';
import path from 'path';
import { parseSyml } from '@yarnpkg/parsers';
import { parseSyml } from '@yarnpkg/parsers/lib/syml';

import type { PackageNode } from '../types';
import { cache } from '../lib/cache';
Expand Down
34 changes: 7 additions & 27 deletions packages/tools/cli/src/package-manager.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
import path from 'path';
import fs, { type PathLike } from 'fs';
import fsp from 'fs/promises';

import { fileExists } from '@nolyfill/internal';

import PromiseAny from '@nolyfill/promise.any';
import { detect, type DetectResult } from 'package-manager-detector';

export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';

const checkFile = (path: PathLike) => fsp.access(path, fs.constants.F_OK);

export async function detectPackageManager(projectPath: string): Promise<PackageManager> {
const packageJsonPath = path.join(projectPath, 'package.json');

if (!await fileExists(packageJsonPath)) {
throw new Error(`Failed to locate package.json at ${projectPath}. Are you sure the path is correct?`);
}

try {
return await PromiseAny([
checkFile(path.join(projectPath, 'yarn.lock')).then<'yarn'>(() => 'yarn'),
checkFile(path.join(projectPath, 'pnpm-lock.yaml')).then<'pnpm'>(() => 'pnpm'),
checkFile(path.join(projectPath, 'package-lock.json')).then<'npm'>(() => 'npm'),
checkFile(path.join(projectPath, 'npm-shrinkwrap.json')).then<'npm'>(() => 'npm'),
checkFile(path.join(projectPath, 'bun.lockb')).then<'bun'>(() => 'bun')
]);
} catch (e) {
console.log(e);
throw new Error('Can not determine the preferred package manager.');
export function tramsformPackageManager(input: DetectResult | null): PackageManager {
if (input == null) {
throw new Error('Can not determine the preferred package manager');
}
return input.agent.split('@')[0] as PackageManager;
}

export const detectPackageManager = (cwd: string) => detect({ cwd }).then(tramsformPackageManager);
2 changes: 1 addition & 1 deletion packages/tools/cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PackageJson } from 'type-fest';
import type { PackageJson } from '@package-json/types';

export interface PackageNode {
name: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/internal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nolyfill/internal",
"version": "1.0.39",
"version": "1.0.41",
"private": true,
"main": "./index.js",
"types": "./index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nolyfill/shared",
"version": "1.0.39",
"version": "1.0.41",
"repository": {
"type": "git",
"url": "https://github.com/SukkaW/nolyfill",
Expand Down
Loading

0 comments on commit d135b75

Please sign in to comment.