@servicetitan/startup 32.0.1 → 32.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/review/rules/index.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/index.js +10 -2
- package/dist/cli/commands/review/rules/index.js.map +1 -1
- package/dist/cli/commands/review/rules/no-deprecated-content-base.d.ts +13 -0
- package/dist/cli/commands/review/rules/no-deprecated-content-base.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js +71 -0
- package/dist/cli/commands/review/rules/no-deprecated-content-base.js.map +1 -0
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.d.ts +15 -0
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js +75 -0
- package/dist/cli/commands/review/rules/no-direct-peer-dependencies.js.map +1 -0
- package/dist/cli/commands/review/rules/no-typescript-entry-point.d.ts +2 -2
- package/dist/cli/commands/review/rules/no-typescript-entry-point.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js +58 -45
- package/dist/cli/commands/review/rules/no-typescript-entry-point.js.map +1 -1
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.d.ts +20 -0
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js +145 -0
- package/dist/cli/commands/review/rules/prefer-open-ended-peer-dependencies.js.map +1 -0
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.d.ts +22 -0
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js +189 -0
- package/dist/cli/commands/review/rules/require-compatible-launch-darkly-sdk.js.map +1 -0
- package/dist/cli/commands/review/rules/require-explicit-side-effects.d.ts +2 -1
- package/dist/cli/commands/review/rules/require-explicit-side-effects.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js +24 -11
- package/dist/cli/commands/review/rules/require-explicit-side-effects.js.map +1 -1
- package/dist/cli/commands/review/rules/require-one-collection-version.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/require-one-collection-version.js +1 -1
- package/dist/cli/commands/review/rules/require-one-collection-version.js.map +1 -1
- package/dist/cli/commands/review/rules/require-project-version-in-root-node-modules.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/require-project-version-in-root-node-modules.js +5 -7
- package/dist/cli/commands/review/rules/require-project-version-in-root-node-modules.js.map +1 -1
- package/dist/cli/commands/review/rules/require-servicetitan-scope.d.ts +2 -1
- package/dist/cli/commands/review/rules/require-servicetitan-scope.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js +24 -11
- package/dist/cli/commands/review/rules/require-servicetitan-scope.js.map +1 -1
- package/dist/cli/commands/review/types.d.ts +4 -1
- package/dist/cli/commands/review/types.d.ts.map +1 -1
- package/dist/cli/commands/review/types.js.map +1 -1
- package/dist/cli/commands/review/utils/check-packages.d.ts +7 -0
- package/dist/cli/commands/review/utils/check-packages.d.ts.map +1 -0
- package/dist/cli/commands/review/utils/check-packages.js +30 -0
- package/dist/cli/commands/review/utils/check-packages.js.map +1 -0
- package/dist/cli/commands/review/utils/index.d.ts +1 -0
- package/dist/cli/commands/review/utils/index.d.ts.map +1 -1
- package/dist/cli/commands/review/utils/index.js +1 -0
- package/dist/cli/commands/review/utils/index.js.map +1 -1
- package/dist/cli/utils/cli-git.d.ts.map +1 -1
- package/dist/cli/utils/cli-git.js +11 -8
- package/dist/cli/utils/cli-git.js.map +1 -1
- package/package.json +4 -4
- package/src/cli/commands/review/rules/__mocks__/mock-config.ts +8 -2
- package/src/cli/commands/review/rules/__tests__/no-deprecated-content-base.test.ts +123 -0
- package/src/cli/commands/review/rules/__tests__/no-direct-peer-dependencies.test.ts +130 -0
- package/src/cli/commands/review/rules/__tests__/prefer-open-ended-peer-dependencies.test.ts +121 -0
- package/src/cli/commands/review/rules/__tests__/require-compatible-launch-darkly-sdk.test.ts +256 -0
- package/src/cli/commands/review/rules/index.ts +10 -2
- package/src/cli/commands/review/rules/no-deprecated-content-base.ts +50 -0
- package/src/cli/commands/review/rules/no-direct-peer-dependencies.ts +58 -0
- package/src/cli/commands/review/rules/no-typescript-entry-point.ts +5 -8
- package/src/cli/commands/review/rules/prefer-open-ended-peer-dependencies.ts +89 -0
- package/src/cli/commands/review/rules/require-compatible-launch-darkly-sdk.ts +141 -0
- package/src/cli/commands/review/rules/require-explicit-side-effects.ts +14 -14
- package/src/cli/commands/review/rules/require-one-collection-version.ts +1 -3
- package/src/cli/commands/review/rules/require-project-version-in-root-node-modules.ts +5 -9
- package/src/cli/commands/review/rules/require-servicetitan-scope.ts +14 -14
- package/src/cli/commands/review/types.ts +16 -2
- package/src/cli/commands/review/utils/check-packages.ts +19 -0
- package/src/cli/commands/review/utils/index.ts +1 -0
- package/src/cli/utils/__tests__/cli-git.test.ts +20 -18
- package/src/cli/utils/cli-git.ts +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAgBvC,eAAO,MAAM,KAAK,EAAE,WAAW,EAe9B,CAAC"}
|
|
@@ -8,8 +8,12 @@ Object.defineProperty(exports, "rules", {
|
|
|
8
8
|
return rules;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _nodeprecatedcontentbase = require("./no-deprecated-content-base");
|
|
12
|
+
const _nodirectpeerdependencies = require("./no-direct-peer-dependencies");
|
|
11
13
|
const _notypescriptentrypoint = require("./no-typescript-entry-point");
|
|
14
|
+
const _preferopenendedpeerdependencies = require("./prefer-open-ended-peer-dependencies");
|
|
12
15
|
const _requireallreactdependencies = require("./require-all-react-dependencies");
|
|
16
|
+
const _requirecompatiblelaunchdarklysdk = require("./require-compatible-launch-darkly-sdk");
|
|
13
17
|
const _requireexplicitsideeffects = require("./require-explicit-side-effects");
|
|
14
18
|
const _requirenpmrc = require("./require-npmrc");
|
|
15
19
|
const _requireoneanviluikitcontribversion = require("./require-one-anvil-uikit-contrib-version");
|
|
@@ -19,13 +23,17 @@ const _requireoneuikitversion = require("./require-one-uikit-version");
|
|
|
19
23
|
const _requireprojectversioninrootnodemodules = require("./require-project-version-in-root-node-modules");
|
|
20
24
|
const _requireservicetitanscope = require("./require-servicetitan-scope");
|
|
21
25
|
const rules = [
|
|
22
|
-
new _requireonepackageversion.RequireOnePackageVersion(),
|
|
23
26
|
new _requireallreactdependencies.RequireAllReactDependencies(),
|
|
24
|
-
new _requireoneuikitversion.RequireOneUikitVersion(),
|
|
25
27
|
new _requireoneanviluikitcontribversion.RequireOneAnvilUikitContribVersion(),
|
|
28
|
+
new _requireonepackageversion.RequireOnePackageVersion(),
|
|
26
29
|
new _requireonereactversion.RequireOneReactVersion(),
|
|
30
|
+
new _requireoneuikitversion.RequireOneUikitVersion(),
|
|
27
31
|
new _requireprojectversioninrootnodemodules.RequireProjectVersionInRootNodeModules(),
|
|
32
|
+
new _requirecompatiblelaunchdarklysdk.RequireCompatibleLaunchDarklySdk(),
|
|
33
|
+
new _nodeprecatedcontentbase.NoDeprecatedContentBase(),
|
|
34
|
+
new _nodirectpeerdependencies.NoDirectPeerDependencies(),
|
|
28
35
|
new _notypescriptentrypoint.NoTypescriptEntryPoint(),
|
|
36
|
+
new _preferopenendedpeerdependencies.PreferOpenEndedPeerDependencies(),
|
|
29
37
|
new _requireservicetitanscope.RequireServiceTitanScope(),
|
|
30
38
|
new _requireexplicitsideeffects.RequireExplicitSideEffects(),
|
|
31
39
|
new _requirenpmrc.RequireNpmrc()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/index.ts"],"sourcesContent":["import { PackageRule } from '../types';\nimport { NoTypescriptEntryPoint } from './no-typescript-entry-point';\nimport { RequireAllReactDependencies } from './require-all-react-dependencies';\nimport { RequireExplicitSideEffects } from './require-explicit-side-effects';\nimport { RequireNpmrc } from './require-npmrc';\nimport { RequireOneAnvilUikitContribVersion } from './require-one-anvil-uikit-contrib-version';\nimport { RequireOnePackageVersion } from './require-one-package-version';\nimport { RequireOneReactVersion } from './require-one-react-version';\nimport { RequireOneUikitVersion } from './require-one-uikit-version';\nimport { RequireProjectVersionInRootNodeModules } from './require-project-version-in-root-node-modules';\nimport { RequireServiceTitanScope } from './require-servicetitan-scope';\n\nexport const rules: PackageRule[] = [\n new RequireOnePackageVersion(),\n new
|
|
1
|
+
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/index.ts"],"sourcesContent":["import { PackageRule } from '../types';\nimport { NoDeprecatedContentBase } from './no-deprecated-content-base';\nimport { NoDirectPeerDependencies } from './no-direct-peer-dependencies';\nimport { NoTypescriptEntryPoint } from './no-typescript-entry-point';\nimport { PreferOpenEndedPeerDependencies } from './prefer-open-ended-peer-dependencies';\nimport { RequireAllReactDependencies } from './require-all-react-dependencies';\nimport { RequireCompatibleLaunchDarklySdk } from './require-compatible-launch-darkly-sdk';\nimport { RequireExplicitSideEffects } from './require-explicit-side-effects';\nimport { RequireNpmrc } from './require-npmrc';\nimport { RequireOneAnvilUikitContribVersion } from './require-one-anvil-uikit-contrib-version';\nimport { RequireOnePackageVersion } from './require-one-package-version';\nimport { RequireOneReactVersion } from './require-one-react-version';\nimport { RequireOneUikitVersion } from './require-one-uikit-version';\nimport { RequireProjectVersionInRootNodeModules } from './require-project-version-in-root-node-modules';\nimport { RequireServiceTitanScope } from './require-servicetitan-scope';\n\nexport const rules: PackageRule[] = [\n new RequireAllReactDependencies(),\n new RequireOneAnvilUikitContribVersion(),\n new RequireOnePackageVersion(),\n new RequireOneReactVersion(),\n new RequireOneUikitVersion(),\n new RequireProjectVersionInRootNodeModules(),\n new RequireCompatibleLaunchDarklySdk(),\n new NoDeprecatedContentBase(),\n new NoDirectPeerDependencies(),\n new NoTypescriptEntryPoint(),\n new PreferOpenEndedPeerDependencies(),\n new RequireServiceTitanScope(),\n new RequireExplicitSideEffects(),\n new RequireNpmrc(),\n];\n"],"names":["rules","RequireAllReactDependencies","RequireOneAnvilUikitContribVersion","RequireOnePackageVersion","RequireOneReactVersion","RequireOneUikitVersion","RequireProjectVersionInRootNodeModules","RequireCompatibleLaunchDarklySdk","NoDeprecatedContentBase","NoDirectPeerDependencies","NoTypescriptEntryPoint","PreferOpenEndedPeerDependencies","RequireServiceTitanScope","RequireExplicitSideEffects","RequireNpmrc"],"mappings":";;;;+BAgBaA;;;eAAAA;;;yCAf2B;0CACC;wCACF;iDACS;6CACJ;kDACK;4CACN;8BACd;oDACsB;0CACV;wCACF;wCACA;wDACgB;0CACd;AAElC,MAAMA,QAAuB;IAChC,IAAIC,wDAA2B;IAC/B,IAAIC,sEAAkC;IACtC,IAAIC,kDAAwB;IAC5B,IAAIC,8CAAsB;IAC1B,IAAIC,8CAAsB;IAC1B,IAAIC,8EAAsC;IAC1C,IAAIC,kEAAgC;IACpC,IAAIC,gDAAuB;IAC3B,IAAIC,kDAAwB;IAC5B,IAAIC,8CAAsB;IAC1B,IAAIC,gEAA+B;IACnC,IAAIC,kDAAwB;IAC5B,IAAIC,sDAA0B;IAC9B,IAAIC,0BAAY;CACnB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PackageError, PackageRule, Project } from '../types';
|
|
2
|
+
interface ErrorData {
|
|
3
|
+
contentBase: string;
|
|
4
|
+
}
|
|
5
|
+
type RuleError = PackageError<ErrorData>;
|
|
6
|
+
export declare class NoDeprecatedContentBase implements PackageRule {
|
|
7
|
+
get id(): string;
|
|
8
|
+
run(project: Project): RuleError[] | undefined;
|
|
9
|
+
fix({ data, location }: RuleError): void;
|
|
10
|
+
private readonly checkPackage;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=no-deprecated-content-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-deprecated-content-base.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/no-deprecated-content-base.ts"],"names":[],"mappings":"AACA,OAAO,EAAuC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnG,UAAU,SAAS;IACf,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,KAAK,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;AAEzC,qBAAa,uBAAwB,YAAW,WAAW;IACvD,IAAI,EAAE,WAEL;IAED,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,SAAS;IAI9C,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,SAAS;IAiBjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAY3B;CACL"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "NoDeprecatedContentBase", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return NoDeprecatedContentBase;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _child_process = require("child_process");
|
|
12
|
+
const _types = require("../types");
|
|
13
|
+
const _utils = require("../utils");
|
|
14
|
+
function _define_property(obj, key, value) {
|
|
15
|
+
if (key in obj) {
|
|
16
|
+
Object.defineProperty(obj, key, {
|
|
17
|
+
value: value,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
obj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
class NoDeprecatedContentBase {
|
|
28
|
+
get id() {
|
|
29
|
+
return 'no-deprecated-content-base';
|
|
30
|
+
}
|
|
31
|
+
run(project) {
|
|
32
|
+
return (0, _utils.checkPackages)(this, project, this.checkPackage);
|
|
33
|
+
}
|
|
34
|
+
fix({ data, location }) {
|
|
35
|
+
const { contentBase } = data !== null && data !== void 0 ? data : {};
|
|
36
|
+
if (!location || contentBase === undefined) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const setCommands = Array.isArray(contentBase) ? contentBase.map((directory, index)=>{
|
|
40
|
+
return `npm pkg set cli.webpack.static[${index}].directory="${directory}" -w ${location}`;
|
|
41
|
+
}) : [
|
|
42
|
+
`npm pkg set cli.webpack.static.directory="${contentBase}" -w ${location}`
|
|
43
|
+
];
|
|
44
|
+
[
|
|
45
|
+
...setCommands,
|
|
46
|
+
`npm pkg delete cli.webpack.contentBase -w ${location}`
|
|
47
|
+
].forEach((command)=>(0, _child_process.execSync)(command, {
|
|
48
|
+
stdio: 'inherit'
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
constructor(){
|
|
52
|
+
_define_property(this, "checkPackage", (pkg)=>{
|
|
53
|
+
var _pkg_cli;
|
|
54
|
+
const { webpack = {} } = (_pkg_cli = pkg.cli) !== null && _pkg_cli !== void 0 ? _pkg_cli : {};
|
|
55
|
+
if (webpack && typeof webpack === 'object' && Object.hasOwn(webpack, 'contentBase')) {
|
|
56
|
+
return {
|
|
57
|
+
id: this.id,
|
|
58
|
+
message: `package "${pkg.name}" uses deprecated cli.webpack.contentBase configuration`,
|
|
59
|
+
location: pkg.location,
|
|
60
|
+
fixable: _types.FixCategory.isolated,
|
|
61
|
+
severity: _types.ErrorSeverity.warning,
|
|
62
|
+
data: {
|
|
63
|
+
contentBase: webpack.contentBase
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=no-deprecated-content-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/no-deprecated-content-base.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { ErrorSeverity, FixCategory, Package, PackageError, PackageRule, Project } from '../types';\nimport { checkPackages } from '../utils';\n\ninterface ErrorData {\n contentBase: string;\n}\n\ntype RuleError = PackageError<ErrorData>;\n\nexport class NoDeprecatedContentBase implements PackageRule {\n get id() {\n return 'no-deprecated-content-base';\n }\n\n run(project: Project): RuleError[] | undefined {\n return checkPackages(this, project, this.checkPackage);\n }\n\n fix({ data, location }: RuleError) {\n const { contentBase } = data ?? {};\n if (!location || contentBase === undefined) {\n return;\n }\n\n const setCommands = Array.isArray(contentBase)\n ? contentBase.map((directory, index) => {\n return `npm pkg set cli.webpack.static[${index}].directory=\"${directory}\" -w ${location}`;\n })\n : [`npm pkg set cli.webpack.static.directory=\"${contentBase}\" -w ${location}`];\n\n [...setCommands, `npm pkg delete cli.webpack.contentBase -w ${location}`].forEach(command =>\n execSync(command, { stdio: 'inherit' })\n );\n }\n\n private readonly checkPackage = (pkg: Package): RuleError | undefined => {\n const { webpack = {} } = pkg.cli ?? {};\n if (webpack && typeof webpack === 'object' && Object.hasOwn(webpack, 'contentBase')) {\n return {\n id: this.id,\n message: `package \"${pkg.name}\" uses deprecated cli.webpack.contentBase configuration`,\n location: pkg.location,\n fixable: FixCategory.isolated,\n severity: ErrorSeverity.warning,\n data: { contentBase: webpack.contentBase },\n };\n }\n };\n}\n"],"names":["NoDeprecatedContentBase","id","run","project","checkPackages","checkPackage","fix","data","location","contentBase","undefined","setCommands","Array","isArray","map","directory","index","forEach","command","execSync","stdio","pkg","webpack","cli","Object","hasOwn","message","name","fixable","FixC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O;oBAC/B1B,MAAM;wBAAEE,aAAaa,QAAQb,WAAW;oBAAC;gBAC7C;YACJ;QACJ;;AACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PackageError, PackageRule, Project } from '../types';
|
|
2
|
+
interface ErrorData {
|
|
3
|
+
dependencies: Record<string, string>;
|
|
4
|
+
directPeerDependencies: string[];
|
|
5
|
+
}
|
|
6
|
+
type RuleError = PackageError<ErrorData>;
|
|
7
|
+
export declare class NoDirectPeerDependencies implements PackageRule {
|
|
8
|
+
get id(): string;
|
|
9
|
+
run(project: Project): RuleError[] | undefined;
|
|
10
|
+
fix({ data, location }: RuleError): void;
|
|
11
|
+
private readonly checkPackage;
|
|
12
|
+
private formatMessage;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=no-direct-peer-dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-direct-peer-dependencies.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/no-direct-peer-dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGpF,UAAU,SAAS;IACf,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,sBAAsB,EAAE,MAAM,EAAE,CAAC;CACpC;AAED,KAAK,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;AAEzC,qBAAa,wBAAyB,YAAW,WAAW;IACxD,IAAI,EAAE,WAEL;IAED,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,SAAS;IAI9C,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,SAAS;IAcjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAc3B;IAEF,OAAO,CAAC,aAAa;CAOxB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "NoDirectPeerDependencies", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return NoDirectPeerDependencies;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _child_process = require("child_process");
|
|
12
|
+
const _types = require("../types");
|
|
13
|
+
const _utils = require("../utils");
|
|
14
|
+
function _define_property(obj, key, value) {
|
|
15
|
+
if (key in obj) {
|
|
16
|
+
Object.defineProperty(obj, key, {
|
|
17
|
+
value: value,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
obj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
class NoDirectPeerDependencies {
|
|
28
|
+
get id() {
|
|
29
|
+
return 'no-direct-peer-dependencies';
|
|
30
|
+
}
|
|
31
|
+
run(project) {
|
|
32
|
+
return (0, _utils.checkPackages)(this, project, this.checkPackage);
|
|
33
|
+
}
|
|
34
|
+
fix({ data, location }) {
|
|
35
|
+
const { dependencies, directPeerDependencies } = data !== null && data !== void 0 ? data : {};
|
|
36
|
+
if (!(location && dependencies && directPeerDependencies)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
directPeerDependencies.forEach((name)=>{
|
|
40
|
+
[
|
|
41
|
+
`npm pkg set devDependencies["${name}"]="${dependencies[name]}" -w ${location}`,
|
|
42
|
+
`npm pkg delete dependencies["${name}"] -w ${location}`
|
|
43
|
+
].forEach((command)=>(0, _child_process.execSync)(command, {
|
|
44
|
+
stdio: 'inherit'
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
formatMessage(name, dependencies) {
|
|
49
|
+
if (dependencies.length === 1) {
|
|
50
|
+
return `package "${name}" lists "${dependencies[0]}" as both a direct and a peer dependency`;
|
|
51
|
+
}
|
|
52
|
+
const list = (0, _utils.formatList)(dependencies.map((name)=>`"${name}"`));
|
|
53
|
+
return `package "${name}" lists ${list} as both direct and peer dependencies`;
|
|
54
|
+
}
|
|
55
|
+
constructor(){
|
|
56
|
+
_define_property(this, "checkPackage", (pkg)=>{
|
|
57
|
+
const { dependencies = {}, peerDependencies = {} } = pkg;
|
|
58
|
+
const directPeerDependencies = Object.keys(peerDependencies).filter((peerDependency)=>!!dependencies[peerDependency]);
|
|
59
|
+
if (directPeerDependencies.length) {
|
|
60
|
+
return {
|
|
61
|
+
id: this.id,
|
|
62
|
+
message: this.formatMessage(pkg.name, directPeerDependencies),
|
|
63
|
+
location: pkg.location,
|
|
64
|
+
fixable: _types.FixCategory.isolated,
|
|
65
|
+
data: {
|
|
66
|
+
dependencies,
|
|
67
|
+
directPeerDependencies
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=no-direct-peer-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/no-direct-peer-dependencies.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { FixCategory, Package, PackageError, PackageRule, Project } from '../types';\nimport { checkPackages, formatList } from '../utils';\n\ninterface ErrorData {\n dependencies: Record<string, string>;\n directPeerDependencies: string[];\n}\n\ntype RuleError = PackageError<ErrorData>;\n\nexport class NoDirectPeerDependencies implements PackageRule {\n get id() {\n return 'no-direct-peer-dependencies';\n }\n\n run(project: Project): RuleError[] | undefined {\n return checkPackages(this, project, this.checkPackage);\n }\n\n fix({ data, location }: RuleError) {\n const { dependencies, directPeerDependencies } = data ?? {};\n if (!(location && dependencies && directPeerDependencies)) {\n return;\n }\n\n directPeerDependencies.forEach(name => {\n [\n `npm pkg set devDependencies[\"${name}\"]=\"${dependencies[name]}\" -w ${location}`,\n `npm pkg delete dependencies[\"${name}\"] -w ${location}`,\n ].forEach(command => execSync(command, { stdio: 'inherit' }));\n });\n }\n\n private readonly checkPackage = (pkg: Package): RuleError | undefined => {\n const { dependencies = {}, peerDependencies = {} } = pkg;\n const directPeerDependencies = Object.keys(peerDependencies).filter(\n peerDependency => !!dependencies[peerDependency]\n );\n if (directPeerDependencies.length) {\n return {\n id: this.id,\n message: this.formatMessage(pkg.name, directPeerDependencies),\n location: pkg.location,\n fixable: FixCategory.isolated,\n data: { dependencies, directPeerDependencies },\n };\n }\n };\n\n private formatMessage(name: string, dependencies: string[]) {\n if (dependencies.length === 1) {\n return `package \"${name}\" lists \"${dependencies[0]}\" as both a direct and a peer dependency`;\n }\n const list = formatList(dependencies.map(name => `\"${name}\"`));\n return `package \"${name}\" lists ${list} as both direct and peer dependencies`;\n }\n}\n"],"names":["NoDirectPeerDependencies","id","run","project","checkPackages","checkPackage","fix","data","location","dependencies","directPeerDependencies","forEach","name","command","execSync","stdio","formatMessage","length","list","formatList","map","pkg","peerDependencies","Object","keys","filter","peerDependency","message","fixable","FixCategory","isolated"],"mappings":";;;;+BAWaA;;;eAAAA;;;+BAXY;uBACgD;uBAC/B;;;;;;;;;;;;;;AASnC,MAAMA;IACT,IAAIC,KAAK;QACL,OAAO;IACX;IAEAC,IAAIC,OAAgB,EAA2B;QAC3C,OAAOC,IAAAA,oBAAa,EAAC,IAAI,EAAED,SAAS,IAAI,CAACE,YAAY;IACzD;IAEAC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAa,EAAE;QAC/B,MAAM,EAAEC,YAAY,EAAEC,sBAAsB,EAAE,GAAGH,iBAAAA,kBAAAA,OAAQ,CAAC;QAC1D,IAAI,CAAEC,CAAAA,YAAYC,gBAAgBC,sBAAqB,GAAI;YACvD;QACJ;QAEAA,uBAAuBC,OAAO,CAACC,CAAAA;YAC3B;gBACI,CAAC,6BAA6B,EAAEA,KAAK,IAAI,EAAE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project): PackageError<ErrorData>[];
|
|
9
9
|
fix({ data, location }: PackageError<ErrorData>): void;
|
|
10
|
-
private checkEntryPoints;
|
|
10
|
+
private readonly checkEntryPoints;
|
|
11
11
|
private isTypescriptEntryPoint;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-typescript-entry-point.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/no-typescript-entry-point.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGpF,UAAU,SAAS;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,sBAAuB,YAAW,WAAW;IACtD,IAAI,EAAE,WAEL;IAED,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"no-typescript-entry-point.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/no-typescript-entry-point.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGpF,UAAU,SAAS;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,sBAAuB,YAAW,WAAW;IACtD,IAAI,EAAE,WAEL;IAED,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,EAAE;IAIhD,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,YAAY,CAAC,SAAS,CAAC;IAc/C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAmC/B;IAEF,OAAO,CAAC,sBAAsB;CAGjC"}
|
|
@@ -13,6 +13,19 @@ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
|
13
13
|
const _utils = require("../../../../utils");
|
|
14
14
|
const _types = require("../types");
|
|
15
15
|
const _utils1 = require("../utils");
|
|
16
|
+
function _define_property(obj, key, value) {
|
|
17
|
+
if (key in obj) {
|
|
18
|
+
Object.defineProperty(obj, key, {
|
|
19
|
+
value: value,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
obj[key] = value;
|
|
26
|
+
}
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
16
29
|
function _interop_require_default(obj) {
|
|
17
30
|
return obj && obj.__esModule ? obj : {
|
|
18
31
|
default: obj
|
|
@@ -22,10 +35,8 @@ class NoTypescriptEntryPoint {
|
|
|
22
35
|
get id() {
|
|
23
36
|
return 'no-typescript-entry-point';
|
|
24
37
|
}
|
|
25
|
-
run(
|
|
26
|
-
|
|
27
|
-
const ruleConfig = (_config_rules = config.rules) === null || _config_rules === void 0 ? void 0 : _config_rules[this.id];
|
|
28
|
-
return (0, _utils1.applyFilter)(ruleConfig, packages, ({ name })=>name).flatMap((pkg)=>this.checkEntryPoints(pkg));
|
|
38
|
+
run(project) {
|
|
39
|
+
return (0, _utils1.checkPackages)(this, project, this.checkEntryPoints);
|
|
29
40
|
}
|
|
30
41
|
fix({ data, location }) {
|
|
31
42
|
const { key, value } = data !== null && data !== void 0 ? data : {};
|
|
@@ -39,50 +50,52 @@ class NoTypescriptEntryPoint {
|
|
|
39
50
|
_utils.log.debug(`review:${this.id}`, `Running ${command}`);
|
|
40
51
|
(0, _child_process.execSync)(command);
|
|
41
52
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
'exports'
|
|
55
|
-
].forEach((key)=>{
|
|
56
|
-
const value = pkg[key];
|
|
57
|
-
if (typeof value === 'string' && this.isTypescriptEntryPoint(value)) {
|
|
58
|
-
addError(`"${key}" is Typescript: ${value}`, {
|
|
59
|
-
key,
|
|
60
|
-
value
|
|
53
|
+
isTypescriptEntryPoint(str) {
|
|
54
|
+
return str.endsWith('.ts') && !str.endsWith('.d.ts');
|
|
55
|
+
}
|
|
56
|
+
constructor(){
|
|
57
|
+
_define_property(this, "checkEntryPoints", (pkg)=>{
|
|
58
|
+
const errors = [];
|
|
59
|
+
const addError = (message, data)=>errors.push({
|
|
60
|
+
id: this.id,
|
|
61
|
+
message,
|
|
62
|
+
location: pkg.location,
|
|
63
|
+
fixable: _types.FixCategory.normal,
|
|
64
|
+
data
|
|
61
65
|
});
|
|
66
|
+
[
|
|
67
|
+
'main',
|
|
68
|
+
'module',
|
|
69
|
+
'exports'
|
|
70
|
+
].forEach((key)=>{
|
|
71
|
+
const value = pkg[key];
|
|
72
|
+
if (typeof value === 'string' && this.isTypescriptEntryPoint(value)) {
|
|
73
|
+
addError(`"${key}" is Typescript: ${value}`, {
|
|
74
|
+
key,
|
|
75
|
+
value
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
if (pkg.exports && typeof pkg.exports !== 'string') {
|
|
80
|
+
const checkExports = (exports1, prefix)=>{
|
|
81
|
+
Object.entries(exports1).forEach(([key, value])=>{
|
|
82
|
+
const path = `${prefix}[${key}]`;
|
|
83
|
+
if (typeof value === 'string') {
|
|
84
|
+
if (this.isTypescriptEntryPoint(value)) {
|
|
85
|
+
addError(`"${path}" is Typescript: ${value}`, {
|
|
86
|
+
key: path,
|
|
87
|
+
value
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
} else if (exports1) {
|
|
91
|
+
checkExports(value, path);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
checkExports(pkg.exports, 'exports');
|
|
62
96
|
}
|
|
97
|
+
return errors;
|
|
63
98
|
});
|
|
64
|
-
if (pkg.exports && typeof pkg.exports !== 'string') {
|
|
65
|
-
const checkExports = (exports1, prefix)=>{
|
|
66
|
-
Object.entries(exports1).forEach(([key, value])=>{
|
|
67
|
-
const path = `${prefix}[${key}]`;
|
|
68
|
-
if (typeof value === 'string') {
|
|
69
|
-
if (this.isTypescriptEntryPoint(value)) {
|
|
70
|
-
addError(`"${path}" is Typescript: ${value}`, {
|
|
71
|
-
key: path,
|
|
72
|
-
value
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
} else if (exports1) {
|
|
76
|
-
checkExports(value, path);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
checkExports(pkg.exports, 'exports');
|
|
81
|
-
}
|
|
82
|
-
return errors;
|
|
83
|
-
}
|
|
84
|
-
isTypescriptEntryPoint(str) {
|
|
85
|
-
return str.endsWith('.ts') && !str.endsWith('.d.ts');
|
|
86
99
|
}
|
|
87
100
|
}
|
|
88
101
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/no-typescript-entry-point.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport path from 'path';\nimport { getFolders, log } from '../../../../utils';\nimport { FixCategory, Package, PackageError, PackageRule, Project } from '../types';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/no-typescript-entry-point.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport path from 'path';\nimport { getFolders, log } from '../../../../utils';\nimport { FixCategory, Package, PackageError, PackageRule, Project } from '../types';\nimport { checkPackages } from '../utils';\n\ninterface ErrorData {\n key: string;\n value: string;\n}\n\nexport class NoTypescriptEntryPoint implements PackageRule {\n get id() {\n return 'no-typescript-entry-point';\n }\n\n run(project: Project): PackageError<ErrorData>[] {\n return checkPackages(this, project, this.checkEntryPoints);\n }\n\n fix({ data, location }: PackageError<ErrorData>) {\n const { key, value } = data ?? {};\n if (!(key && value && location)) {\n return;\n }\n\n const workspace = path.relative('.', location);\n const { source, destination } = getFolders(location);\n const newValue = value.replace(source, destination).replace(/\\.ts$/, '.js');\n const command = `npm pkg set \"${key}\"=\"${newValue}\" -w ${workspace}`;\n log.debug(`review:${this.id}`, `Running ${command}`);\n execSync(command);\n }\n\n private readonly checkEntryPoints = (pkg: Package) => {\n const errors: PackageError<ErrorData>[] = [];\n const addError = (message: string, data: ErrorData) =>\n errors.push({\n id: this.id,\n message,\n location: pkg.location,\n fixable: FixCategory.normal,\n data,\n });\n\n (['main', 'module', 'exports'] as (keyof Package)[]).forEach(key => {\n const value = pkg[key];\n if (typeof value === 'string' && this.isTypescriptEntryPoint(value)) {\n addError(`\"${key}\" is Typescript: ${value}`, { key, value });\n }\n });\n\n if (pkg.exports && typeof pkg.exports !== 'string') {\n const checkExports = (exports: NonNullable<Package['exports']>, prefix: string) => {\n Object.entries(exports).forEach(([key, value]) => {\n const path = `${prefix}[${key}]`;\n if (typeof value === 'string') {\n if (this.isTypescriptEntryPoint(value)) {\n addError(`\"${path}\" is Typescript: ${value}`, { key: path, value });\n }\n } else if (exports) {\n checkExports(value, path);\n }\n });\n };\n checkExports(pkg.exports, 'exports');\n }\n\n return errors;\n };\n\n private isTypescriptEntryPoint(str: string) {\n return str.endsWith('.ts') && !str.endsWith('.d.ts');\n }\n}\n"],"names":["NoTypescriptEntryPoint","id","run","project","checkPackages","checkEntryPoints","fix","data","location","key","value","workspace","path","relative","source","destination","getFolders","newValue","replace","command","log","debug","execSync","isTypescriptEntryPoint","str","endsWith","pkg","errors","addError","message","push","fixable","FixCategory","normal","forEach","exports","checkExports","prefix","Object","entries"],"mappings":";;;;+BAWaA;;;eAAAA;;;+BAXY;6DACR;uBACe;uBACyC;wBAC3C;;;;;;;;;;;;;;;;;;;AAOvB,MAAMA;IACT,IAAIC,KAAK;QACL,OAAO;IACX;IAEAC,IAAIC,OAAgB,EAA6B;QAC7C,OAAOC,IAAAA,qBAAa,EAAC,IAAI,EAAED,SAAS,IAAI,CAACE,gBAAgB;IAC7D;IAEAC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAA2B,EAAE;QAC7C,MAAM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AOT,IAAIS,OAAO,KAAK,UAAU;gBAChD,MAAMC,eAAe,CAACD,UAA0CE;oBAC5DC,OAAOC,OAAO,CAACJ,UAASD,OAAO,CAAC,CAAC,CAACzB,KAAKC,MAAM;wBACzC,MAAME,OAAO,GAAGyB,OAAO,CAAC,EAAE5B,IAAI,CAAC,CAAC;wBAChC,IAAI,OAAOC,UAAU,UAAU;4BAC3B,IAAI,IAAI,CAACa,sBAAsB,CAACb,QAAQ;gCACpCkB,SAAS,CAAC,CAAC,EAAEhB,KAAK,iBAAiB,EAAEF,OAAO,EAAE;oCAAED,KAAKG;oCAAMF;gCAAM;4BACrE;wBACJ,OAAO,IAAIyB,UAAS;4BAChBC,aAAa1B,OAAOE;wBACxB;oBACJ;gBACJ;gBACAwB,aAAaV,IAAIS,OAAO,EAAE;YAC9B;YAEA,OAAOR;QACX;;AAKJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PackageError, PackageRule, Project } from '../types';
|
|
2
|
+
interface ErrorData {
|
|
3
|
+
dependency: string;
|
|
4
|
+
version: string;
|
|
5
|
+
}
|
|
6
|
+
type RuleError = PackageError<ErrorData>;
|
|
7
|
+
export declare class PreferOpenEndedPeerDependencies implements PackageRule {
|
|
8
|
+
#private;
|
|
9
|
+
get id(): string;
|
|
10
|
+
run(project: Project): RuleError[] | undefined;
|
|
11
|
+
fix({ data, location }: RuleError): void;
|
|
12
|
+
private readonly checkPackage;
|
|
13
|
+
private isExactVersion;
|
|
14
|
+
private isExcluded;
|
|
15
|
+
private isOpenEndedVersion;
|
|
16
|
+
private isFixable;
|
|
17
|
+
private isViolation;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=prefer-open-ended-peer-dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-open-ended-peer-dependencies.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/review/rules/prefer-open-ended-peer-dependencies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnG,UAAU,SAAS;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,KAAK,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;AAEzC,qBAAa,+BAAgC,YAAW,WAAW;;IAG/D,IAAI,EAAE,WAEL;IAED,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,SAAS;IAK9C,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,SAAS;IAWjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAkB3B;IAEF,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;CAUtB"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "PreferOpenEndedPeerDependencies", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return PreferOpenEndedPeerDependencies;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _child_process = require("child_process");
|
|
12
|
+
const _semver = require("semver");
|
|
13
|
+
const _types = require("../types");
|
|
14
|
+
const _utils = require("../utils");
|
|
15
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
16
|
+
if (privateCollection.has(obj)) {
|
|
17
|
+
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
21
|
+
if (descriptor.get) {
|
|
22
|
+
return descriptor.get.call(receiver);
|
|
23
|
+
}
|
|
24
|
+
return descriptor.value;
|
|
25
|
+
}
|
|
26
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
27
|
+
if (descriptor.set) {
|
|
28
|
+
descriptor.set.call(receiver, value);
|
|
29
|
+
} else {
|
|
30
|
+
if (!descriptor.writable) {
|
|
31
|
+
throw new TypeError("attempted to set read only private field");
|
|
32
|
+
}
|
|
33
|
+
descriptor.value = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
37
|
+
if (!privateMap.has(receiver)) {
|
|
38
|
+
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
39
|
+
}
|
|
40
|
+
return privateMap.get(receiver);
|
|
41
|
+
}
|
|
42
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
43
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
44
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
45
|
+
}
|
|
46
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
47
|
+
_check_private_redeclaration(obj, privateMap);
|
|
48
|
+
privateMap.set(obj, value);
|
|
49
|
+
}
|
|
50
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
51
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
52
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
function _define_property(obj, key, value) {
|
|
56
|
+
if (key in obj) {
|
|
57
|
+
Object.defineProperty(obj, key, {
|
|
58
|
+
value: value,
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
obj[key] = value;
|
|
65
|
+
}
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
var _project = /*#__PURE__*/ new WeakMap();
|
|
69
|
+
class PreferOpenEndedPeerDependencies {
|
|
70
|
+
get id() {
|
|
71
|
+
return 'prefer-open-ended-peer-dependencies';
|
|
72
|
+
}
|
|
73
|
+
run(project) {
|
|
74
|
+
_class_private_field_set(this, _project, project);
|
|
75
|
+
return (0, _utils.checkPackages)(this, project, this.checkPackage);
|
|
76
|
+
}
|
|
77
|
+
fix({ data, location }) {
|
|
78
|
+
const { dependency, version } = data !== null && data !== void 0 ? data : {};
|
|
79
|
+
if (!(location && dependency && version)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const openEndedVersion = version.replace(/^[\^~]/, '>=');
|
|
83
|
+
const command = `npm pkg set peerDependencies["${dependency}"]="${openEndedVersion}" -w ${location}`;
|
|
84
|
+
(0, _child_process.execSync)(command, {
|
|
85
|
+
stdio: 'inherit'
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
isExactVersion(version) {
|
|
89
|
+
return /^\d/.test(version);
|
|
90
|
+
}
|
|
91
|
+
isExcluded({ name }, dependency) {
|
|
92
|
+
var _class_private_field_get_config_rules;
|
|
93
|
+
const ruleConfig = (_class_private_field_get_config_rules = _class_private_field_get(this, _project).config.rules) === null || _class_private_field_get_config_rules === void 0 ? void 0 : _class_private_field_get_config_rules[this.id];
|
|
94
|
+
if (Array.isArray(ruleConfig)) {
|
|
95
|
+
var _ruleConfig_;
|
|
96
|
+
const { exclude } = (_ruleConfig_ = ruleConfig[1]) !== null && _ruleConfig_ !== void 0 ? _ruleConfig_ : {};
|
|
97
|
+
if (typeof exclude === 'object' && !Array.isArray(exclude)) {
|
|
98
|
+
var _exclude_name;
|
|
99
|
+
return (_exclude_name = exclude[name]) === null || _exclude_name === void 0 ? void 0 : _exclude_name.includes(dependency);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
isOpenEndedVersion(version) {
|
|
105
|
+
return (0, _semver.satisfies)('999.999.999', version);
|
|
106
|
+
}
|
|
107
|
+
isFixable(version) {
|
|
108
|
+
return /^[\^~]\d+(\.\d+){0,2}$/.test(version);
|
|
109
|
+
}
|
|
110
|
+
isViolation(pkg, { dependency, version }) {
|
|
111
|
+
return !this.isExactVersion(version) && !this.isOpenEndedVersion(version) && !this.isExcluded(pkg, dependency);
|
|
112
|
+
}
|
|
113
|
+
constructor(){
|
|
114
|
+
_class_private_field_init(this, _project, {
|
|
115
|
+
writable: true,
|
|
116
|
+
value: void 0
|
|
117
|
+
});
|
|
118
|
+
_define_property(this, "checkPackage", (pkg)=>{
|
|
119
|
+
var _pkg_peerDependencies;
|
|
120
|
+
return Object.entries((_pkg_peerDependencies = pkg.peerDependencies) !== null && _pkg_peerDependencies !== void 0 ? _pkg_peerDependencies : {}).reduce((result, [dependency, version])=>{
|
|
121
|
+
if (this.isViolation(pkg, {
|
|
122
|
+
dependency,
|
|
123
|
+
version
|
|
124
|
+
})) {
|
|
125
|
+
result.push({
|
|
126
|
+
id: this.id,
|
|
127
|
+
message: `package "${pkg.name}" has closed-ended peer dependency on "${dependency}@${version}"`,
|
|
128
|
+
location: pkg.location,
|
|
129
|
+
severity: _types.ErrorSeverity.warning,
|
|
130
|
+
...this.isFixable(version) ? {
|
|
131
|
+
fixable: _types.FixCategory.isolated,
|
|
132
|
+
data: {
|
|
133
|
+
dependency,
|
|
134
|
+
version
|
|
135
|
+
}
|
|
136
|
+
} : {}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}, []);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=prefer-open-ended-peer-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/cli/commands/review/rules/prefer-open-ended-peer-dependencies.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport { satisfies } from 'semver';\nimport { ErrorSeverity, FixCategory, Package, PackageError, PackageRule, Project } from '../types';\nimport { checkPackages } from '../utils';\n\ninterface ErrorData {\n dependency: string;\n version: string;\n}\n\ntype RuleError = PackageError<ErrorData>;\n\nexport class PreferOpenEndedPeerDependencies implements PackageRule {\n #project!: Project;\n\n get id() {\n return 'prefer-open-ended-peer-dependencies';\n }\n\n run(project: Project): RuleError[] | undefined {\n this.#project = project;\n return checkPackages(this, project, this.checkPackage);\n }\n\n fix({ data, location }: RuleError) {\n const { dependency, version } = data ?? {};\n if (!(location && dependency && version)) {\n return;\n }\n\n const openEndedVersion = version.replace(/^[\\^~]/, '>=');\n const command = `npm pkg set peerDependencies[\"${dependency}\"]=\"${openEndedVersion}\" -w ${location}`;\n execSync(command, { stdio: 'inherit' });\n }\n\n private readonly checkPackage = (pkg: Package): RuleError[] | undefined => {\n return Object.entries(pkg.peerDependencies ?? {}).reduce<RuleError[]>(\n (result, [dependency, version]) => {\n if (this.isViolation(pkg, { dependency, version })) {\n result.push({\n id: this.id,\n message: `package \"${pkg.name}\" has closed-ended peer dependency on \"${dependency}@${version}\"`,\n location: pkg.location,\n severity: ErrorSeverity.warning,\n ...(this.isFixable(version)\n ? { fixable: FixCategory.isolated, data: { dependency, version } }\n : {}),\n });\n }\n return result;\n },\n []\n );\n };\n\n private isExactVersion(version: string) {\n return /^\\d/.test(version);\n }\n\n private isExcluded({ name }: Package, dependency: string) {\n const ruleConfig = this.#project.config.rules?.[this.id];\n if (Array.isArray(ruleConfig)) {\n const { exclude } = ruleConfig[1] ?? {};\n if (typeof exclude === 'object' && !Array.isArray(exclude)) {\n return exclude[name]?.includes(dependency);\n }\n }\n return false;\n }\n\n private isOpenEndedVersion(version: string) {\n return satisfies('999.999.999', version);\n }\n\n private isFixable(version: string) {\n return /^[\\^~]\\d+(\\.\\d+){0,2}$/.test(version);\n }\n\n private isViolation(\n pkg: Package,\n { dependency, version }: { dependency: string; version: string }\n ) {\n return (\n !this.isExactVersion(version) &&\n !this.isOpenEndedVersion(version) &&\n !this.isExcluded(pkg, dependency)\n );\n }\n}\n"],"names":["PreferOpenEndedPeerDependencies","id","run","project","checkPackages","checkPackage","fix","data","location","dependency","version","openEndedVersion","replace","command","execSync","stdio","isExactVersion","test","isExcluded","name","ruleConfig","config","rules","Array","isArray","exclude","includes","isOpenEndedVersion","satisfies","isFixable","isViolation","pkg","Object","entries","peerDependencies","reduce","result","push","message","severity","ErrorSeverity","warning","fixable","FixCategory","isolated"],"mappings":";;;;+BAYaA;;;eAAAA;;;+BAZY;wBACC;uBAC8D;uBAC1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAU1B;AADG,MAAMA;IAGT,IAAIC,KAAK;QACL,OAAO;IACX;IAEAC,IAAIC,OAAgB,EAA2B;uCACtC,UAAWA;QAChB,OAAOC,IAAAA,oBAAa,EAAC,IAAI,EAAED,SAAS,IAAI,CAACE,YAAY;IACzD;IAEAC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAa,EAAE;QAC/B,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAE,GAAGH,iBAAAA,kBAAAA,OAAQ,CAAC;QACzC,IAAI,CAAEC,CAAAA,YAAYC,cAAcC,OAAM,GAAI;YACtC;QACJ;QAEA,MAAMC,mBAAmBD,QAAQE,OAAO,CAAC,UAAU;QACnD,MAAMC,UAAU,CAAC,8BAA8B,EAAEJ,WAAW,IAAI,EAAEE,iBAAiB,KAAK,EAAEH,UAAU;QACpGM,IAAAA,uBAAQ,EAACD,SAAS;YAAEE,OAAO;QAAU;IACzC;IAsBQC,eAAeN,OAAe,EAAE;QACpC,OAAO,MAAMO,IAAI,CAACP;IACtB;IAEQQ,WAAW,EAAEC,IAAI,EAAW,EAAEV,UAAkB,EAAE;YACnC;QAAnB,MAAMW,cAAa,wCAAA,yBAAA,IAAI,EAAC,UAASC,MAAM,CAACC,KAAK,cAA1B,4DAAA,qCAA4B,CAAC,IAAI,CAACrB,EAAE,CAAC;QACxD,IAAIsB,MAAMC,OAAO,CAACJ,aAAa;gBACPA;YAApB,MAAM,EAAEK,OAAO,EAAE,GAAGL,CAAAA,eAAA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