@mark1russell7/conventions 0.12.1 → 0.12.3

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/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as runCli } from "./run-CKf71WQx.js";
2
+ import { c as runCli } from "./run-DKVHmESw.js";
3
3
  // src/cli.ts
4
4
  try {
5
5
  process.exitCode = runCli(process.argv.slice(2), {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/gate-trigger.ts","../src/rules/main-check.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/source-main.ts","../src/rules/tests-required.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-files.ts","../src/rules/typed-scripts.ts","../src/rules/trust-policy.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;WAEA,iBAAiB;;;;;;UAOX;;WAEN;;WAEA;;WAEA;;;wBAIK,YAAY,cAAc,cAAc;;KAQ5C;;KAGA,UAAU,SAAS,eAAe;;UAG7B;WACN;WACA,SAAS;WACT;;;KAIC,WAAW,SAAS;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,UAAU;;;UAIJ;;WAEN;;WAEA,aAAa;;WAEb,mBAAmB;;WAEnB,KAAK,SAAS;;WAEd;;EAET;;EAEA,IAAI;;;KAIM,uBAAuB;WAAqB;;;UAGvC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,kBAAkB;;WAElB,SAAS,SAAS,eAAe;EAC1C,MAAM,SAAS,aAAa,SAAS,UAAU;;;qBAIpC;;w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EA;;WAEA;WACA,MAAM,SAAS;;WAEf,iBAAiB;;;wBAaZ,WAAW,cAAc,iBAAgB,SAAiB;;wBAO1D,cAAc,cAAc,QAAQ,mBAAmB,UAAS,KAAK,gCAAqC;;wBAwB1G,UAAU,SAAS,eAAe;;UAoCjC;;WAEN;;WAEA;;WAEA,QAAQ;;;;;;;wBAWH,OAAO,SAAS,eAAe;;wBAyC/B,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBA0BG,OAAO,yBAAyB,IAAI;;;;;;wBC9QpC,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/gate-trigger.ts","../src/rules/main-check.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/source-main.ts","../src/rules/tests-required.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-files.ts","../src/rules/typed-scripts.ts","../src/rules/trust-policy.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;WAEA,iBAAiB;;;;;;UAOX;;WAEN;;WAEA;;WAEA;;;wBAIK,YAAY,cAAc,cAAc;;KAQ5C;;KAGA,UAAU,SAAS,eAAe;;UAG7B;WACN;WACA,SAAS;WACT;;;KAIC,WAAW,SAAS;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,UAAU;;;UA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,UACd,SAAS,SAAS,0BAClB,cACA,OAAM;qBAkRK,YAAY;qBC/VZ,cAAc;;qBC3Bd;;qBAGA;qBA6DA,aAAa;qBCnEb,mBAAmB;;qBCenB,gBAAgB;;UCXZ;WACN;WACA;WACA;;WAEA;WACA,iBAAiB;;WAEjB;;WAEA;;;UAIM;WACN,gBAAgB;;WAEhB;;;UAIM;;WAEN;;WAEA;;WAEA;WACA,MAAM,SAAS;;WAEf,iBAAiB;;;wBAaZ,WAAW,cAAc,iBAAgB,SAAiB;;wBAO1D,cAAc,cAAc,QAAQ,mBAAmB,UAAS,KAAK,gCAAqC;;wBAwB1G,UAAU,SAAS,eAAe;;UAoCjC;;WAEN;;WAEA;;WAEA,QAAQ;;;;;;;wBAWH,OAAO,SAAS,eAAe;;wBAyC/B,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBA0BG,OAAO,yBAAyB,IAAI;;;;;;wBC9QpC,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
package/build/index.js CHANGED
@@ -1 +1 @@
1
- export { U as ACTIONS_COMMIT, I as DEFAULT_ALLOWED, X as DEPENDENCY_FIELDS, L as HOME_PATTERNS, p as IGNORE_AFTER, B as REAL_COMPARE, d as RULES, J as STRICT_OPTIONS, m as TRAIN_SCOPES, t as USAGE, n as annotations, Z as cleanPath, Q as codePackages, _ as configsOfScript, W as convertGate, r as createContext, Y as cuePreset, pt as defaultOptions, i as formatResult, G as gateTrigger, lt as globFolders, ut as globToRegExp, $ as hasFile, V as hasImportMetaMain, x as hasTests, et as inFolder, N as isGitSpecifier, P as isPinned, C as isSourcePath, tt as keyLine, nt as lineOf, a as listRules, H as mainCheck, rt as matchesAny, z as noBuildOutput, R as noLocalPaths, dt as packageFolders, mt as parseConfig, it as parseJsonc, w as pathsOf, F as pinnedGitDeps, K as prPathFilters, o as readConfig, at as readJsonc, M as releaseFiles, ot as replaceLine, E as repositoryOfRemote, j as requiredScripts, k as roadmapOfLine, A as roadmapParses, s as runChecks, c as runCli, l as runFix, st as runGit, D as runnerBudget, O as scheduleMinute, v as scriptsOf, T as sourceMain, ct as specifiersOf, u as summaryMarkdown, q as summaryName, b as testsRequired, h as trustPolicy, S as tsconfigTest, y as typedFiles, g as typedScripts, ft as workspaceGlobs, f as workspaceProtocol } from "./run-CKf71WQx.js";
1
+ export { U as ACTIONS_COMMIT, I as DEFAULT_ALLOWED, X as DEPENDENCY_FIELDS, L as HOME_PATTERNS, p as IGNORE_AFTER, B as REAL_COMPARE, d as RULES, J as STRICT_OPTIONS, m as TRAIN_SCOPES, t as USAGE, n as annotations, Z as cleanPath, Q as codePackages, _ as configsOfScript, W as convertGate, r as createContext, Y as cuePreset, pt as defaultOptions, i as formatResult, G as gateTrigger, lt as globFolders, ut as globToRegExp, $ as hasFile, V as hasImportMetaMain, x as hasTests, et as inFolder, N as isGitSpecifier, P as isPinned, C as isSourcePath, tt as keyLine, nt as lineOf, a as listRules, H as mainCheck, rt as matchesAny, z as noBuildOutput, R as noLocalPaths, dt as packageFolders, mt as parseConfig, it as parseJsonc, w as pathsOf, F as pinnedGitDeps, K as prPathFilters, o as readConfig, at as readJsonc, M as releaseFiles, ot as replaceLine, E as repositoryOfRemote, j as requiredScripts, k as roadmapOfLine, A as roadmapParses, s as runChecks, c as runCli, l as runFix, st as runGit, D as runnerBudget, O as scheduleMinute, v as scriptsOf, T as sourceMain, ct as specifiersOf, u as summaryMarkdown, q as summaryName, b as testsRequired, h as trustPolicy, S as tsconfigTest, y as typedFiles, g as typedScripts, ft as workspaceGlobs, f as workspaceProtocol } from "./run-DKVHmESw.js";
@@ -1383,7 +1383,7 @@ const releaseFiles = {
1383
1383
  id: "release-files",
1384
1384
  title: "A pull request changes `.github/workflows/release.yml` or `scripts/release/` only with a `Release-Edit: <reason>` line.",
1385
1385
  reason: "The release flow publishes to npm with trusted publishing. A change of its files by a session that does not own the release can stop or break each release.",
1386
- fix: "Revert the change of the release files. When the owner asked for the change, add the line `Release-Edit: <reason>` to the last commit message or to the body of the pull request.",
1386
+ fix: "Revert the change of the release files. When the owner asked for the change, add the line `Release-Edit: <reason>` to the last commit message or to the body of the pull request. A re-run of a job reads the body of the event that started the run, so after a change of the body, push a commit.",
1387
1387
  sources: [
1388
1388
  {
1389
1389
  repo: "coeval",
@@ -3006,11 +3006,11 @@ const ROOT_DIRS = /* @__PURE__ */ new Set([
3006
3006
  "${configDir}/"
3007
3007
  ]);
3008
3008
  /**
3009
- * This function gives the `rootDir` that a tsconfig gets from the configs it extends, as an absolute path. It gives
3009
+ * This function gives the value of the compiler option `name` that a tsconfig gets from the configs it extends. It gives
3010
3010
  * `null` when no config of the chain sets it. It gives `undefined` when it cannot read a config of the chain, for example
3011
3011
  * a package that is not installed.
3012
3012
  */
3013
- function inheritedRootDir(tsconfig, leaf = tsconfig, seen = /* @__PURE__ */ new Set()) {
3013
+ function inheritedOption(tsconfig, name, seen = /* @__PURE__ */ new Set()) {
3014
3014
  const json = readJsonc(tsconfig);
3015
3015
  if (json === void 0 || seen.has(tsconfig)) return void 0;
3016
3016
  const specs = Array.isArray(json.extends) ? json.extends : json.extends === void 0 ? [] : [json.extends];
@@ -3026,14 +3026,29 @@ function inheritedRootDir(tsconfig, leaf = tsconfig, seen = /* @__PURE__ */ new
3026
3026
  if (!existsSync(file) && existsSync(`${file}.json`)) file = `${file}.json`;
3027
3027
  const parent = readJsonc(file);
3028
3028
  if (parent === void 0) return void 0;
3029
- const own = parent.compilerOptions?.rootDir;
3030
- const rootDir = typeof own === "string" ? own.startsWith("${configDir}") ? resolve(dirname(leaf), `.${own.slice(12)}`) : resolve(dirname(file), own) : inheritedRootDir(file, leaf, /* @__PURE__ */ new Set([...seen, tsconfig]));
3031
- if (rootDir === void 0) return void 0;
3032
- if (rootDir !== null) found = rootDir;
3029
+ const own = parent.compilerOptions?.[name];
3030
+ const value = own === void 0 ? inheritedOption(file, name, /* @__PURE__ */ new Set([...seen, tsconfig])) : {
3031
+ value: own,
3032
+ file
3033
+ };
3034
+ if (value === void 0) return void 0;
3035
+ if (value !== null) found = value;
3033
3036
  }
3034
3037
  return found;
3035
3038
  }
3036
3039
  /**
3040
+ * This function tells if a tsconfig gets a `rootDir` other than its folder from a config that it extends. It also says
3041
+ * yes when it cannot read that config. A `${configDir}` is the folder of the tsconfig, the other paths are relative to
3042
+ * the config that sets them.
3043
+ */
3044
+ function inheritsSubfolder(tsconfig) {
3045
+ const inherited = inheritedOption(tsconfig, "rootDir");
3046
+ if (inherited === null) return false;
3047
+ if (inherited === void 0 || typeof inherited.value !== "string") return true;
3048
+ const own = inherited.value;
3049
+ return (own.startsWith("${configDir}") ? resolve(dirname(tsconfig), `.${own.slice(12)}`) : resolve(dirname(inherited.file), own)) !== resolve(dirname(tsconfig));
3050
+ }
3051
+ /**
3037
3052
  * This function gives the edit that adds the config files at the root of a package to its `tsconfig.test.json`. It adds
3038
3053
  * the include `*.config.ts`. When the `rootDir` is a subfolder, it sets `rootDir: "."`. It also does this when the file
3039
3054
  * gets the `rootDir` from a config that it extends, or when it cannot read that config. A `rootDir` of the folder does
@@ -3065,20 +3080,28 @@ function configEdit(root, tsconfig, extension) {
3065
3080
  const rootDir = options?.["rootDir"];
3066
3081
  const moveRoot = typeof rootDir === "string" && !ROOT_DIRS.has(rootDir);
3067
3082
  if (moveRoot) after = after.replace(/("rootDir"\s*:\s*)"(?:[^"\\]|\\.)*"/, "$1\".\"");
3068
- const inherited = rootDir === void 0 && after !== text ? inheritedRootDir(tsconfig) : null;
3069
- const addRoot = inherited !== null && (inherited === void 0 || resolve(inherited) !== resolve(dirname(tsconfig)));
3070
- if (addRoot && options !== void 0) after = Object.keys(options).length === 0 ? after.replace(/("compilerOptions"\s*:\s*\{)\s*\}/, "$1 \"rootDir\": \".\" }") : after.replace(/("compilerOptions"\s*:\s*\{)(\s*)/, (_all, start, space) => `${start}${space}"rootDir": ".",${space}`);
3071
- else if (addRoot) after = after.replace(/^(\s*\{)(\s*)/, (_all, start, space) => `${start}${space}"compilerOptions": { "rootDir": "." },${space}`);
3083
+ const added = {};
3084
+ if (after !== text) {
3085
+ if (rootDir === void 0 && inheritsSubfolder(tsconfig)) added["rootDir"] = ".";
3086
+ const isolated = options?.["isolatedDeclarations"] === void 0 ? inheritedOption(tsconfig, "isolatedDeclarations") : null;
3087
+ if (isolated === void 0 || isolated !== null && isolated.value !== false) added["isolatedDeclarations"] = false;
3088
+ }
3089
+ const entries = Object.entries(added).map(([key, value]) => `${JSON.stringify(key)}: ${JSON.stringify(value)}`);
3090
+ if (entries.length > 0 && options !== void 0) after = Object.keys(options).length === 0 ? after.replace(/("compilerOptions"\s*:\s*\{)\s*\}/, `$1 ${entries.join(", ")} }`) : after.replace(/("compilerOptions"\s*:\s*\{)(\s*)/, (_all, start, space) => `${start}${space}${entries.join(`,${space}`)},${space}`);
3091
+ else if (entries.length > 0) after = after.replace(/^(\s*\{)(\s*)/, (_all, start, space) => `${start}${space}"compilerOptions": { ${entries.join(", ")} },${space}`);
3072
3092
  const include = globs.includes(glob) ? globs : [...globs, glob];
3073
- const intended = addRoot ? options === void 0 ? {
3074
- compilerOptions: { rootDir: "." },
3093
+ const intended = entries.length > 0 ? options === void 0 ? {
3094
+ compilerOptions: added,
3075
3095
  ...json,
3076
3096
  include
3077
3097
  } : {
3078
3098
  ...json,
3079
3099
  compilerOptions: {
3080
- rootDir: ".",
3081
- ...options
3100
+ ...added,
3101
+ ...moveRoot ? {
3102
+ ...options,
3103
+ rootDir: "."
3104
+ } : options
3082
3105
  },
3083
3106
  include
3084
3107
  } : {
@@ -3887,4 +3910,4 @@ function runCli(args, io) {
3887
3910
  }
3888
3911
  export { hasFile as $, roadmapParses as A, REAL_COMPARE as B, isSourcePath as C, runnerBudget as D, repositoryOfRemote as E, pinnedGitDeps as F, gateTrigger as G, mainCheck as H, DEFAULT_ALLOWED as I, STRICT_OPTIONS as J, prPathFilters as K, HOME_PATTERNS as L, releaseFiles as M, isGitSpecifier as N, scheduleMinute as O, isPinned as P, codePackages as Q, noLocalPaths as R, tsconfigTest as S, sourceMain as T, ACTIONS_COMMIT as U, hasImportMetaMain as V, convertGate as W, DEPENDENCY_FIELDS as X, cuePreset as Y, cleanPath as Z, configsOfScript as _, listRules as a, readJsonc as at, testsRequired as b, runCli as c, specifiersOf as ct, RULES as d, packageFolders as dt, inFolder as et, workspaceProtocol as f, workspaceGlobs as ft, typedScripts as g, trustPolicy as h, formatResult as i, parseJsonc as it, requiredScripts as j, roadmapOfLine as k, runFix as l, globFolders as lt, TRAIN_SCOPES as m, parseConfig as mt, annotations as n, lineOf as nt, readConfig as o, replaceLine as ot, IGNORE_AFTER as p, defaultOptions as pt, summaryName as q, createContext as r, matchesAny as rt, runChecks as s, runGit as st, USAGE as t, keyLine as tt, summaryMarkdown as u, globToRegExp as ut, scriptsOf as v, pathsOf as w, hasTests as x, typedFiles as y, noBuildOutput as z };
3889
3912
 
3890
- //# sourceMappingURL=run-CKf71WQx.js.map
3913
+ //# sourceMappingURL=run-DKVHmESw.js.map