Skip to content

Commit

Permalink
feat: rewrite for ESM
Browse files Browse the repository at this point in the history
BREAKING CHANGE: requires ESM, drop CJS support
  • Loading branch information
christophehurpeau committed Nov 27, 2022
1 parent fc63828 commit 464baa4
Show file tree
Hide file tree
Showing 63 changed files with 822 additions and 645 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"root": true,
"extends": ["@pob/eslint-config/root-commonjs"],
"extends": ["@pob/eslint-config/root-module"],
"ignorePatterns": ["/dist"]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ If something is missing for your need, please open an issue !
Create a script, for example `scripts/check-package.js`. Add it in `"scripts"` in your package.json. Run in CI and/or in your husky hooks.

```js
'use script';

const { createCheckPackage } = require('check-package-dependencies');
import { createCheckPackage } from 'check-package-dependencies';

await createCheckPackage(/* '.' */)
// Check that your package.json contains only exact versions of package, not range.
Expand Down
4 changes: 1 addition & 3 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module.exports = function babelConfig(api) {

return {
only: ['src'],
presets: [
[require.resolve('pob-babel/preset.cjs'), { modules: 'commonjs' }],
],
presets: [[require.resolve('pob-babel/preset.cjs')]],
};
};
10 changes: 4 additions & 6 deletions bin/check-package-dependencies.js → bin/check-package-dependencies.mjs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/usr/bin/env node

'use strict';

const {
import {
createCheckPackage,
createCheckPackageWithWorkspaces,
} = require('../dist/index-node14.cjs');
} from '../dist/index-node14.mjs';

const checkPackage = createCheckPackage();
if (checkPackage.pkg.workspaces) {
Expand All @@ -15,3 +11,5 @@ if (checkPackage.pkg.workspaces) {
} else {
checkPackage.checkRecommended();
}

await checkPackage.run();
2 changes: 1 addition & 1 deletion dist/check-package-with-workspaces.d.ts.map

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

2 changes: 1 addition & 1 deletion dist/check-package.d.ts.map

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

3 changes: 2 additions & 1 deletion dist/checks/checkDirectDuplicateDependencies.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { GetDependencyPackageJson } from 'utils/createGetDependencyPackageJson';
import { createReportError } from '../utils/createReportError';
import type { PackageJson, DependencyTypes } from '../utils/packageTypes';
import type { OnlyWarnsForMappingCheck } from '../utils/warnForUtils';
export declare function checkDirectDuplicateDependencies(pkg: PackageJson, pkgPathName: string, depType: DependencyTypes, getDependencyPackageJson: GetDependencyPackageJson, onlyWarnsForCheck: OnlyWarnsForMappingCheck, reportErrorNamePrefix?: string): void;
export declare function checkDirectDuplicateDependencies(pkg: PackageJson, pkgPathName: string, depType: DependencyTypes, getDependencyPackageJson: GetDependencyPackageJson, onlyWarnsForCheck: OnlyWarnsForMappingCheck, reportErrorNamePrefix?: string, customCreateReportError?: typeof createReportError): Promise<void>;
//# sourceMappingURL=checkDirectDuplicateDependencies.d.ts.map
2 changes: 1 addition & 1 deletion dist/checks/checkDirectDuplicateDependencies.d.ts.map

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

3 changes: 2 additions & 1 deletion dist/checks/checkDirectPeerDependencies.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { GetDependencyPackageJson } from 'utils/createGetDependencyPackageJson';
import { createReportError } from '../utils/createReportError';
import type { PackageJson } from '../utils/packageTypes';
import type { OnlyWarnsForMappingCheck } from '../utils/warnForUtils';
export declare function checkDirectPeerDependencies(isLibrary: boolean, pkg: PackageJson, pkgPathName: string, getDependencyPackageJson: GetDependencyPackageJson, missingOnlyWarnsForCheck: OnlyWarnsForMappingCheck, invalidOnlyWarnsForCheck: OnlyWarnsForMappingCheck): void;
export declare function checkDirectPeerDependencies(isLibrary: boolean, pkg: PackageJson, pkgPathName: string, getDependencyPackageJson: GetDependencyPackageJson, missingOnlyWarnsForCheck: OnlyWarnsForMappingCheck, invalidOnlyWarnsForCheck: OnlyWarnsForMappingCheck, customCreateReportError?: typeof createReportError): Promise<void>;
//# sourceMappingURL=checkDirectPeerDependencies.d.ts.map
2 changes: 1 addition & 1 deletion dist/checks/checkDirectPeerDependencies.d.ts.map

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

4 changes: 3 additions & 1 deletion dist/checks/checkExactVersions.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { GetDependencyPackageJson } from '../utils/createGetDependencyPackageJson';
import { createReportError } from '../utils/createReportError';
import type { PackageJson, DependencyTypes } from '../utils/packageTypes';
import type { OnlyWarnsFor, OnlyWarnsForCheck } from '../utils/warnForUtils';
export interface CheckExactVersionsOptions {
getDependencyPackageJson?: GetDependencyPackageJson;
onlyWarnsForCheck: OnlyWarnsForCheck;
internalExactVersionsIgnore?: OnlyWarnsFor;
tryToAutoFix?: boolean;
customCreateReportError?: typeof createReportError;
}
export declare function checkExactVersions(pkg: PackageJson, pkgPathName: string, types: DependencyTypes[], { getDependencyPackageJson, onlyWarnsForCheck, internalExactVersionsIgnore, tryToAutoFix, }: CheckExactVersionsOptions): void;
export declare function checkExactVersions(pkg: PackageJson, pkgPathName: string, types: DependencyTypes[], { getDependencyPackageJson, onlyWarnsForCheck, internalExactVersionsIgnore, tryToAutoFix, customCreateReportError, }: CheckExactVersionsOptions): Promise<void>;
//# sourceMappingURL=checkExactVersions.d.ts.map
2 changes: 1 addition & 1 deletion dist/checks/checkExactVersions.d.ts.map

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

3 changes: 2 additions & 1 deletion dist/checks/checkIdenticalVersions.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createReportError } from '../utils/createReportError';
import type { DependencyTypes, PackageJson } from '../utils/packageTypes';
import type { OnlyWarnsForCheck } from '../utils/warnForUtils';
export declare function checkIdenticalVersions(pkg: PackageJson, pkgPathName: string, type: DependencyTypes, deps: Record<string, string[] | Partial<Record<DependencyTypes, string[]>>>, onlyWarnsForCheck?: OnlyWarnsForCheck): void;
export declare function checkIdenticalVersions(pkg: PackageJson, pkgPathName: string, type: DependencyTypes, deps: Record<string, string[] | Partial<Record<DependencyTypes, string[]>>>, onlyWarnsForCheck?: OnlyWarnsForCheck, customCreateReportError?: typeof createReportError): void;
//# sourceMappingURL=checkIdenticalVersions.d.ts.map

0 comments on commit 464baa4

Please sign in to comment.