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.
Files changed (92) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +37 -18
  3. package/THIRD-PARTY-LICENSES.txt +134 -36
  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 +81 -89
  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 +42 -39
  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 +43 -23
  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
@@ -1,49 +0,0 @@
1
- import { updatePackageJsonFile } from "@tylerbu/cli-api";
2
- import { sortPackageJson } from "sort-package-json";
3
- import jsonfile from "jsonfile";
4
- const { readFile: readJson } = jsonfile;
5
- /**
6
- * A repo policy that checks if package.json files in the repo are sorted using sort-package-json.
7
- */
8
- export const PackageJsonSortedPolicy = {
9
- name: "PackageJsonSortedPolicy",
10
- match: /(^|\/)package\.json/i,
11
- handler: async ({ file, resolve }) => {
12
- const json = await readJson(file);
13
- const sortedJson = sortPackageJson(json);
14
- const isSorted = JSON.stringify(sortedJson) === JSON.stringify(json);
15
- if (isSorted) {
16
- return true;
17
- }
18
- if (resolve) {
19
- try {
20
- await updatePackageJsonFile(file, (json) => json, { sort: true });
21
- const result = {
22
- name: PackageJsonSortedPolicy.name,
23
- file,
24
- resolved: true,
25
- };
26
- return result;
27
- }
28
- catch (error) {
29
- const result = {
30
- name: PackageJsonSortedPolicy.name,
31
- file,
32
- resolved: false,
33
- autoFixable: true,
34
- errorMessage: error.message,
35
- };
36
- return result;
37
- }
38
- }
39
- else {
40
- const result = {
41
- name: PackageJsonSortedPolicy.name,
42
- file,
43
- autoFixable: true,
44
- };
45
- return result;
46
- }
47
- },
48
- };
49
- //# sourceMappingURL=PackageJsonSortedPolicy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PackageJsonSortedPolicy.js","sourceRoot":"","sources":["../../src/policies/PackageJsonSortedPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;AAIxC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAe;IAClD,IAAI,EAAE,yBAAyB;IAC/B,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QACpC,MAAM,IAAI,GAAgB,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAErE,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;QACb,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC;gBACJ,MAAM,qBAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBAClE,MAAM,MAAM,GAAoB;oBAC/B,IAAI,EAAE,uBAAuB,CAAC,IAAI;oBAClC,IAAI;oBACJ,QAAQ,EAAE,IAAI;iBACd,CAAC;gBACF,OAAO,MAAM,CAAC;YACf,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACzB,MAAM,MAAM,GAAoB;oBAC/B,IAAI,EAAE,uBAAuB,CAAC,IAAI;oBAClC,IAAI;oBACJ,QAAQ,EAAE,KAAK;oBACf,WAAW,EAAE,IAAI;oBACjB,YAAY,EAAG,KAAe,CAAC,OAAO;iBACtC,CAAC;gBACF,OAAO,MAAM,CAAC;YACf,CAAC;QACF,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAkB;gBAC7B,IAAI,EAAE,uBAAuB,CAAC,IAAI;gBAClC,IAAI;gBACJ,WAAW,EAAE,IAAI;aACjB,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;IACF,CAAC;CACD,CAAC","sourcesContent":["import { updatePackageJsonFile } from \"@tylerbu/cli-api\";\nimport { sortPackageJson } from \"sort-package-json\";\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 repo policy that checks if package.json files in the repo are sorted using sort-package-json.\n */\nexport const PackageJsonSortedPolicy: RepoPolicy = {\n\tname: \"PackageJsonSortedPolicy\",\n\tmatch: /(^|\\/)package\\.json/i,\n\thandler: async ({ file, resolve }) => {\n\t\tconst json: PackageJson = await readJson(file);\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: PackageJsonSortedPolicy.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: PackageJsonSortedPolicy.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: PackageJsonSortedPolicy.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"]}
@@ -1,10 +0,0 @@
1
- import type { RepoPolicy } from "../policy.js";
2
- /**
3
- * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be
4
- * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This
5
- * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS
6
- * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated
7
- * like an ESM file.
8
- */
9
- export declare const SortTsconfigs: RepoPolicy;
10
- //# sourceMappingURL=SortTsconfigs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SortTsconfigs.d.ts","sourceRoot":"","sources":["../../src/policies/SortTsconfigs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkC,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/E;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,UA2B3B,CAAC"}
@@ -1,33 +0,0 @@
1
- import { isSorted, sortTsconfigFile } from "sort-tsconfig";
2
- /**
3
- * A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be
4
- * interpreted by node as either CommonJS or ESM based on the `type` field in the nearest package.json file. This
5
- * can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS
6
- * is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn't suddenly treated
7
- * like an ESM file.
8
- */
9
- export const SortTsconfigs = {
10
- name: "SortTsconfigs",
11
- match: /(^|\/)[^/]+tsconfig\..*\.json$/i,
12
- // biome-ignore lint/suspicious/useAwait: <explanation>
13
- handler: async ({ file, config, resolve }) => {
14
- if (config === undefined) {
15
- return true;
16
- }
17
- const failResult = {
18
- name: SortTsconfigs.name,
19
- file,
20
- autoFixable: true,
21
- };
22
- if (resolve) {
23
- sortTsconfigFile(file, true);
24
- const fixResult = {
25
- ...failResult,
26
- resolved: true,
27
- };
28
- return fixResult;
29
- }
30
- return isSorted(file) === true ? true : failResult;
31
- },
32
- };
33
- //# sourceMappingURL=SortTsconfigs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SortTsconfigs.js","sourceRoot":"","sources":["../../src/policies/SortTsconfigs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG3D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAe;IACxC,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,iCAAiC;IACxC,uDAAuD;IACvD,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,aAAa,CAAC,IAAI;YACxB,IAAI;YACJ,WAAW,EAAE,IAAI;SACjB,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACb,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7B,MAAM,SAAS,GAAoB;gBAClC,GAAG,UAAU;gBACb,QAAQ,EAAE,IAAI;aACd,CAAC;YAEF,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;IACpD,CAAC;CACD,CAAC","sourcesContent":["import { isSorted, sortTsconfigFile } from \"sort-tsconfig\";\nimport type { PolicyFailure, PolicyFixResult, 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 SortTsconfigs: RepoPolicy = {\n\tname: \"SortTsconfigs\",\n\tmatch: /(^|\\/)[^/]+tsconfig\\..*\\.json$/i,\n\t// biome-ignore lint/suspicious/useAwait: <explanation>\n\thandler: async ({ file, config, resolve }) => {\n\t\tif (config === undefined) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst failResult: PolicyFailure = {\n\t\t\tname: SortTsconfigs.name,\n\t\t\tfile,\n\t\t\tautoFixable: true,\n\t\t};\n\n\t\tif (resolve) {\n\t\t\tsortTsconfigFile(file, true);\n\t\t\tconst fixResult: PolicyFixResult = {\n\t\t\t\t...failResult,\n\t\t\t\tresolved: true,\n\t\t\t};\n\n\t\t\treturn fixResult;\n\t\t}\n\n\t\treturn isSorted(file) === true ? true : failResult;\n\t},\n};\n"]}