repopo 0.4.0 → 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.
Files changed (92) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +37 -18
  3. package/THIRD-PARTY-LICENSES.txt +21 -11
  4. package/esm/api.d.ts +2 -0
  5. package/esm/api.d.ts.map +1 -0
  6. package/esm/api.js +2 -0
  7. package/esm/api.js.map +1 -0
  8. package/esm/baseCommand.d.ts +13 -43
  9. package/esm/baseCommand.d.ts.map +1 -1
  10. package/esm/baseCommand.js +27 -62
  11. package/esm/baseCommand.js.map +1 -1
  12. package/esm/commands/check.d.ts +2 -8
  13. package/esm/commands/check.d.ts.map +1 -1
  14. package/esm/commands/check.js +79 -87
  15. package/esm/commands/check.js.map +1 -1
  16. package/esm/commands/list.d.ts +1 -2
  17. package/esm/commands/list.d.ts.map +1 -1
  18. package/esm/commands/list.js +5 -6
  19. package/esm/commands/list.js.map +1 -1
  20. package/esm/config.d.ts +10 -5
  21. package/esm/config.d.ts.map +1 -1
  22. package/esm/config.js.map +1 -1
  23. package/esm/context.d.ts +29 -0
  24. package/esm/context.d.ts.map +1 -0
  25. package/esm/context.js +2 -0
  26. package/esm/context.js.map +1 -0
  27. package/esm/index.d.ts +11 -4
  28. package/esm/index.d.ts.map +1 -1
  29. package/esm/index.js +8 -0
  30. package/esm/index.js.map +1 -1
  31. package/esm/perf.d.ts.map +1 -1
  32. package/esm/perf.js +1 -5
  33. package/esm/perf.js.map +1 -1
  34. package/esm/policies/HtmlFileHeaders.d.ts +8 -0
  35. package/esm/policies/HtmlFileHeaders.d.ts.map +1 -0
  36. package/esm/policies/HtmlFileHeaders.js +17 -0
  37. package/esm/policies/HtmlFileHeaders.js.map +1 -0
  38. package/esm/policies/JsTsFileHeaders.d.ts +8 -0
  39. package/esm/policies/JsTsFileHeaders.d.ts.map +1 -0
  40. package/esm/policies/JsTsFileHeaders.js +24 -0
  41. package/esm/policies/JsTsFileHeaders.js.map +1 -0
  42. package/esm/policies/NoJsFileExtensions.d.ts +2 -0
  43. package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
  44. package/esm/policies/NoJsFileExtensions.js +2 -0
  45. package/esm/policies/NoJsFileExtensions.js.map +1 -1
  46. package/esm/policies/PackageJsonProperties.d.ts +6 -8
  47. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  48. package/esm/policies/PackageJsonProperties.js +37 -40
  49. package/esm/policies/PackageJsonProperties.js.map +1 -1
  50. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +3 -2
  51. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  52. package/esm/policies/PackageJsonRepoDirectoryProperty.js +40 -37
  53. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  54. package/esm/policies/PackageJsonSorted.d.ts +7 -0
  55. package/esm/policies/PackageJsonSorted.d.ts.map +1 -0
  56. package/esm/policies/PackageJsonSorted.js +45 -0
  57. package/esm/policies/PackageJsonSorted.js.map +1 -0
  58. package/esm/policies/PackageScripts.d.ts +7 -0
  59. package/esm/policies/PackageScripts.d.ts.map +1 -0
  60. package/esm/policies/PackageScripts.js +25 -0
  61. package/esm/policies/PackageScripts.js.map +1 -0
  62. package/esm/policies/constants.d.ts +5 -0
  63. package/esm/policies/constants.d.ts.map +1 -0
  64. package/esm/policies/constants.js +5 -0
  65. package/esm/policies/constants.js.map +1 -0
  66. package/esm/policies.d.ts +7 -0
  67. package/esm/policies.d.ts.map +1 -0
  68. package/esm/policies.js +7 -0
  69. package/esm/policies.js.map +1 -0
  70. package/esm/policy.d.ts +31 -13
  71. package/esm/policy.d.ts.map +1 -1
  72. package/esm/policy.js +8 -20
  73. package/esm/policy.js.map +1 -1
  74. package/esm/policyGenerators/generateFileHeaderPolicy.d.ts +45 -0
  75. package/esm/policyGenerators/generateFileHeaderPolicy.d.ts.map +1 -0
  76. package/esm/policyGenerators/generateFileHeaderPolicy.js +61 -0
  77. package/esm/policyGenerators/generateFileHeaderPolicy.js.map +1 -0
  78. package/esm/policyGenerators/generatePackagePolicy.d.ts +9 -0
  79. package/esm/policyGenerators/generatePackagePolicy.d.ts.map +1 -0
  80. package/esm/policyGenerators/generatePackagePolicy.js +20 -0
  81. package/esm/policyGenerators/generatePackagePolicy.js.map +1 -0
  82. package/esm/tsdoc-metadata.json +1 -1
  83. package/oclif.manifest.json +45 -53
  84. package/package.json +39 -21
  85. package/esm/policies/PackageJsonSortedPolicy.d.ts +0 -6
  86. package/esm/policies/PackageJsonSortedPolicy.d.ts.map +0 -1
  87. package/esm/policies/PackageJsonSortedPolicy.js +0 -49
  88. package/esm/policies/PackageJsonSortedPolicy.js.map +0 -1
  89. package/esm/policies/SortTsconfigs.d.ts +0 -10
  90. package/esm/policies/SortTsconfigs.d.ts.map +0 -1
  91. package/esm/policies/SortTsconfigs.js +0 -33
  92. package/esm/policies/SortTsconfigs.js.map +0 -1
