repopo 0.3.2 → 0.5.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/CHANGELOG.md +65 -0
- package/README.md +37 -18
- package/THIRD-PARTY-LICENSES.txt +134 -36
- package/esm/api.d.ts +2 -0
- package/esm/api.d.ts.map +1 -0
- package/esm/api.js +2 -0
- package/esm/api.js.map +1 -0
- package/esm/baseCommand.d.ts +13 -43
- package/esm/baseCommand.d.ts.map +1 -1
- package/esm/baseCommand.js +27 -62
- package/esm/baseCommand.js.map +1 -1
- package/esm/commands/check.d.ts +2 -8
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +81 -89
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts +1 -2
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +5 -6
- package/esm/commands/list.js.map +1 -1
- package/esm/config.d.ts +10 -5
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js.map +1 -1
- package/esm/context.d.ts +29 -0
- package/esm/context.d.ts.map +1 -0
- package/esm/context.js +2 -0
- package/esm/context.js.map +1 -0
- package/esm/index.d.ts +11 -4
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +8 -0
- package/esm/index.js.map +1 -1
- package/esm/perf.d.ts.map +1 -1
- package/esm/perf.js +1 -5
- package/esm/perf.js.map +1 -1
- package/esm/policies/HtmlFileHeaders.d.ts +8 -0
- package/esm/policies/HtmlFileHeaders.d.ts.map +1 -0
- package/esm/policies/HtmlFileHeaders.js +17 -0
- package/esm/policies/HtmlFileHeaders.js.map +1 -0
- package/esm/policies/JsTsFileHeaders.d.ts +8 -0
- package/esm/policies/JsTsFileHeaders.d.ts.map +1 -0
- package/esm/policies/JsTsFileHeaders.js +24 -0
- package/esm/policies/JsTsFileHeaders.js.map +1 -0
- package/esm/policies/NoJsFileExtensions.d.ts +2 -0
- package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
- package/esm/policies/NoJsFileExtensions.js +2 -0
- package/esm/policies/NoJsFileExtensions.js.map +1 -1
- package/esm/policies/PackageJsonProperties.d.ts +6 -8
- package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
- package/esm/policies/PackageJsonProperties.js +37 -40
- package/esm/policies/PackageJsonProperties.js.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +3 -2
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.js +42 -39
- package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
- package/esm/policies/PackageJsonSorted.d.ts +7 -0
- package/esm/policies/PackageJsonSorted.d.ts.map +1 -0
- package/esm/policies/PackageJsonSorted.js +45 -0
- package/esm/policies/PackageJsonSorted.js.map +1 -0
- package/esm/policies/PackageScripts.d.ts +7 -0
- package/esm/policies/PackageScripts.d.ts.map +1 -0
- package/esm/policies/PackageScripts.js +25 -0
- package/esm/policies/PackageScripts.js.map +1 -0
- package/esm/policies/constants.d.ts +5 -0
- package/esm/policies/constants.d.ts.map +1 -0
- package/esm/policies/constants.js +5 -0
- package/esm/policies/constants.js.map +1 -0
- package/esm/policies.d.ts +7 -0
- package/esm/policies.d.ts.map +1 -0
- package/esm/policies.js +7 -0
- package/esm/policies.js.map +1 -0
- package/esm/policy.d.ts +31 -13
- package/esm/policy.d.ts.map +1 -1
- package/esm/policy.js +8 -20
- package/esm/policy.js.map +1 -1
- package/esm/policyGenerators/generateFileHeaderPolicy.d.ts +45 -0
- package/esm/policyGenerators/generateFileHeaderPolicy.d.ts.map +1 -0
- package/esm/policyGenerators/generateFileHeaderPolicy.js +61 -0
- package/esm/policyGenerators/generateFileHeaderPolicy.js.map +1 -0
- package/esm/policyGenerators/generatePackagePolicy.d.ts +9 -0
- package/esm/policyGenerators/generatePackagePolicy.d.ts.map +1 -0
- package/esm/policyGenerators/generatePackagePolicy.js +20 -0
- package/esm/policyGenerators/generatePackagePolicy.js.map +1 -0
- package/esm/tsdoc-metadata.json +1 -1
- package/oclif.manifest.json +45 -53
- package/package.json +43 -23
- package/esm/policies/PackageJsonSortedPolicy.d.ts +0 -6
- package/esm/policies/PackageJsonSortedPolicy.d.ts.map +0 -1
- package/esm/policies/PackageJsonSortedPolicy.js +0 -49
- package/esm/policies/PackageJsonSortedPolicy.js.map +0 -1
- package/esm/policies/SortTsconfigs.d.ts +0 -10
- package/esm/policies/SortTsconfigs.d.ts.map +0 -1
- package/esm/policies/SortTsconfigs.js +0 -33
- package/esm/policies/SortTsconfigs.js.map +0 -1
package/esm/policy.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @alpha
|
|
3
|
+
*/
|
|
4
|
+
export type DefaultPolicyConfigType = object | unknown;
|
|
1
5
|
/**
|
|
2
6
|
* A type representing a policy name.
|
|
3
7
|
*
|
|
@@ -5,13 +9,29 @@
|
|
|
5
9
|
*/
|
|
6
10
|
export type PolicyName = string;
|
|
7
11
|
/**
|
|
12
|
+
* Arguments passed to policy functions.
|
|
13
|
+
*
|
|
8
14
|
* @alpha
|
|
9
15
|
*/
|
|
10
|
-
export interface PolicyFunctionArguments<C
|
|
16
|
+
export interface PolicyFunctionArguments<C> {
|
|
17
|
+
/**
|
|
18
|
+
* Path to the file, relative to the repo root.
|
|
19
|
+
*/
|
|
11
20
|
file: string;
|
|
21
|
+
/**
|
|
22
|
+
* Absolute path to the root of the repo.
|
|
23
|
+
*/
|
|
12
24
|
root: string;
|
|
25
|
+
/**
|
|
26
|
+
* If true, the handler should resolve any violations automatically if possible.
|
|
27
|
+
*/
|
|
13
28
|
resolve: boolean;
|
|
14
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @remarks
|
|
31
|
+
*
|
|
32
|
+
* Note that the handler function receives the config as an argument.
|
|
33
|
+
*/
|
|
34
|
+
config?: C | undefined;
|
|
15
35
|
}
|
|
16
36
|
/**
|
|
17
37
|
* A policy handler is a function that is called to check policy against a file.
|
|
@@ -24,7 +44,7 @@ export type PolicyHandler<C = unknown | undefined> = (args: PolicyFunctionArgume
|
|
|
24
44
|
*
|
|
25
45
|
* @alpha
|
|
26
46
|
*/
|
|
27
|
-
export type PolicyStandaloneResolver<C =
|
|
47
|
+
export type PolicyStandaloneResolver<C = DefaultPolicyConfigType | undefined> = (args: Omit<PolicyFunctionArguments<C>, "resolve">) => Promise<PolicyFixResult>;
|
|
28
48
|
/**
|
|
29
49
|
* A RepoPolicy checks and applies policies to files in the repository.
|
|
30
50
|
*
|
|
@@ -38,7 +58,7 @@ export type PolicyStandaloneResolver<C = unknown | undefined> = (args: Omit<Poli
|
|
|
38
58
|
*
|
|
39
59
|
* @alpha
|
|
40
60
|
*/
|
|
41
|
-
export interface RepoPolicy<C =
|
|
61
|
+
export interface RepoPolicy<C extends DefaultPolicyConfigType = unknown | undefined> {
|
|
42
62
|
/**
|
|
43
63
|
* The name of the policy; displayed in UI and used in settings.
|
|
44
64
|
*/
|
|
@@ -69,14 +89,12 @@ export interface RepoPolicy<C = any | undefined> {
|
|
|
69
89
|
*/
|
|
70
90
|
resolver?: PolicyStandaloneResolver<C> | undefined;
|
|
71
91
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
constructor(name: string, match: RegExp, handler: PolicyHandler, resolver?: PolicyStandaloneResolver | undefined);
|
|
79
|
-
}
|
|
92
|
+
/**
|
|
93
|
+
* A policy handler especially for policies that target package.json.
|
|
94
|
+
*
|
|
95
|
+
* @alpha
|
|
96
|
+
*/
|
|
97
|
+
export type PackageJsonHandler<J, C> = (json: J, args: PolicyFunctionArguments<C>) => Promise<true | PolicyFailure | PolicyFixResult>;
|
|
80
98
|
/**
|
|
81
99
|
* A policy failure.
|
|
82
100
|
*
|
|
@@ -117,5 +135,5 @@ export declare function isPolicyFixResult(toCheck: any): toCheck is PolicyFixRes
|
|
|
117
135
|
*
|
|
118
136
|
* @alpha
|
|
119
137
|
*/
|
|
120
|
-
export declare const DefaultPolicies: RepoPolicy[];
|
|
138
|
+
export declare const DefaultPolicies: RepoPolicy<any>[];
|
|
121
139
|
//# sourceMappingURL=policy.d.ts.map
|
package/esm/policy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;GAIG;AAEH,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACzC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;CACvB;AAED;;;;GAIG;AAEH,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,GAAG,SAAS,IAAI,CACpD,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAC5B,OAAO,CAAC,IAAI,GAAG,aAAa,GAAG,eAAe,CAAC,CAAC;AAOrD;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,GAAG,uBAAuB,GAAG,SAAS,IAC3E,CACC,IAAI,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,KAC7C,OAAO,CAAC,eAAe,CAAC,CAAC;AAI/B;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU,CAC1B,CAAC,SAAS,uBAAuB,GAAG,OAAO,GAAG,SAAS;IAEvD;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;;OAOG;IAEH,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAE1B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI,CACtC,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAC5B,OAAO,CAAC,IAAI,GAAG,aAAa,GAAG,eAAe,CAAC,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAElC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACrD;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;CAClB;AAGD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,eAAe,CAK1E;AAED;;;;GAIG;AAGH,eAAO,MAAM,eAAe,EAAE,UAAU,CAAC,GAAG,CAAC,EAQnC,CAAC"}
|
package/esm/policy.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
+
import { HtmlFileHeaders } from "./policies.js";
|
|
2
|
+
import { JsTsFileHeaders } from "./policies/JsTsFileHeaders.js";
|
|
1
3
|
import { NoJsFileExtensions } from "./policies/NoJsFileExtensions.js";
|
|
2
4
|
import { PackageJsonProperties } from "./policies/PackageJsonProperties.js";
|
|
3
5
|
import { PackageJsonRepoDirectoryProperty } from "./policies/PackageJsonRepoDirectoryProperty.js";
|
|
4
|
-
import {
|
|
5
|
-
import { SortTsconfigs } from "./policies/SortTsconfigs.js";
|
|
6
|
-
export class RepoPolicyClass {
|
|
7
|
-
name;
|
|
8
|
-
match;
|
|
9
|
-
handler;
|
|
10
|
-
resolver;
|
|
11
|
-
static createRepoPolicy(name, match, handler, resolver) {
|
|
12
|
-
return new RepoPolicyClass(name, match, handler, resolver);
|
|
13
|
-
}
|
|
14
|
-
constructor(name, match, handler, resolver) {
|
|
15
|
-
this.name = name;
|
|
16
|
-
this.match = match;
|
|
17
|
-
this.handler = handler;
|
|
18
|
-
this.resolver = resolver;
|
|
19
|
-
// empty
|
|
20
|
-
}
|
|
21
|
-
}
|
|
6
|
+
import { PackageScripts } from "./policies/PackageScripts.js";
|
|
22
7
|
// biome-ignore lint/suspicious/noExplicitAny: type guard
|
|
23
8
|
export function isPolicyFixResult(toCheck) {
|
|
24
9
|
if (typeof toCheck !== "object") {
|
|
@@ -31,11 +16,14 @@ export function isPolicyFixResult(toCheck) {
|
|
|
31
16
|
*
|
|
32
17
|
* @alpha
|
|
33
18
|
*/
|
|
19
|
+
// biome-ignore lint/suspicious/noExplicitAny: FIXME
|
|
34
20
|
export const DefaultPolicies = [
|
|
21
|
+
HtmlFileHeaders,
|
|
22
|
+
JsTsFileHeaders,
|
|
35
23
|
NoJsFileExtensions,
|
|
36
24
|
PackageJsonRepoDirectoryProperty,
|
|
37
25
|
PackageJsonProperties,
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
// PackageJsonSorted,
|
|
27
|
+
PackageScripts,
|
|
40
28
|
];
|
|
41
29
|
//# sourceMappingURL=policy.js.map
|
package/esm/policy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AA4K9D,yDAAyD;AACzD,MAAM,UAAU,iBAAiB,CAAC,OAAY;IAC7C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,UAAU,IAAI,OAAO,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAAsB;IACjD,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,gCAAgC;IAChC,qBAAqB;IACrB,qBAAqB;IACrB,cAAc;CACL,CAAC","sourcesContent":["import { HtmlFileHeaders } from \"./policies.js\";\nimport { JsTsFileHeaders } from \"./policies/JsTsFileHeaders.js\";\nimport { NoJsFileExtensions } from \"./policies/NoJsFileExtensions.js\";\nimport { PackageJsonProperties } from \"./policies/PackageJsonProperties.js\";\nimport { PackageJsonRepoDirectoryProperty } from \"./policies/PackageJsonRepoDirectoryProperty.js\";\nimport { PackageScripts } from \"./policies/PackageScripts.js\";\n\n/**\n * @alpha\n */\nexport type DefaultPolicyConfigType = object | unknown;\n\n/**\n * A type representing a policy name.\n *\n * @alpha\n */\nexport type PolicyName = string;\n\n/**\n * Arguments passed to policy functions.\n *\n * @alpha\n */\n\nexport interface PolicyFunctionArguments<C> {\n\t/**\n\t * Path to the file, relative to the repo root.\n\t */\n\tfile: string;\n\n\t/**\n\t * Absolute path to the root of the repo.\n\t */\n\troot: string;\n\n\t/**\n\t * If true, the handler should resolve any violations automatically if possible.\n\t */\n\tresolve: boolean;\n\n\t/**\n\t * @remarks\n\t *\n\t * Note that the handler function receives the config as an argument.\n\t */\n\tconfig?: C | undefined;\n}\n\n/**\n * A policy handler is a function that is called to check policy against a file.\n *\n * @alpha\n */\n\nexport type PolicyHandler<C = unknown | undefined> = (\n\targs: PolicyFunctionArguments<C>,\n) => Promise<true | PolicyFailure | PolicyFixResult>;\n\n// export type PolicyCheckOnly = (\n// \tfile: string,\n// \troot: string,\n// ) => Promise<true | PolicyFailure | PolicyFixResult>;\n\n/**\n * A standalone function that can be called to resolve a policy failure.\n *\n * @alpha\n */\nexport type PolicyStandaloneResolver<C = DefaultPolicyConfigType | undefined> =\n\t(\n\t\targs: Omit<PolicyFunctionArguments<C>, \"resolve\">,\n\t) => Promise<PolicyFixResult>;\n\n// function isPolicyHandler(input: PolicyHandler | PolicyCheckOnly): input is PolicyHandler\n\n/**\n * A RepoPolicy checks and applies policies to files in the repository.\n *\n * Each policy has a name and a match regex for matching which files it should apply to. Every file in th repo is\n * enumerated and if it matches the regex for a policy, that policy is applied.\n *\n * Each policy includes a handler function that checks a file against the policy and can optionally resolve any problems\n * (automated resolutions depend on the policy implementation).\n *\n * @typeParam C - type of configuration object used by the policy\n *\n * @alpha\n */\nexport interface RepoPolicy<\n\tC extends DefaultPolicyConfigType = unknown | undefined,\n> {\n\t/**\n\t * The name of the policy; displayed in UI and used in settings.\n\t */\n\tname: PolicyName;\n\n\t/**\n\t * A more detailed description of the policy and its intended function.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * A regular expression that is used to match files in the repo.\n\t */\n\tmatch: RegExp;\n\n\t/**\n\t * A handler function that checks if a file is compliant with the policy.\n\t *\n\t * @param file - Repo-relative path to the file to check.\n\t * @param root - Absolute path to the root of the repo.\n\t * @param resolve - If true, automated policy fixes will be applied. Not all policies support automated fixes.\n\t * @returns True if the file passed the policy; otherwise a PolicyFailure object will be returned.\n\t */\n\n\thandler: PolicyHandler<C>;\n\n\t/**\n\t * A resolver function that can be used to automatically address the policy violation.\n\t *\n\t * @param file - Repo-relative path to the file to check.\n\t * @param root - Absolute path to the root of the repo.\n\t * @returns true if the file passed the policy; otherwise a PolicyFailure object will be returned.\n\t */\n\tresolver?: PolicyStandaloneResolver<C> | undefined;\n}\n\n/**\n * A policy handler especially for policies that target package.json.\n *\n * @alpha\n */\nexport type PackageJsonHandler<J, C> = (\n\tjson: J,\n\targs: PolicyFunctionArguments<C>,\n) => Promise<true | PolicyFailure | PolicyFixResult>;\n\n/**\n * A policy failure.\n *\n * @alpha\n */\nexport interface PolicyFailure {\n\t/**\n\t * Name of the policy that failed.\n\t */\n\tname: PolicyName;\n\n\t/**\n\t * Path to the file that failed the policy.\n\t */\n\tfile: string;\n\n\t/**\n\t * Set to `true` if the policy can be fixed automatically.\n\t */\n\tautoFixable?: boolean | undefined;\n\n\t/**\n\t * An optional error message accompanying the failure.\n\t */\n\terrorMessage?: string | undefined;\n}\n\n/**\n * The result of an automatic fix for a failing policy.\n *\n * @alpha\n */\nexport interface PolicyFixResult extends PolicyFailure {\n\t/**\n\t * Set to true if the failure was resolved by the automated fixer.\n\t */\n\tresolved: boolean;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isPolicyFixResult(toCheck: any): toCheck is PolicyFixResult {\n\tif (typeof toCheck !== \"object\") {\n\t\treturn false;\n\t}\n\treturn \"resolved\" in toCheck;\n}\n\n/**\n * Default policies included with repopo.\n *\n * @alpha\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: FIXME\nexport const DefaultPolicies: RepoPolicy<any>[] = [\n\tHtmlFileHeaders,\n\tJsTsFileHeaders,\n\tNoJsFileExtensions,\n\tPackageJsonRepoDirectoryProperty,\n\tPackageJsonProperties,\n\t// PackageJsonSorted,\n\tPackageScripts,\n] as const;\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { RepoPolicy } from "../policy.js";
|
|
2
|
+
/**
|
|
3
|
+
* @alpha
|
|
4
|
+
*/
|
|
5
|
+
export interface FileHeaderPolicyConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The text to use as the header.
|
|
8
|
+
*/
|
|
9
|
+
headerText: string;
|
|
10
|
+
/**
|
|
11
|
+
* An optional string that will be appended to the headerText.
|
|
12
|
+
*/
|
|
13
|
+
autoGenText?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @alpha
|
|
17
|
+
*/
|
|
18
|
+
export interface FileHeaderGeneratorConfig extends Partial<FileHeaderPolicyConfig> {
|
|
19
|
+
match: RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Regex matching header prefix (e.g. `/*!\r?\n`)
|
|
22
|
+
*/
|
|
23
|
+
headerStart?: RegExp;
|
|
24
|
+
/**
|
|
25
|
+
* Regex matching beginning of each line (e.g. ' * ')
|
|
26
|
+
*/
|
|
27
|
+
lineStart: RegExp;
|
|
28
|
+
/**
|
|
29
|
+
* Regex matching the end of each line (e.g., `\r?\n`)
|
|
30
|
+
*/
|
|
31
|
+
lineEnd: RegExp;
|
|
32
|
+
/**
|
|
33
|
+
* Regex matching the header postfix.
|
|
34
|
+
*/
|
|
35
|
+
headerEnd?: RegExp;
|
|
36
|
+
replacer: (content: string, config: FileHeaderPolicyConfig) => string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Given a `FileHeaderGeneratorConfig`, produces a function that detects correct file headers
|
|
40
|
+
* and returns an error string if the header is missing or incorrect.
|
|
41
|
+
*
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
export declare function generateFileHeaderPolicy(name: string, config: FileHeaderGeneratorConfig): RepoPolicy<FileHeaderPolicyConfig>;
|
|
45
|
+
//# sourceMappingURL=generateFileHeaderPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateFileHeaderPolicy.d.ts","sourceRoot":"","sources":["../../src/policyGenerators/generateFileHeaderPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkC,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,yBAChB,SAAQ,OAAO,CAAC,sBAAsB,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB,KAAK,MAAM,CAAC;CACtE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,yBAAyB,GAC/B,UAAU,CAAC,sBAAsB,CAAC,CAiEpC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { EOL as newline } from "node:os";
|
|
3
|
+
import { extname } from "pathe";
|
|
4
|
+
const trailingSpaces = /\s*\\r\?\\n/;
|
|
5
|
+
/**
|
|
6
|
+
* Given a `FileHeaderGeneratorConfig`, produces a function that detects correct file headers
|
|
7
|
+
* and returns an error string if the header is missing or incorrect.
|
|
8
|
+
*
|
|
9
|
+
* @alpha
|
|
10
|
+
*/
|
|
11
|
+
export function generateFileHeaderPolicy(name, config) {
|
|
12
|
+
const pre = config.headerStart?.source ?? "";
|
|
13
|
+
const start = config.lineStart.source;
|
|
14
|
+
const end = config.lineEnd.source;
|
|
15
|
+
const post = config.headerEnd?.source ?? "";
|
|
16
|
+
// Helper which constructs a matching RegExp from a given multiline string.
|
|
17
|
+
// (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping)
|
|
18
|
+
const toRegex = (text) => text
|
|
19
|
+
.split(newline)
|
|
20
|
+
.map((line) => `${start}${line.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}${end}`)
|
|
21
|
+
.join("")
|
|
22
|
+
.replace(trailingSpaces, "\\r?\\n"); // Trim trailing spaces at end-of-line.
|
|
23
|
+
// Detection regex matches the header start (if any), followed by lines in 'headerText',
|
|
24
|
+
// optionally followed by lines in the 'autoGenText', and finally the header end (if any).
|
|
25
|
+
const regex = new RegExp(`^${pre}${toRegex(config.headerText ?? "")}(${toRegex(config.autoGenText ?? "")})?${post}`);
|
|
26
|
+
return {
|
|
27
|
+
name,
|
|
28
|
+
match: config.match,
|
|
29
|
+
handler: async ({ file, resolve, config: policyConfig }) => {
|
|
30
|
+
if (policyConfig === undefined) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const failResult = {
|
|
34
|
+
name,
|
|
35
|
+
file,
|
|
36
|
+
autoFixable: true,
|
|
37
|
+
};
|
|
38
|
+
// TODO: Consider reading only the first 512B or so since headers are typically
|
|
39
|
+
// at the beginning of the file.
|
|
40
|
+
const content = await readFile(file, { encoding: "utf8" });
|
|
41
|
+
const failed = !regex.test(content);
|
|
42
|
+
if (failed) {
|
|
43
|
+
failResult.errorMessage = `${extname(file)} file missing header`;
|
|
44
|
+
}
|
|
45
|
+
if (failed) {
|
|
46
|
+
if (resolve) {
|
|
47
|
+
const newContent = config.replacer(content, policyConfig);
|
|
48
|
+
await writeFile(file, newContent);
|
|
49
|
+
const fixResult = {
|
|
50
|
+
...failResult,
|
|
51
|
+
resolved: true,
|
|
52
|
+
};
|
|
53
|
+
return fixResult;
|
|
54
|
+
}
|
|
55
|
+
return failResult;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=generateFileHeaderPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateFileHeaderPolicy.js","sourceRoot":"","sources":["../../src/policyGenerators/generateFileHeaderPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC,MAAM,cAAc,GAAG,aAAa,CAAC;AA+CrC;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACvC,IAAY,EACZ,MAAiC;IAEjC,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,IAAI,EAAE,CAAC;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;IACtC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,IAAI,EAAE,CAAC;IAE5C,2EAA2E;IAC3E,mGAAmG;IACnG,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,CACxC,IAAI;SACF,KAAK,CAAC,OAAO,CAAC;SACd,GAAG,CACH,CAAC,IAAI,EAAE,EAAE,CACR,GAAG,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAAG,GAAG,EAAE,CAC/D;SACA,IAAI,CAAC,EAAE,CAAC;SACR,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC,uCAAuC;IAE9E,wFAAwF;IACxF,0FAA0F;IAC1F,MAAM,KAAK,GAAG,IAAI,MAAM,CACvB,IAAI,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,KAAK,IAAI,EAAE,CAC1F,CAAC;IAEF,OAAO;QACN,IAAI;QACJ,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE;YAC1D,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC;YACb,CAAC;YAED,MAAM,UAAU,GAAkB;gBACjC,IAAI;gBACJ,IAAI;gBACJ,WAAW,EAAE,IAAI;aACjB,CAAC;YAEF,+EAA+E;YAC/E,gCAAgC;YAChC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3D,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAEpC,IAAI,MAAM,EAAE,CAAC;gBACZ,UAAU,CAAC,YAAY,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;YAClE,CAAC;YAED,IAAI,MAAM,EAAE,CAAC;gBACZ,IAAI,OAAO,EAAE,CAAC;oBACb,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;oBAC1D,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;oBAElC,MAAM,SAAS,GAAoB;wBAClC,GAAG,UAAU;wBACb,QAAQ,EAAE,IAAI;qBACd,CAAC;oBAEF,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,OAAO,UAAU,CAAC;YACnB,CAAC;YAED,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { readFile, writeFile } from \"node:fs/promises\";\nimport { EOL as newline } from \"node:os\";\nimport { extname } from \"pathe\";\nimport type { PolicyFailure, PolicyFixResult, RepoPolicy } from \"../policy.js\";\n\nconst trailingSpaces = /\\s*\\\\r\\?\\\\n/;\n\n/**\n * @alpha\n */\nexport interface FileHeaderPolicyConfig {\n\t/**\n\t * The text to use as the header.\n\t */\n\theaderText: string;\n\n\t/**\n\t * An optional string that will be appended to the headerText.\n\t */\n\tautoGenText?: string;\n}\n\n/**\n * @alpha\n */\nexport interface FileHeaderGeneratorConfig\n\textends Partial<FileHeaderPolicyConfig> {\n\tmatch: RegExp;\n\n\t/**\n\t * Regex matching header prefix (e.g. `/*!\\r?\\n`)\n\t */\n\theaderStart?: RegExp;\n\n\t/**\n\t * Regex matching beginning of each line (e.g. ' * ')\n\t */\n\tlineStart: RegExp;\n\n\t/**\n\t * Regex matching the end of each line (e.g., `\\r?\\n`)\n\t */\n\tlineEnd: RegExp;\n\n\t/**\n\t * Regex matching the header postfix.\n\t */\n\theaderEnd?: RegExp;\n\n\treplacer: (content: string, config: FileHeaderPolicyConfig) => string;\n}\n\n/**\n * Given a `FileHeaderGeneratorConfig`, produces a function that detects correct file headers\n * and returns an error string if the header is missing or incorrect.\n *\n * @alpha\n */\nexport function generateFileHeaderPolicy(\n\tname: string,\n\tconfig: FileHeaderGeneratorConfig,\n): RepoPolicy<FileHeaderPolicyConfig> {\n\tconst pre = config.headerStart?.source ?? \"\";\n\tconst start = config.lineStart.source;\n\tconst end = config.lineEnd.source;\n\tconst post = config.headerEnd?.source ?? \"\";\n\n\t// Helper which constructs a matching RegExp from a given multiline string.\n\t// (See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping)\n\tconst toRegex = (text: string): string =>\n\t\ttext\n\t\t\t.split(newline)\n\t\t\t.map(\n\t\t\t\t(line) =>\n\t\t\t\t\t`${start}${line.replace(/[$()*+.?[\\\\\\]^{|}]/g, \"\\\\$&\")}${end}`,\n\t\t\t)\n\t\t\t.join(\"\")\n\t\t\t.replace(trailingSpaces, \"\\\\r?\\\\n\"); // Trim trailing spaces at end-of-line.\n\n\t// Detection regex matches the header start (if any), followed by lines in 'headerText',\n\t// optionally followed by lines in the 'autoGenText', and finally the header end (if any).\n\tconst regex = new RegExp(\n\t\t`^${pre}${toRegex(config.headerText ?? \"\")}(${toRegex(config.autoGenText ?? \"\")})?${post}`,\n\t);\n\n\treturn {\n\t\tname,\n\t\tmatch: config.match,\n\t\thandler: async ({ file, resolve, config: policyConfig }) => {\n\t\t\tif (policyConfig === undefined) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst failResult: PolicyFailure = {\n\t\t\t\tname,\n\t\t\t\tfile,\n\t\t\t\tautoFixable: true,\n\t\t\t};\n\n\t\t\t// TODO: Consider reading only the first 512B or so since headers are typically\n\t\t\t// at the beginning of the file.\n\t\t\tconst content = await readFile(file, { encoding: \"utf8\" });\n\t\t\tconst failed = !regex.test(content);\n\n\t\t\tif (failed) {\n\t\t\t\tfailResult.errorMessage = `${extname(file)} file missing header`;\n\t\t\t}\n\n\t\t\tif (failed) {\n\t\t\t\tif (resolve) {\n\t\t\t\t\tconst newContent = config.replacer(content, policyConfig);\n\t\t\t\t\tawait writeFile(file, newContent);\n\n\t\t\t\t\tconst fixResult: PolicyFixResult = {\n\t\t\t\t\t\t...failResult,\n\t\t\t\t\t\tresolved: true,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn fixResult;\n\t\t\t\t}\n\t\t\t\treturn failResult;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PackageJson } from "type-fest";
|
|
2
|
+
import type { PackageJsonHandler, RepoPolicy } from "../policy.js";
|
|
3
|
+
/**
|
|
4
|
+
* Define a repo policy for package.json files.
|
|
5
|
+
*
|
|
6
|
+
* @alpha
|
|
7
|
+
*/
|
|
8
|
+
export declare function generatePackagePolicy<J = PackageJson, C = undefined>(name: string, packagePolicy: PackageJsonHandler<J, C>): RepoPolicy<C>;
|
|
9
|
+
//# sourceMappingURL=generatePackagePolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatePackagePolicy.d.ts","sourceRoot":"","sources":["../../src/policyGenerators/generatePackagePolicy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAInE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,WAAW,EAAE,CAAC,GAAG,SAAS,EACnE,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAErC,UAAU,CAAC,CAAC,CAAC,CAUf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import jsonfile from "jsonfile";
|
|
2
|
+
import { PackageJsonRegexMatch } from "../policies/constants.js";
|
|
3
|
+
const { readFile: readJson } = jsonfile;
|
|
4
|
+
/**
|
|
5
|
+
* Define a repo policy for package.json files.
|
|
6
|
+
*
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export function generatePackagePolicy(name, packagePolicy) {
|
|
10
|
+
// const func = () => handler(json, args);
|
|
11
|
+
return {
|
|
12
|
+
name,
|
|
13
|
+
match: PackageJsonRegexMatch,
|
|
14
|
+
handler: async (innerArgs) => {
|
|
15
|
+
const json = await readJson(innerArgs.file);
|
|
16
|
+
return packagePolicy(json, innerArgs);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=generatePackagePolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatePackagePolicy.js","sourceRoot":"","sources":["../../src/policyGenerators/generatePackagePolicy.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACpC,IAAY,EACZ,aAAuC;IAGvC,0CAA0C;IAC1C,OAAO;QACN,IAAI;QACJ,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC5B,MAAM,IAAI,GAAM,MAAM,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAC/C,OAAO,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACvC,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import jsonfile from \"jsonfile\";\nimport type { PackageJson } from \"type-fest\";\nimport { PackageJsonRegexMatch } from \"../policies/constants.js\";\nimport type { PackageJsonHandler, RepoPolicy } from \"../policy.js\";\n\nconst { readFile: readJson } = jsonfile;\n\n/**\n * Define a repo policy for package.json files.\n *\n * @alpha\n */\nexport function generatePackagePolicy<J = PackageJson, C = undefined>(\n\tname: string,\n\tpackagePolicy: PackageJsonHandler<J, C>,\n\t// args: PolicyFunctionArguments<C>,\n): RepoPolicy<C> {\n\t// const func = () => handler(json, args);\n\treturn {\n\t\tname,\n\t\tmatch: PackageJsonRegexMatch,\n\t\thandler: async (innerArgs) => {\n\t\t\tconst json: J = await readJson(innerArgs.file);\n\t\t\treturn packagePolicy(json, innerArgs);\n\t\t},\n\t};\n}\n"]}
|
package/esm/tsdoc-metadata.json
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -4,6 +4,29 @@
|
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {},
|
|
6
6
|
"flags": {
|
|
7
|
+
"verbose": {
|
|
8
|
+
"char": "v",
|
|
9
|
+
"description": "Enable verbose logging.",
|
|
10
|
+
"exclusive": [
|
|
11
|
+
"quiet"
|
|
12
|
+
],
|
|
13
|
+
"helpGroup": "LOGGING",
|
|
14
|
+
"name": "verbose",
|
|
15
|
+
"required": false,
|
|
16
|
+
"allowNo": false,
|
|
17
|
+
"type": "boolean"
|
|
18
|
+
},
|
|
19
|
+
"quiet": {
|
|
20
|
+
"description": "Disable all logging.",
|
|
21
|
+
"exclusive": [
|
|
22
|
+
"verbose"
|
|
23
|
+
],
|
|
24
|
+
"helpGroup": "LOGGING",
|
|
25
|
+
"name": "quiet",
|
|
26
|
+
"required": false,
|
|
27
|
+
"allowNo": false,
|
|
28
|
+
"type": "boolean"
|
|
29
|
+
},
|
|
7
30
|
"fix": {
|
|
8
31
|
"aliases": [
|
|
9
32
|
"resolve"
|
|
@@ -22,35 +45,6 @@
|
|
|
22
45
|
"allowNo": false,
|
|
23
46
|
"type": "boolean"
|
|
24
47
|
},
|
|
25
|
-
"policy": {
|
|
26
|
-
"char": "d",
|
|
27
|
-
"description": "Filter policies to apply by <regex>. Only policies with a name matching the regex will be applied.",
|
|
28
|
-
"name": "policy",
|
|
29
|
-
"required": false,
|
|
30
|
-
"hasDynamicHelp": false,
|
|
31
|
-
"multiple": false,
|
|
32
|
-
"type": "option"
|
|
33
|
-
},
|
|
34
|
-
"excludePolicy": {
|
|
35
|
-
"char": "D",
|
|
36
|
-
"description": "Exclude policies by name. Can be specified multiple times to exclude multiple policies.",
|
|
37
|
-
"exclusive": [
|
|
38
|
-
"policy"
|
|
39
|
-
],
|
|
40
|
-
"name": "excludePolicy",
|
|
41
|
-
"hasDynamicHelp": false,
|
|
42
|
-
"multiple": true,
|
|
43
|
-
"type": "option"
|
|
44
|
-
},
|
|
45
|
-
"path": {
|
|
46
|
-
"char": "p",
|
|
47
|
-
"description": "Filter file paths by <regex>.",
|
|
48
|
-
"name": "path",
|
|
49
|
-
"required": false,
|
|
50
|
-
"hasDynamicHelp": false,
|
|
51
|
-
"multiple": false,
|
|
52
|
-
"type": "option"
|
|
53
|
-
},
|
|
54
48
|
"config": {
|
|
55
49
|
"description": "The path to a configuration file.",
|
|
56
50
|
"helpGroup": "CONFIGURATION",
|
|
@@ -67,7 +61,9 @@
|
|
|
67
61
|
"pluginAlias": "repopo",
|
|
68
62
|
"pluginName": "repopo",
|
|
69
63
|
"pluginType": "core",
|
|
64
|
+
"strict": true,
|
|
70
65
|
"summary": "Checks and applies policies to the files in the repository.",
|
|
66
|
+
"enableJsonFlag": false,
|
|
71
67
|
"isESM": true,
|
|
72
68
|
"relativePath": [
|
|
73
69
|
"esm",
|
|
@@ -79,34 +75,28 @@
|
|
|
79
75
|
"aliases": [],
|
|
80
76
|
"args": {},
|
|
81
77
|
"flags": {
|
|
82
|
-
"
|
|
83
|
-
"char": "
|
|
84
|
-
"description": "
|
|
85
|
-
"
|
|
78
|
+
"verbose": {
|
|
79
|
+
"char": "v",
|
|
80
|
+
"description": "Enable verbose logging.",
|
|
81
|
+
"exclusive": [
|
|
82
|
+
"quiet"
|
|
83
|
+
],
|
|
84
|
+
"helpGroup": "LOGGING",
|
|
85
|
+
"name": "verbose",
|
|
86
86
|
"required": false,
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"type": "option"
|
|
87
|
+
"allowNo": false,
|
|
88
|
+
"type": "boolean"
|
|
90
89
|
},
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"description": "Exclude policies by name. Can be specified multiple times to exclude multiple policies.",
|
|
90
|
+
"quiet": {
|
|
91
|
+
"description": "Disable all logging.",
|
|
94
92
|
"exclusive": [
|
|
95
|
-
"
|
|
93
|
+
"verbose"
|
|
96
94
|
],
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"multiple": true,
|
|
100
|
-
"type": "option"
|
|
101
|
-
},
|
|
102
|
-
"path": {
|
|
103
|
-
"char": "p",
|
|
104
|
-
"description": "Filter file paths by <regex>.",
|
|
105
|
-
"name": "path",
|
|
95
|
+
"helpGroup": "LOGGING",
|
|
96
|
+
"name": "quiet",
|
|
106
97
|
"required": false,
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"type": "option"
|
|
98
|
+
"allowNo": false,
|
|
99
|
+
"type": "boolean"
|
|
110
100
|
},
|
|
111
101
|
"config": {
|
|
112
102
|
"description": "The path to a configuration file.",
|
|
@@ -124,7 +114,9 @@
|
|
|
124
114
|
"pluginAlias": "repopo",
|
|
125
115
|
"pluginName": "repopo",
|
|
126
116
|
"pluginType": "core",
|
|
117
|
+
"strict": true,
|
|
127
118
|
"summary": "Lists the policies configured to run.",
|
|
119
|
+
"enableJsonFlag": false,
|
|
128
120
|
"isESM": true,
|
|
129
121
|
"relativePath": [
|
|
130
122
|
"esm",
|
|
@@ -133,5 +125,5 @@
|
|
|
133
125
|
]
|
|
134
126
|
}
|
|
135
127
|
},
|
|
136
|
-
"version": "0.
|
|
128
|
+
"version": "0.5.0"
|
|
137
129
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repopo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Enforce policies on all or some of the files in a git repository.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"policy",
|
|
@@ -20,6 +20,14 @@
|
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./esm/index.d.ts",
|
|
22
22
|
"import": "./esm/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./api": {
|
|
25
|
+
"types": "./esm/api.d.ts",
|
|
26
|
+
"import": "./esm/api.js"
|
|
27
|
+
},
|
|
28
|
+
"./policies": {
|
|
29
|
+
"types": "./esm/policies.d.ts",
|
|
30
|
+
"import": "./esm/policies.js"
|
|
23
31
|
}
|
|
24
32
|
},
|
|
25
33
|
"types": "esm/index.d.ts",
|
|
@@ -45,35 +53,45 @@
|
|
|
45
53
|
"repositoryPrefix": "<%- repo %>/blob/main/packages/repopo/<%- commandPath %>"
|
|
46
54
|
},
|
|
47
55
|
"dependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@oclif/core": "^4.
|
|
50
|
-
"@oclif/plugin-help": "^6.2.
|
|
51
|
-
"@rushstack/node-core-library": "^5.
|
|
52
|
-
"
|
|
56
|
+
"@fluid-tools/build-infrastructure": "^0.56.0",
|
|
57
|
+
"@oclif/core": "^4.2.10",
|
|
58
|
+
"@oclif/plugin-help": "^6.2.27",
|
|
59
|
+
"@rushstack/node-core-library": "^5.13.0",
|
|
60
|
+
"defu": "^6.1.4",
|
|
53
61
|
"jsonfile": "^6.1.0",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
62
|
+
"microdiff": "^1.5.0",
|
|
63
|
+
"pathe": "^2.0.3",
|
|
64
|
+
"picocolors": "^1.1.1",
|
|
65
|
+
"simple-git": "^3.27.0",
|
|
66
|
+
"@tylerbu/cli-api": "^0.7.1",
|
|
67
|
+
"@tylerbu/fundamentals": "^0.2.1"
|
|
58
68
|
},
|
|
59
69
|
"devDependencies": {
|
|
60
|
-
"@biomejs/biome": "1.
|
|
61
|
-
"@microsoft/api-extractor": "^7.
|
|
62
|
-
"@oclif/plugin-command-snapshot": "^5.2.
|
|
63
|
-
"@oclif/test": "^4.
|
|
70
|
+
"@biomejs/biome": "1.9.4",
|
|
71
|
+
"@microsoft/api-extractor": "^7.52.4",
|
|
72
|
+
"@oclif/plugin-command-snapshot": "^5.2.38",
|
|
73
|
+
"@oclif/test": "^4.1.12",
|
|
64
74
|
"@types/jsonfile": "^6.1.4",
|
|
65
75
|
"@types/node": "^20.12.7",
|
|
66
76
|
"@types/tmp": "^0.2.6",
|
|
67
|
-
"
|
|
68
|
-
"oclif": "^4.
|
|
69
|
-
"rimraf": "^6.0.
|
|
70
|
-
"serve": "^14.2.
|
|
71
|
-
"start-server-and-test": "^2.0.
|
|
77
|
+
"generate-license-file": "^4.0.0",
|
|
78
|
+
"oclif": "^4.17.45",
|
|
79
|
+
"rimraf": "^6.0.1",
|
|
80
|
+
"serve": "^14.2.4",
|
|
81
|
+
"start-server-and-test": "^2.0.11",
|
|
72
82
|
"tmp-promise": "^3.0.3",
|
|
73
83
|
"ts-node": "^10.9.2",
|
|
74
|
-
"type-fest": "^4.
|
|
84
|
+
"type-fest": "^4.40.0",
|
|
75
85
|
"typescript": "~5.5.4",
|
|
76
|
-
"vitest": "^
|
|
86
|
+
"vitest": "^3.1.1"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"sort-package-json": "*"
|
|
90
|
+
},
|
|
91
|
+
"peerDependenciesMeta": {
|
|
92
|
+
"sort-package-json": {
|
|
93
|
+
"optional": true
|
|
94
|
+
}
|
|
77
95
|
},
|
|
78
96
|
"engines": {
|
|
79
97
|
"node": ">=18.0.0"
|
|
@@ -94,7 +112,9 @@
|
|
|
94
112
|
"lint": "biome lint .",
|
|
95
113
|
"lint:fix": "biome lint . --write",
|
|
96
114
|
"manifest": "oclif manifest",
|
|
97
|
-
"readme": "
|
|
98
|
-
"
|
|
115
|
+
"readme": "concurrently npm:readme:*",
|
|
116
|
+
"readme:docs": "oclif readme --no-aliases --readme-path=../repopo-docs/src/content/docs/cli-reference.md",
|
|
117
|
+
"readme:main": "oclif readme --no-aliases",
|
|
118
|
+
"release:license-file": "generate-license-file -c ../../.generatelicensefile.cjs"
|
|
99
119
|
}
|
|
100
120
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { RepoPolicy } from "../policy.js";
|
|
2
|
-
/**
|
|
3
|
-
* A repo policy that checks if package.json files in the repo are sorted using sort-package-json.
|
|
4
|
-
*/
|
|
5
|
-
export declare const PackageJsonSortedPolicy: RepoPolicy;
|
|
6
|
-
//# sourceMappingURL=PackageJsonSortedPolicy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PackageJsonSortedPolicy.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonSortedPolicy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAkC,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,UAwCrC,CAAC"}
|