@@ -0,0 +1,24 @@
1
+ import { EOL as newline } from "node:os";
2
+ import { generateFileHeaderPolicy, } from "../policyGenerators/generateFileHeaderPolicy.js";
3
+ const jsTsReplacer = (prevContent, { headerText }) => {
4
+ // prepend header to existing content
5
+ const separator = prevContent.startsWith("\r") || prevContent.startsWith("\n")
6
+ ? newline
7
+ : newline + newline;
8
+ const newContent = `/*!${newline} * ${headerText.replace(newline, `${newline} * `)}${newline} */${separator}${prevContent}`;
9
+ return newContent;
10
+ };
11
+ /**
12
+ * A RepoPolicy that checks that JavaScript and TypeScript source files have the configured header comment
13
+ *
14
+ * @alpha
15
+ */
16
+ export const JsTsFileHeaders = generateFileHeaderPolicy("JsTsFileHeaders", {
17
+ match: /(^|\/)[^/]+\.[mc]?[jt]sx?$/i,
18
+ headerStart: /(#![^\n]*\r?\n)?\/\*!\r?\n/, // Begins with optional hashbang followed by '/*!'
19
+ lineStart: / \* /, // Subsequent lines begins with ' * '
20
+ lineEnd: /\r?\n/, // Subsequent lines end with CRLF or LF
21
+ headerEnd: / \*\/\r?\n\r?\n/, // Header ends with ' */' on a line by itself, followed by another newline
22
+ replacer: jsTsReplacer,
23
+ });
24
+ //# sourceMappingURL=JsTsFileHeaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsTsFileHeaders.js","sourceRoot":"","sources":["../../src/policies/JsTsFileHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAEN,wBAAwB,GACxB,MAAM,iDAAiD,CAAC;AAEzD,MAAM,YAAY,GAAG,CACpB,WAAmB,EACnB,EAAE,UAAU,EAA0B,EAC7B,EAAE;IACX,qCAAqC;IACrC,MAAM,SAAS,GACd,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;QAC3D,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,MAAM,UAAU,GAAG,MAAM,OAAO,MAAM,UAAU,CAAC,OAAO,CACvD,OAAO,EACP,GAAG,OAAO,KAAK,CACf,GAAG,OAAO,MAAM,SAAS,GAAG,WAAW,EAAE,CAAC;IAC3C,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAC,iBAAiB,EAAE;IAC1E,KAAK,EAAE,6BAA6B;IACpC,WAAW,EAAE,4BAA4B,EAAE,kDAAkD;IAC7F,SAAS,EAAE,MAAM,EAAE,qCAAqC;IACxD,OAAO,EAAE,OAAO,EAAE,uCAAuC;IACzD,SAAS,EAAE,iBAAiB,EAAE,0EAA0E;IACxG,QAAQ,EAAE,YAAY;CACtB,CAAC,CAAC","sourcesContent":["import { EOL as newline } from \"node:os\";\nimport {\n\ttype FileHeaderPolicyConfig,\n\tgenerateFileHeaderPolicy,\n} from \"../policyGenerators/generateFileHeaderPolicy.js\";\n\nconst jsTsReplacer = (\n\tprevContent: string,\n\t{ headerText }: FileHeaderPolicyConfig,\n): string => {\n\t// prepend header to existing content\n\tconst separator =\n\t\tprevContent.startsWith(\"\\r\") || prevContent.startsWith(\"\\n\")\n\t\t\t? newline\n\t\t\t: newline + newline;\n\tconst newContent = `/*!${newline} * ${headerText.replace(\n\t\tnewline,\n\t\t`${newline} * `,\n\t)}${newline} */${separator}${prevContent}`;\n\treturn newContent;\n};\n\n/**\n * A RepoPolicy that checks that JavaScript and TypeScript source files have the configured header comment\n *\n * @alpha\n */\nexport const JsTsFileHeaders = generateFileHeaderPolicy(\"JsTsFileHeaders\", {\n\tmatch: /(^|\\/)[^/]+\\.[mc]?[jt]sx?$/i,\n\theaderStart: /(#![^\\n]*\\r?\\n)?\\/\\*!\\r?\\n/, // Begins with optional hashbang followed by '/*!'\n\tlineStart: / \\* /, // Subsequent lines begins with ' * '\n\tlineEnd: /\\r?\\n/, // Subsequent lines end with CRLF or LF\n\theaderEnd: / \\*\\/\\r?\\n\\r?\\n/, // Header ends with ' */' on a line by itself, followed by another newline\n\treplacer: jsTsReplacer,\n});\n"]}
@@ -5,6 +5,8 @@ import type { RepoPolicy } from "../policy.js";
5
5
  * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS
6
6
  * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated
7
7
  * like an ESM file.
8
+ *
9
+ * @alpha
8
10
  */
9
11
  export declare const NoJsFileExtensions: RepoPolicy;
10
12
  //# sourceMappingURL=NoJsFileExtensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoJsFileExtensions.d.ts","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAehC,CAAC"}
1
+ {"version":3,"file":"NoJsFileExtensions.d.ts","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAehC,CAAC"}
@@ -4,6 +4,8 @@
4
4
  * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS
5
5
  * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated
6
6
  * like an ESM file.
7
+ *
8
+ * @alpha
7
9
  */
8
10
  export const NoJsFileExtensions = {
9
11
  name: "NoJsFileExtensions",
@@ -1 +1 @@
1
- {"version":3,"file":"NoJsFileExtensions.js","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAe;IAC7C,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,mBAAmB;IAC1B,uDAAuD;IACvD,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC3B,qCAAqC;QACrC,MAAM,MAAM,GAAkB;YAC7B,IAAI,EAAE,kBAAkB,CAAC,IAAI;YAC7B,IAAI;YACJ,WAAW,EAAE,KAAK;YAClB,YAAY,EACX,iIAAiI;SAClI,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;CACD,CAAC","sourcesContent":["import type { PolicyFailure, RepoPolicy } from \"../policy.js\";\n\n/**\n * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be\n * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This\n * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS\n * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated\n * like an ESM file.\n */\nexport const NoJsFileExtensions: RepoPolicy = {\n\tname: \"NoJsFileExtensions\",\n\tmatch: /(^|\\/)[^/]+\\.js$/i,\n\t// biome-ignore lint/suspicious/useAwait: <explanation>\n\thandler: async ({ file }) => {\n\t\t// Any match is considered a failure.\n\t\tconst result: PolicyFailure = {\n\t\t\tname: NoJsFileExtensions.name,\n\t\t\tfile,\n\t\t\tautoFixable: false,\n\t\t\terrorMessage:\n\t\t\t\t\"JavaScript files should have a .cjs or .mjs file extension based on the module format of the file. Rename the file accordingly.\",\n\t\t};\n\t\treturn result;\n\t},\n};\n"]}
1
+ {"version":3,"file":"NoJsFileExtensions.js","sourceRoot":"","sources":["../../src/policies/NoJsFileExtensions.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAe;IAC7C,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,mBAAmB;IAC1B,uDAAuD;IACvD,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC3B,qCAAqC;QACrC,MAAM,MAAM,GAAkB;YAC7B,IAAI,EAAE,kBAAkB,CAAC,IAAI;YAC7B,IAAI;YACJ,WAAW,EAAE,KAAK;YAClB,YAAY,EACX,iIAAiI;SAClI,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;CACD,CAAC","sourcesContent":["import type { PolicyFailure, RepoPolicy } from \"../policy.js\";\n\n/**\n * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be\n * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This\n * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS\n * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated\n * like an ESM file.\n *\n * @alpha\n */\nexport const NoJsFileExtensions: RepoPolicy = {\n\tname: \"NoJsFileExtensions\",\n\tmatch: /(^|\\/)[^/]+\\.js$/i,\n\t// biome-ignore lint/suspicious/useAwait: <explanation>\n\thandler: async ({ file }) => {\n\t\t// Any match is considered a failure.\n\t\tconst result: PolicyFailure = {\n\t\t\tname: NoJsFileExtensions.name,\n\t\t\tfile,\n\t\t\tautoFixable: false,\n\t\t\terrorMessage:\n\t\t\t\t\"JavaScript files should have a .cjs or .mjs file extension based on the module format of the file. Rename the file accordingly.\",\n\t\t};\n\t\treturn result;\n\t},\n};\n"]}
@@ -1,8 +1,4 @@
1
- import type { RepoPolicy } from "../policy.js";
2
- /**
3
- * @alpha
4
- */
5
- export type PackageJsonProperty = string;
1
+ import type { PackageJson } from "type-fest";
6
2
  /**
7
3
  * Policy settings for the PackageJsonProperties repo policy.
8
4
  *
@@ -10,12 +6,14 @@ export type PackageJsonProperty = string;
10
6
  */
11
7
  export interface PackageJsonPropertiesSettings {
12
8
  /**
13
- * Sets a package.json property to the string value provided. The string value will be used verbatim.
9
+ * Sets a package.json property to the value provided. The value will be used verbatim.
14
10
  */
15
- verbatim: Record<PackageJsonProperty, string>;
11
+ verbatim: PackageJson;
16
12
  }
17
13
  /**
18
14
  * A RepoPolicy that checks that package.json properties in packages match expected values.
15
+ *
16
+ * @alpha
19
17
  */
20
- export declare const PackageJsonProperties: RepoPolicy<PackageJsonPropertiesSettings>;
18
+ export declare const PackageJsonProperties: import("../policy.js").RepoPolicy<PackageJsonPropertiesSettings | undefined>;
21
19
  //# sourceMappingURL=PackageJsonProperties.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PackageJsonProperties.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAkC,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;CAC9C;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,UAAU,CAAC,6BAA6B,CAkD1E,CAAC"}
1
+ {"version":3,"file":"PackageJsonProperties.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAM7C;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,QAAQ,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,8EA4ChC,CAAC"}
@@ -1,46 +1,43 @@
1
+ import { defu } from "defu";
1
2
  import jsonfile from "jsonfile";
2
- const { writeFile: writeJson, readFile: readJson } = jsonfile;
3
+ import diff from "microdiff";
4
+ import { generatePackagePolicy } from "../policyGenerators/generatePackagePolicy.js";
5
+ const { writeFile: writeJson } = jsonfile;
3
6
  /**
4
7
  * A RepoPolicy that checks that package.json properties in packages match expected values.
8
+ *
9
+ * @alpha
5
10
  */
6
- export const PackageJsonProperties = {
7
- name: "PackageJsonProperties",
8
- match: /(^|\/)package\.json/i,
9
- handler: async ({ file, config, resolve }) => {
10
- if (config === undefined) {
11
- return true;
12
- }
13
- const failResult = {
14
- name: PackageJsonProperties.name,
15
- file,
16
- autoFixable: true,
17
- };
18
- const { verbatim } = config;
19
- const json = (await readJson(file));
20
- const messages = [];
21
- for (const [propName, value] of Object.entries(verbatim)) {
22
- if (json[propName] !== value) {
23
- messages.push(`Incorrect package.json field value for '${propName}'. Expected '${value}', got '${json[propName]}'.`);
24
- }
25
- }
26
- if (messages.length > 0) {
27
- if (resolve) {
28
- const fixResult = {
29
- ...failResult,
30
- resolved: false,
31
- };
32
- for (const [propName, value] of Object.entries(verbatim)) {
33
- json[propName] = value;
34
- }
35
- await writeJson(file, json, { spaces: "\t" });
36
- fixResult.resolved = true;
37
- return fixResult;
38
- }
39
- // There were errors, and we're not resolving them, so return a fail result
40
- failResult.errorMessage = messages.join("\n");
41
- return failResult;
42
- }
11
+ export const PackageJsonProperties = generatePackagePolicy("PackageJsonProperties", async (json, { file, config, resolve }) => {
12
+ if (config === undefined) {
43
13
  return true;
44
- },
45
- };
14
+ }
15
+ const { verbatim } = config;
16
+ const failResult = {
17
+ name: PackageJsonProperties.name,
18
+ file,
19
+ autoFixable: true,
20
+ };
21
+ const merged = defu(json, verbatim);
22
+ const result = diff(merged, json);
23
+ const messages = [];
24
+ for (const diffResult of result) {
25
+ messages.push(`Incorrect package.json field value for '${diffResult.path}'.`);
26
+ }
27
+ if (messages.length > 0) {
28
+ if (resolve) {
29
+ const fixResult = {
30
+ ...failResult,
31
+ resolved: false,
32
+ };
33
+ await writeJson(file, merged, { spaces: "\t" });
34
+ fixResult.resolved = true;
35
+ return fixResult;
36
+ }
37
+ // There were errors, and we're not resolving them, so return a fail result
38
+ failResult.errorMessage = messages.join("\n");
39
+ return failResult;
40
+ }
41
+ return true;
42
+ });
46
43
  //# sourceMappingURL=PackageJsonProperties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PackageJsonProperties.js","sourceRoot":"","sources":["../../src/policies/PackageJsonProperties.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;AAqB9D;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GACjC;IACC,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QAC5C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,UAAU,GAAkB;YACjC,IAAI,EAAE,qBAAqB,CAAC,IAAI;YAChC,IAAI;YACJ,WAAW,EAAE,IAAI;SACjB,CAAC;QAEF,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QAC5B,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAgB,CAAC;QACnD,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1D,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;gBAC9B,QAAQ,CAAC,IAAI,CACZ,2CAA2C,QAAQ,gBAAgB,KAAK,WAAW,IAAI,CAAC,QAAQ,CAAC,IAAI,CACrG,CAAC;YACH,CAAC;QACF,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,OAAO,EAAE,CAAC;gBACb,MAAM,SAAS,GAAoB;oBAClC,GAAG,UAAU;oBACb,QAAQ,EAAE,KAAK;iBACf,CAAC;gBAEF,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC1D,IAAI,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;gBACxB,CAAC;gBACD,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBAE9C,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;gBAC1B,OAAO,SAAS,CAAC;YAClB,CAAC;YAED,2EAA2E;YAC3E,UAAU,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9C,OAAO,UAAU,CAAC;QACnB,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC","sourcesContent":["import type { PackageJson } from \"type-fest\";\n\nimport jsonfile from \"jsonfile\";\nconst { writeFile: writeJson, readFile: readJson } = jsonfile;\n\nimport type { PolicyFailure, PolicyFixResult, RepoPolicy } from \"../policy.js\";\n\n/**\n * @alpha\n */\nexport type PackageJsonProperty = string;\n\n/**\n * Policy settings for the PackageJsonProperties repo policy.\n *\n * @alpha\n */\nexport interface PackageJsonPropertiesSettings {\n\t/**\n\t * Sets a package.json property to the string value provided. The string value will be used verbatim.\n\t */\n\tverbatim: Record<PackageJsonProperty, string>;\n}\n\n/**\n * A RepoPolicy that checks that package.json properties in packages match expected values.\n */\nexport const PackageJsonProperties: RepoPolicy<PackageJsonPropertiesSettings> =\n\t{\n\t\tname: \"PackageJsonProperties\",\n\t\tmatch: /(^|\\/)package\\.json/i,\n\t\thandler: async ({ file, config, resolve }) => {\n\t\t\tif (config === undefined) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst failResult: PolicyFailure = {\n\t\t\t\tname: PackageJsonProperties.name,\n\t\t\t\tfile,\n\t\t\t\tautoFixable: true,\n\t\t\t};\n\n\t\t\tconst { verbatim } = config;\n\t\t\tconst json = (await readJson(file)) as PackageJson;\n\t\t\tconst messages: string[] = [];\n\n\t\t\tfor (const [propName, value] of Object.entries(verbatim)) {\n\t\t\t\tif (json[propName] !== value) {\n\t\t\t\t\tmessages.push(\n\t\t\t\t\t\t`Incorrect package.json field value for '${propName}'. Expected '${value}', got '${json[propName]}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (messages.length > 0) {\n\t\t\t\tif (resolve) {\n\t\t\t\t\tconst fixResult: PolicyFixResult = {\n\t\t\t\t\t\t...failResult,\n\t\t\t\t\t\tresolved: false,\n\t\t\t\t\t};\n\n\t\t\t\t\tfor (const [propName, value] of Object.entries(verbatim)) {\n\t\t\t\t\t\tjson[propName] = value;\n\t\t\t\t\t}\n\t\t\t\t\tawait writeJson(file, json, { spaces: \"\\t\" });\n\n\t\t\t\t\tfixResult.resolved = true;\n\t\t\t\t\treturn fixResult;\n\t\t\t\t}\n\n\t\t\t\t// There were errors, and we're not resolving them, so return a fail result\n\t\t\t\tfailResult.errorMessage = messages.join(\"\\n\");\n\t\t\t\treturn failResult;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\t};\n"]}
1
+ {"version":3,"file":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AE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAEhD,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC1B,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,2EAA2E;QAC3E,UAAU,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC,CAAC","sourcesContent":["import { defu } from \"defu\";\nimport jsonfile from \"jsonfile\";\nimport diff from \"microdiff\";\nimport type { PackageJson } from \"type-fest\";\nimport type { PolicyFailure, PolicyFixResult } from \"../policy.js\";\nimport { generatePackagePolicy } from \"../policyGenerators/generatePackagePolicy.js\";\n\nconst { writeFile: writeJson } = jsonfile;\n\n/**\n * Policy settings for the PackageJsonProperties repo policy.\n *\n * @alpha\n */\nexport interface PackageJsonPropertiesSettings {\n\t/**\n\t * Sets a package.json property to the value provided. The value will be used verbatim.\n\t */\n\tverbatim: PackageJson;\n}\n\n/**\n * A RepoPolicy that checks that package.json properties in packages match expected values.\n *\n * @alpha\n */\nexport const PackageJsonProperties = generatePackagePolicy<\n\tPackageJson,\n\tPackageJsonPropertiesSettings | undefined\n>(\"PackageJsonProperties\", async (json, { file, config, resolve }) => {\n\tif (config === undefined) {\n\t\treturn true;\n\t}\n\tconst { verbatim } = config;\n\n\tconst failResult: PolicyFailure = {\n\t\tname: PackageJsonProperties.name,\n\t\tfile,\n\t\tautoFixable: true,\n\t};\n\n\tconst merged = defu(json, verbatim);\n\tconst result = diff(merged, json);\n\n\tconst messages: string[] = [];\n\tfor (const diffResult of result) {\n\t\tmessages.push(\n\t\t\t`Incorrect package.json field value for '${diffResult.path}'.`,\n\t\t);\n\t}\n\n\tif (messages.length > 0) {\n\t\tif (resolve) {\n\t\t\tconst fixResult: PolicyFixResult = {\n\t\t\t\t...failResult,\n\t\t\t\tresolved: false,\n\t\t\t};\n\n\t\t\tawait writeJson(file, merged, { spaces: \"\\t\" });\n\n\t\t\tfixResult.resolved = true;\n\t\t\treturn fixResult;\n\t\t}\n\n\t\t// There were errors, and we're not resolving them, so return a fail result\n\t\tfailResult.errorMessage = messages.join(\"\\n\");\n\t\treturn failResult;\n\t}\n\n\treturn true;\n});\n"]}
@@ -1,7 +1,8 @@
1
- import type { RepoPolicy } from "../policy.js";
2
1
  /**
3
2
  * A RepoPolicy that checks that the repository.directory property in package.json is set correctly. If the repository
4
3
  * field is a string instead of an object the package will be ignored.
4
+ *
5
+ * @alpha
5
6
  */
6
- export declare const PackageJsonRepoDirectoryProperty: RepoPolicy;
7
+ export declare const PackageJsonRepoDirectoryProperty: import("../policy.js").RepoPolicy<undefined>;
7
8
  //# sourceMappingURL=PackageJsonRepoDirectoryProperty.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PackageJsonRepoDirectoryProperty.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAkC,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,gCAAgC,EAAE,UA2C9C,CAAC"}
1
+ {"version":3,"file":"PackageJsonRepoDirectoryProperty.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,8CA+C3C,CAAC"}
@@ -1,49 +1,52 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { updatePackageJsonFile } from "@fluid-tools/build-infrastructure";
3
3
  import path from "pathe";
4
- import jsonfile from "jsonfile";
5
- const { readFile: readJson } = jsonfile;
4
+ import { generatePackagePolicy } from "../policyGenerators/generatePackagePolicy.js";
6
5
  /**
7
6
  * A RepoPolicy that checks that the repository.directory property in package.json is set correctly. If the repository
8
7
  * field is a string instead of an object the package will be ignored.
8
+ *
9
+ * @alpha
9
10
  */
10
- export const PackageJsonRepoDirectoryProperty = {
11
- name: "PackageJsonRepoDirectoryProperty",
12
- match: /(^|\/)package\.json/i,
13
- handler: async ({ file, root, resolve }) => {
14
- const failResult = {
15
- name: PackageJsonRepoDirectoryProperty.name,
16
- file,
17
- autoFixable: true,
18
- };
19
- const fixResult = {
20
- ...failResult,
21
- resolved: false,
22
- };
23
- const pkg = (await readJson(file));
24
- const pkgDir = path.dirname(file);
25
- const relativePkgDir = path.relative(root, pkgDir);
26
- if (typeof pkg.repository === "object") {
27
- if (pkg.repository.directory !== relativePkgDir) {
28
- if (resolve) {
29
- try {
30
- updatePackageJsonFile(file, (json) => {
31
- assert(typeof json.repository === "object");
11
+ export const PackageJsonRepoDirectoryProperty = generatePackagePolicy("PackageJsonRepoDirectoryProperty", async (json, { file, root, resolve }) => {
12
+ const failResult = {
13
+ name: PackageJsonRepoDirectoryProperty.name,
14
+ file,
15
+ autoFixable: true,
16
+ };
17
+ const fixResult = {
18
+ ...failResult,
19
+ resolved: false,
20
+ };
21
+ const pkgDir = path.dirname(file);
22
+ const maybeDir = path.relative(root, pkgDir);
23
+ const relativePkgDir = maybeDir === "" ? undefined : maybeDir;
24
+ if (typeof json.repository === "object") {
25
+ if (json.repository.directory !== relativePkgDir) {
26
+ if (resolve) {
27
+ try {
28
+ updatePackageJsonFile(file, (json) => {
29
+ assert(typeof json.repository === "object");
30
+ if (relativePkgDir === undefined) {
31
+ // biome-ignore lint/performance/noDelete: <explanation>
32
+ delete json.repository.directory;
33
+ }
34
+ else {
32
35
  json.repository.directory = relativePkgDir;
33
- });
34
- fixResult.resolved = true;
35
- }
36
- catch (error) {
37
- fixResult.resolved = false;
38
- fixResult.errorMessage = `${error.message}\n${error.stack}`;
39
- }
40
- return fixResult;
36
+ }
37
+ });
38
+ fixResult.resolved = true;
41
39
  }
42
- failResult.errorMessage = `repository.directory value is wrong. Expected '${relativePkgDir}', got '${pkg.repository.directory}'`;
43
- return failResult;
40
+ catch (error) {
41
+ fixResult.resolved = false;
42
+ fixResult.errorMessage = `${error.message}\n${error.stack}`;
43
+ }
44
+ return fixResult;
44
45
  }
46
+ failResult.errorMessage = `repository.directory value is wrong. Expected '${relativePkgDir}', got '${json.repository.directory}'`;
47
+ return failResult;
45
48
  }
46
- return true;
47
- },
48
- };
49
+ }
50
+ return true;
51
+ });
49
52
  //# sourceMappingURL=PackageJsonRepoDirectoryProperty.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PackageJsonRepoDirectoryProperty.js","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,IAAI,MAAM,OAAO,CAAC;AAGzB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;AAIxC;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAe;IAC3D,IAAI,EAAE,kCAAkC;IACxC,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1C,MAAM,UAAU,GAAkB;YACjC,IAAI,EAAE,gCAAgC,CAAC,IAAI;YAC3C,IAAI;YACJ,WAAW,EAAE,IAAI;SACjB,CAAC;QAEF,MAAM,SAAS,GAAoB;YAClC,GAAG,UAAU;YACb,QAAQ,EAAE,KAAK;SACf,CAAC;QAEF,MAAM,GAAG,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAgB,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEnD,IAAI,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YACxC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,KAAK,cAAc,EAAE,CAAC;gBACjD,IAAI,OAAO,EAAE,CAAC;oBACb,IAAI,CAAC;wBACJ,qBAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;4BACpC,MAAM,CAAC,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC;4BAC5C,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,cAAc,CAAC;wBAC5C,CAAC,CAAC,CAAC;wBACH,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;oBAC3B,CAAC;oBAAC,OAAO,KAAc,EAAE,CAAC;wBACzB,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC;wBAC3B,SAAS,CAAC,YAAY,GAAG,GAAI,KAAe,CAAC,OAAO,KAClD,KAAe,CAAC,KAClB,EAAE,CAAC;oBACJ,CAAC;oBACD,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,UAAU,CAAC,YAAY,GAAG,kDAAkD,cAAc,WAAW,GAAG,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC;gBACjI,OAAO,UAAU,CAAC;YACnB,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { updatePackageJsonFile } from \"@fluid-tools/build-infrastructure\";\nimport path from \"pathe\";\nimport type { PackageJson } from \"type-fest\";\n\nimport jsonfile from \"jsonfile\";\nconst { readFile: readJson } = jsonfile;\n\nimport type { PolicyFailure, PolicyFixResult, RepoPolicy } from \"../policy.js\";\n\n/**\n * A RepoPolicy that checks that the repository.directory property in package.json is set correctly. If the repository\n * field is a string instead of an object the package will be ignored.\n */\nexport const PackageJsonRepoDirectoryProperty: RepoPolicy = {\n\tname: \"PackageJsonRepoDirectoryProperty\",\n\tmatch: /(^|\\/)package\\.json/i,\n\thandler: async ({ file, root, resolve }) => {\n\t\tconst failResult: PolicyFailure = {\n\t\t\tname: PackageJsonRepoDirectoryProperty.name,\n\t\t\tfile,\n\t\t\tautoFixable: true,\n\t\t};\n\n\t\tconst fixResult: PolicyFixResult = {\n\t\t\t...failResult,\n\t\t\tresolved: false,\n\t\t};\n\n\t\tconst pkg = (await readJson(file)) as PackageJson;\n\t\tconst pkgDir = path.dirname(file);\n\t\tconst relativePkgDir = path.relative(root, pkgDir);\n\n\t\tif (typeof pkg.repository === \"object\") {\n\t\t\tif (pkg.repository.directory !== relativePkgDir) {\n\t\t\t\tif (resolve) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tupdatePackageJsonFile(file, (json) => {\n\t\t\t\t\t\t\tassert(typeof json.repository === \"object\");\n\t\t\t\t\t\t\tjson.repository.directory = relativePkgDir;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfixResult.resolved = true;\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tfixResult.resolved = false;\n\t\t\t\t\t\tfixResult.errorMessage = `${(error as Error).message}\\n${\n\t\t\t\t\t\t\t(error as Error).stack\n\t\t\t\t\t\t}`;\n\t\t\t\t\t}\n\t\t\t\t\treturn fixResult;\n\t\t\t\t}\n\t\t\t\tfailResult.errorMessage = `repository.directory value is wrong. Expected '${relativePkgDir}', got '${pkg.repository.directory}'`;\n\t\t\t\treturn failResult;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t},\n};\n"]}
1
+ {"version":3,"file":"PackageJsonRepoDirectoryProperty.js","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,IAAI,MAAM,OAAO,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,qBA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AY,GAAG,GAAI,KAAe,CAAC,OAAO,KAClD,KAAe,CAAC,KAClB,EAAE,CAAC;gBACJ,CAAC;gBACD,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,UAAU,CAAC,YAAY,GAAG,kDAAkD,cAAc,WAAW,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC;YAClI,OAAO,UAAU,CAAC;QACnB,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { updatePackageJsonFile } from \"@fluid-tools/build-infrastructure\";\nimport path from \"pathe\";\nimport type { PackageJson } from \"type-fest\";\nimport type { PolicyFailure, PolicyFixResult } from \"../policy.js\";\nimport { generatePackagePolicy } from \"../policyGenerators/generatePackagePolicy.js\";\n\n/**\n * A RepoPolicy that checks that the repository.directory property in package.json is set correctly. If the repository\n * field is a string instead of an object the package will be ignored.\n *\n * @alpha\n */\nexport const PackageJsonRepoDirectoryProperty = generatePackagePolicy<\n\tPackageJson,\n\tundefined\n>(\"PackageJsonRepoDirectoryProperty\", async (json, { file, root, resolve }) => {\n\tconst failResult: PolicyFailure = {\n\t\tname: PackageJsonRepoDirectoryProperty.name,\n\t\tfile,\n\t\tautoFixable: true,\n\t};\n\n\tconst fixResult: PolicyFixResult = {\n\t\t...failResult,\n\t\tresolved: false,\n\t};\n\n\tconst pkgDir = path.dirname(file);\n\tconst maybeDir = path.relative(root, pkgDir);\n\tconst relativePkgDir = maybeDir === \"\" ? undefined : maybeDir;\n\n\tif (typeof json.repository === \"object\") {\n\t\tif (json.repository.directory !== relativePkgDir) {\n\t\t\tif (resolve) {\n\t\t\t\ttry {\n\t\t\t\t\tupdatePackageJsonFile(file, (json) => {\n\t\t\t\t\t\tassert(typeof json.repository === \"object\");\n\t\t\t\t\t\tif (relativePkgDir === undefined) {\n\t\t\t\t\t\t\t// biome-ignore lint/performance/noDelete: <explanation>\n\t\t\t\t\t\t\tdelete json.repository.directory;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tjson.repository.directory = relativePkgDir;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tfixResult.resolved = true;\n\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\tfixResult.resolved = false;\n\t\t\t\t\tfixResult.errorMessage = `${(error as Error).message}\\n${\n\t\t\t\t\t\t(error as Error).stack\n\t\t\t\t\t}`;\n\t\t\t\t}\n\t\t\t\treturn fixResult;\n\t\t\t}\n\t\t\tfailResult.errorMessage = `repository.directory value is wrong. Expected '${relativePkgDir}', got '${json.repository.directory}'`;\n\t\t\treturn failResult;\n\t\t}\n\t}\n\n\treturn true;\n});\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A repo policy that checks if package.json files in the repo are sorted using sort-package-json.
3
+ *
4
+ * @alpha
5
+ */
6
+ export declare const PackageJsonSorted: import("../policy.js").RepoPolicy<undefined>;
7
+ //# sourceMappingURL=PackageJsonSorted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageJsonSorted.d.ts","sourceRoot":"","sources":["../../src/policies/PackageJsonSorted.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,8CAsC7B,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { updatePackageJsonFile } from "@tylerbu/cli-api";
2
+ import { sortPackageJson } from "sort-package-json";
3
+ import { generatePackagePolicy } from "../policyGenerators/generatePackagePolicy.js";
4
+ /**
5
+ * A repo policy that checks if package.json files in the repo are sorted using sort-package-json.
6
+ *
7
+ * @alpha
8
+ */
9
+ export const PackageJsonSorted = generatePackagePolicy("PackageJsonSorted", async (json, { file, resolve }) => {
10
+ const sortedJson = sortPackageJson(json);
11
+ const isSorted = JSON.stringify(sortedJson) === JSON.stringify(json);
12
+ if (isSorted) {
13
+ return true;
14
+ }
15
+ if (resolve) {
16
+ try {
17
+ await updatePackageJsonFile(file, (json) => json, { sort: true });
18
+ const result = {
19
+ name: PackageJsonSorted.name,
20
+ file,
21
+ resolved: true,
22
+ };
23
+ return result;
24
+ }
25
+ catch (error) {
26
+ const result = {
27
+ name: PackageJsonSorted.name,
28
+ file,
29
+ resolved: false,
30
+ autoFixable: true,
31
+ errorMessage: error.message,
32
+ };
33
+ return result;
34
+ }
35
+ }
36
+ else {
37
+ const result = {
38
+ name: PackageJsonSorted.name,
39
+ file,
40
+ autoFixable: true,
41
+ };
42
+ return result;
43
+ }
44
+ });
45
+ //# sourceMappingURL=PackageJsonSorted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageJsonSorted.js","sourceRoot":"","sources":["../../src/policies/PackageJsonSorted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CACrD,mBAAmB,EACnB,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IACjC,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAErE,IAAI,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACb,IAAI,CAAC;YACJ,MAAM,qBAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAClE,MAAM,MAAM,GAAoB;gBAC/B,IAAI,EAAE,iBAAiB,CAAC,IAAI;gBAC5B,IAAI;gBACJ,QAAQ,EAAE,IAAI;aACd,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACzB,MAAM,MAAM,GAAoB;gBAC/B,IAAI,EAAE,iBAAiB,CAAC,IAAI;gBAC5B,IAAI;gBACJ,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,IAAI;gBACjB,YAAY,EAAG,KAAe,CAAC,OAAO;aACtC,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;IACF,CAAC;SAAM,CAAC;QACP,MAAM,MAAM,GAAkB;YAC7B,IAAI,EAAE,iBAAiB,CAAC,IAAI;YAC5B,IAAI;YACJ,WAAW,EAAE,IAAI;SACjB,CAAC;QACF,OAAO,MAAM,CAAC;IACf,CAAC;AACF,CAAC,CACD,CAAC","sourcesContent":["import { updatePackageJsonFile } from \"@tylerbu/cli-api\";\nimport { sortPackageJson } from \"sort-package-json\";\nimport type { PolicyFailure, PolicyFixResult } from \"../policy.js\";\nimport { generatePackagePolicy } from \"../policyGenerators/generatePackagePolicy.js\";\n\n/**\n * A repo policy that checks if package.json files in the repo are sorted using sort-package-json.\n *\n * @alpha\n */\nexport const PackageJsonSorted = generatePackagePolicy(\n\t\"PackageJsonSorted\",\n\tasync (json, { file, resolve }) => {\n\t\tconst sortedJson = sortPackageJson(json);\n\t\tconst isSorted = JSON.stringify(sortedJson) === JSON.stringify(json);\n\n\t\tif (isSorted) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (resolve) {\n\t\t\ttry {\n\t\t\t\tawait updatePackageJsonFile(file, (json) => json, { sort: true });\n\t\t\t\tconst result: PolicyFixResult = {\n\t\t\t\t\tname: PackageJsonSorted.name,\n\t\t\t\t\tfile,\n\t\t\t\t\tresolved: true,\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t} catch (error: unknown) {\n\t\t\t\tconst result: PolicyFixResult = {\n\t\t\t\t\tname: PackageJsonSorted.name,\n\t\t\t\t\tfile,\n\t\t\t\t\tresolved: false,\n\t\t\t\t\tautoFixable: true,\n\t\t\t\t\terrorMessage: (error as Error).message,\n\t\t\t\t};\n\t\t\t\treturn result;\n\t\t\t}\n\t\t} else {\n\t\t\tconst result: PolicyFailure = {\n\t\t\t\tname: PackageJsonSorted.name,\n\t\t\t\tfile,\n\t\t\t\tautoFixable: true,\n\t\t\t};\n\t\t\treturn result;\n\t\t}\n\t},\n);\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A RepoPolicy that checks that package.json properties in packages match expected values.
3
+ *
4
+ * @alpha
5
+ */
6
+ export declare const PackageScripts: import("../policy.js").RepoPolicy<undefined>;
7
+ //# sourceMappingURL=PackageScripts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageScripts.d.ts","sourceRoot":"","sources":["../../src/policies/PackageScripts.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,cAAc,8CA+B1B,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { generatePackagePolicy } from "../policyGenerators/generatePackagePolicy.js";
2
+ const expectedScripts = ["build", "clean"];
3
+ /**
4
+ * A RepoPolicy that checks that package.json properties in packages match expected values.
5
+ *
6
+ * @alpha
7
+ */
8
+ export const PackageScripts = generatePackagePolicy("PackageScripts", async (json, { file }) => {
9
+ const failResult = {
10
+ name: PackageScripts.name,
11
+ file,
12
+ autoFixable: false,
13
+ };
14
+ const hasScriptsField = Object.prototype.hasOwnProperty.call(json, "scripts");
15
+ const missingScripts = [];
16
+ if (hasScriptsField) {
17
+ missingScripts.push(...expectedScripts.filter((script) => !Object.prototype.hasOwnProperty.call(json.scripts, script)));
18
+ }
19
+ if (missingScripts.length > 0) {
20
+ failResult.errorMessage = `missing the following scripts: \n\t${missingScripts.join("\n\t")}`;
21
+ return failResult;
22
+ }
23
+ return true;
24
+ });
25
+ //# sourceMappingURL=PackageScripts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageScripts.js","sourceRoot":"","sources":["../../src/policies/PackageScripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAClD,gBAAgB,EAChB,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IACxB,MAAM,UAAU,GAAkB;QACjC,IAAI,EAAE,cAAc,CAAC,IAAI;QACzB,IAAI;QACJ,WAAW,EAAE,KAAK;KAClB,CAAC;IAEF,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAC3D,IAAI,EACJ,SAAS,CACT,CAAC;IAEF,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,IAAI,eAAe,EAAE,CAAC;QACrB,cAAc,CAAC,IAAI,CAClB,GAAG,eAAe,CAAC,MAAM,CACxB,CAAC,MAAM,EAAE,EAAE,CACV,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAC5D,CACD,CAAC;IACH,CAAC;IAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,UAAU,CAAC,YAAY,GAAG,sCAAsC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9F,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC,CACD,CAAC","sourcesContent":["import type { PolicyFailure } from \"../policy.js\";\nimport { generatePackagePolicy } from \"../policyGenerators/generatePackagePolicy.js\";\n\nconst expectedScripts = [\"build\", \"clean\"] as const;\n\n/**\n * A RepoPolicy that checks that package.json properties in packages match expected values.\n *\n * @alpha\n */\nexport const PackageScripts = generatePackagePolicy(\n\t\"PackageScripts\",\n\tasync (json, { file }) => {\n\t\tconst failResult: PolicyFailure = {\n\t\t\tname: PackageScripts.name,\n\t\t\tfile,\n\t\t\tautoFixable: false,\n\t\t};\n\n\t\tconst hasScriptsField = Object.prototype.hasOwnProperty.call(\n\t\t\tjson,\n\t\t\t\"scripts\",\n\t\t);\n\n\t\tconst missingScripts: string[] = [];\n\t\tif (hasScriptsField) {\n\t\t\tmissingScripts.push(\n\t\t\t\t...expectedScripts.filter(\n\t\t\t\t\t(script) =>\n\t\t\t\t\t\t!Object.prototype.hasOwnProperty.call(json.scripts, script),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (missingScripts.length > 0) {\n\t\t\tfailResult.errorMessage = `missing the following scripts: \\n\\t${missingScripts.join(\"\\n\\t\")}`;\n\t\t\treturn failResult;\n\t\t}\n\n\t\treturn true;\n\t},\n);\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A regular expression that matches package.json files in path strings.
3
+ */
4
+ export declare const PackageJsonRegexMatch: RegExp;
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/policies/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A regular expression that matches package.json files in path strings.
3
+ */
4
+ export const PackageJsonRegexMatch = /(^|\/)package\.json/i;
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/policies/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC","sourcesContent":["/**\n * A regular expression that matches package.json files in path strings.\n */\nexport const PackageJsonRegexMatch = /(^|\\/)package\\.json/i;\n"]}
@@ -0,0 +1,7 @@
1
+ export { PackageJsonProperties } from "./policies/PackageJsonProperties.js";
2
+ export { NoJsFileExtensions } from "./policies/NoJsFileExtensions.js";
3
+ export { PackageJsonRepoDirectoryProperty } from "./policies/PackageJsonRepoDirectoryProperty.js";
4
+ export { PackageJsonSorted } from "./policies/PackageJsonSorted.js";
5
+ export { JsTsFileHeaders } from "./policies/JsTsFileHeaders.js";
6
+ export { HtmlFileHeaders } from "./policies/HtmlFileHeaders.js";
7
+ //# sourceMappingURL=policies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { PackageJsonProperties } from "./policies/PackageJsonProperties.js";
2
+ export { NoJsFileExtensions } from "./policies/NoJsFileExtensions.js";
3
+ export { PackageJsonRepoDirectoryProperty } from "./policies/PackageJsonRepoDirectoryProperty.js";
4
+ export { PackageJsonSorted } from "./policies/PackageJsonSorted.js";
5
+ export { JsTsFileHeaders } from "./policies/JsTsFileHeaders.js";
6
+ export { HtmlFileHeaders } from "./policies/HtmlFileHeaders.js";
7
+ //# sourceMappingURL=policies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policies.js","sourceRoot":"","sources":["../src/policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["export { PackageJsonProperties } from \"./policies/PackageJsonProperties.js\";\nexport { NoJsFileExtensions } from \"./policies/NoJsFileExtensions.js\";\nexport { PackageJsonRepoDirectoryProperty } from \"./policies/PackageJsonRepoDirectoryProperty.js\";\nexport { PackageJsonSorted } from \"./policies/PackageJsonSorted.js\";\nexport { JsTsFileHeaders } from \"./policies/JsTsFileHeaders.js\";\nexport { HtmlFileHeaders } from \"./policies/HtmlFileHeaders.js\";\n"]}
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 = unknown | undefined> {
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
- config?: C;
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 = unknown | undefined> = (args: Omit<PolicyFunctionArguments<C>, "resolve">) => PolicyFixResult;
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 = any | undefined> {
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
- export declare class RepoPolicyClass implements RepoPolicy {
73
- readonly name: string;
74
- readonly match: RegExp;
75
- handler: PolicyHandler;
76
- resolver?: PolicyStandaloneResolver | undefined;
77
- static createRepoPolicy(name: string, match: RegExp, handler: PolicyHandler, resolver?: PolicyStandaloneResolver): RepoPolicyClass;
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
@@ -1 +1 @@
1
- {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,uBAAuB,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