@mark1russell7/conventions 0.8.0 → 0.8.1
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
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.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/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;;KAIC;;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;;wBAGG,aAAa,UAAU,UAAU;;wBAOjC,OAAO,cAAc,gBAAgB;;wBAOrC,QAAQ,cAAc,eAAe;;qBAMxC,WAAY,gBAAgB;;qBAG5B,YAAa;;wBAGV,WAAW,cAAc;;;;;;wBASzB,WAAW;;wBA2BX,UAAU;;wBAUV,OAAO,cAAc;;qBAOxB,UAAW,aAAa;;;;;wBAMrB,aAAa,SAAS,KAAK,oDAAoD;;UC9K9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;UAIH;;WAEN;;WAEA,OAAO,SAAS,eAAe;;;wBAW1B,eAAe,MAAM,OAAO;;;;;;;wBAU5B,YAAY,gBAAgB,gBAAgB,SAAS;;qBCnCxD;qBA2FA,WAAW;qBC/FX,eAAe;;qBCYf;;qBAGA,wBAAwB;qBAOxB,cAAc;;wBCnBX,eAAe;;;;;wBAaf,SAAS,cAAc;qBAqB1B,eAAe;qBCEf,cAAc;qBCrBd,iBAAiB;;wBCqCd,cAAc;qBAajB,eAAe;;;;;;wBCnBZ,eAAe,oBAAoB;;wBAUnC,mBAAmB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.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/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;;KAIC;;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;;wBAGG,aAAa,UAAU,UAAU;;wBAOjC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wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBAwBG,OAAO,yBAAyB,IAAI;;;;;;wBCxNpC,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { M as DEFAULT_ALLOWED, R as DEPENDENCY_FIELDS, N as HOME_PATTERNS, u as RULES, I as STRICT_OPTIONS, t as USAGE, n as annotations, z as cleanPath, B as codePackages, p as configsOfScript, r as createContext, L as cuePreset, et as defaultOptions, i as formatResult, X as globFolders, Z as globToRegExp, V as hasFile, g as hasTests, H as inFolder, k as isGitSpecifier, A as isPinned, y as isSourcePath, U as keyLine, W as lineOf, a as listRules, G as matchesAny, F as noBuildOutput, P as noLocalPaths, Q as packageFolders, tt as parseConfig, K as parseJsonc, b as pathsOf, j as pinnedGitDeps, o as readConfig, q as readJsonc, O as releaseFiles, S as repositoryOfRemote, D as requiredScripts, T as roadmapOfLine, E as roadmapParses, s as runChecks, c as runCli, J as runGit, C as runnerBudget, w as scheduleMinute, m as scriptsOf, x as sourceMain, Y as specifiersOf, l as summaryMarkdown, v as testsRequired, _ as tsconfigTest, h as typedFiles, f as typedScripts, $ as workspaceGlobs, d as workspaceProtocol } from "./run-
|
|
1
|
+
export { M as DEFAULT_ALLOWED, R as DEPENDENCY_FIELDS, N as HOME_PATTERNS, u as RULES, I as STRICT_OPTIONS, t as USAGE, n as annotations, z as cleanPath, B as codePackages, p as configsOfScript, r as createContext, L as cuePreset, et as defaultOptions, i as formatResult, X as globFolders, Z as globToRegExp, V as hasFile, g as hasTests, H as inFolder, k as isGitSpecifier, A as isPinned, y as isSourcePath, U as keyLine, W as lineOf, a as listRules, G as matchesAny, F as noBuildOutput, P as noLocalPaths, Q as packageFolders, tt as parseConfig, K as parseJsonc, b as pathsOf, j as pinnedGitDeps, o as readConfig, q as readJsonc, O as releaseFiles, S as repositoryOfRemote, D as requiredScripts, T as roadmapOfLine, E as roadmapParses, s as runChecks, c as runCli, J as runGit, C as runnerBudget, w as scheduleMinute, m as scriptsOf, x as sourceMain, Y as specifiersOf, l as summaryMarkdown, v as testsRequired, _ as tsconfigTest, h as typedFiles, f as typedScripts, $ as workspaceGlobs, d as workspaceProtocol } from "./run-B7ftggFF.js";
|
|
@@ -130,12 +130,18 @@ function globToRegExp(glob) {
|
|
|
130
130
|
}
|
|
131
131
|
/** The characters that make a path segment a pattern. */
|
|
132
132
|
const GLOB_CHARS = /[*?{]/;
|
|
133
|
+
/** This function removes the `/` characters at the end of a path, with a loop in place of a regular expression. */
|
|
134
|
+
function trimEndSlashes(path) {
|
|
135
|
+
let end = path.length;
|
|
136
|
+
while (end > 0 && path.charAt(end - 1) === "/") end -= 1;
|
|
137
|
+
return path.slice(0, end);
|
|
138
|
+
}
|
|
133
139
|
/**
|
|
134
140
|
* This function gives the folders under `root` that a glob names, as `/` paths relative to `root`,
|
|
135
141
|
* in the order of the code units. It does not go into `node_modules` or a folder that starts with `.`.
|
|
136
142
|
*/
|
|
137
143
|
function globFolders(root, glob) {
|
|
138
|
-
const clean = glob.
|
|
144
|
+
const clean = trimEndSlashes(glob.startsWith("./") ? glob.slice(2) : glob);
|
|
139
145
|
const segments = clean.split("/");
|
|
140
146
|
const firstPattern = segments.findIndex((segment) => GLOB_CHARS.test(segment));
|
|
141
147
|
if (firstPattern < 0) return existsSync(join(root, clean)) ? [clean] : [];
|
|
@@ -1883,15 +1889,33 @@ function matrixBreaks(file, lines, limit) {
|
|
|
1883
1889
|
});
|
|
1884
1890
|
return breaks;
|
|
1885
1891
|
}
|
|
1886
|
-
/**
|
|
1892
|
+
/**
|
|
1893
|
+
* This function gives the minute field of a schedule that starts `perHour` times in each hour, at equal steps. One start is at
|
|
1894
|
+
* `minute`: `"18"` for 1, `"18,48"` for 2. The list is in the order of the numbers.
|
|
1895
|
+
*/
|
|
1896
|
+
function minuteField(minute, perHour) {
|
|
1897
|
+
const step = 60 / perHour;
|
|
1898
|
+
return Array.from({ length: perHour }, (_, k) => (minute + k * step) % 60).sort((a, b) => a - b).join(",");
|
|
1899
|
+
}
|
|
1900
|
+
/** This function gives the number of starts in each hour of a minute field (`"*\/30"` or `"5,35"` give 2), or 1 when it cannot tell. */
|
|
1901
|
+
function startsPerHour(field) {
|
|
1902
|
+
const step = /^\*\/(\d+)$/.exec(field);
|
|
1903
|
+
const count = step ? 60 / Number(step[1]) : field.split(",").length;
|
|
1904
|
+
return Number.isInteger(count) && count >= 1 && 60 % count === 0 ? count : 1;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* This function gives the breaks of the schedules: the minute of each `cron` is the minute of the repository and the file. A
|
|
1908
|
+
* schedule that starts more than once in each hour starts at equal steps from that minute (`18,48` for each 30 minutes).
|
|
1909
|
+
*/
|
|
1887
1910
|
function cronBreaks(file, lines, minute) {
|
|
1888
1911
|
const breaks = [];
|
|
1889
1912
|
lines.forEach((line, index) => {
|
|
1890
1913
|
const value = keyValue(line, "cron");
|
|
1891
1914
|
if (value === void 0) return;
|
|
1892
1915
|
const fields = value.split(" ").filter((field) => field !== "");
|
|
1893
|
-
|
|
1894
|
-
|
|
1916
|
+
const wanted = minuteField(minute, startsPerHour(fields[0] ?? ""));
|
|
1917
|
+
if (fields[0] === wanted) return;
|
|
1918
|
+
const expected = [wanted, ...fields.slice(1)].join(" ");
|
|
1895
1919
|
breaks.push({
|
|
1896
1920
|
file,
|
|
1897
1921
|
line: index + 1,
|
|
@@ -2142,12 +2166,26 @@ const testsRequired = {
|
|
|
2142
2166
|
* The rule `tsconfig-test`: each TypeScript package has a `tsconfig.test.json`, and its typecheck
|
|
2143
2167
|
* examines it.
|
|
2144
2168
|
*/
|
|
2145
|
-
/** The
|
|
2146
|
-
const
|
|
2169
|
+
/** The ends of the name of a test file: `.test.` or `.spec.`, then an extension of JavaScript or TypeScript. */
|
|
2170
|
+
const TEST_ENDS = ["test", "spec"].flatMap((kind) => [
|
|
2171
|
+
"",
|
|
2172
|
+
"c",
|
|
2173
|
+
"m"
|
|
2174
|
+
].flatMap((module) => ["j", "t"].flatMap((lang) => ["", "x"].map((jsx) => `.${kind}.${module}${lang}s${jsx}`))));
|
|
2175
|
+
/**
|
|
2176
|
+
* This function tells if a path is a test file: `*.test.*` or `*.spec.*` of JavaScript or TypeScript, or a file in a
|
|
2177
|
+
* folder `__tests__`. It uses string operations, with no regular expression, so a long path takes linear time.
|
|
2178
|
+
*/
|
|
2179
|
+
function isTestFile(path) {
|
|
2180
|
+
const segments = path.split("/");
|
|
2181
|
+
const name = segments[segments.length - 1] ?? "";
|
|
2182
|
+
if (name !== "" && segments.slice(0, -1).includes("__tests__")) return true;
|
|
2183
|
+
return TEST_ENDS.some((end) => name.length > end.length && name.endsWith(end));
|
|
2184
|
+
}
|
|
2147
2185
|
/** This function tells if git tracks a test file in the package folder `folder` (`""` is the root). */
|
|
2148
2186
|
function hasTests(files, folder) {
|
|
2149
2187
|
const prefix = folder === "" ? "" : `${folder}/`;
|
|
2150
|
-
return files.some((path) => path.startsWith(prefix) &&
|
|
2188
|
+
return files.some((path) => path.startsWith(prefix) && isTestFile(path.slice(prefix.length)));
|
|
2151
2189
|
}
|
|
2152
2190
|
const tsconfigTest = {
|
|
2153
2191
|
id: "tsconfig-test",
|
|
@@ -2775,8 +2813,8 @@ function formatResult(result) {
|
|
|
2775
2813
|
if (result.failed) out.push("", "To turn a rule off or to keep an exception, add a reason in the field conventions of package.json (`conventions --list`).");
|
|
2776
2814
|
return `${out.join("\n")}\n`;
|
|
2777
2815
|
}
|
|
2778
|
-
/** This function escapes the text of a cell of a Markdown table
|
|
2779
|
-
const cell = (text) => text.replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
|
2816
|
+
/** This function escapes the text of a cell of a Markdown table: first each backslash, then each `|`. */
|
|
2817
|
+
const cell = (text) => text.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
|
2780
2818
|
/** This function gives the result as Markdown for the summary of a GitHub Actions run. */
|
|
2781
2819
|
function summaryMarkdown(result) {
|
|
2782
2820
|
const out = [
|
|
@@ -2917,4 +2955,4 @@ function runCli(args, io) {
|
|
|
2917
2955
|
}
|
|
2918
2956
|
export { workspaceGlobs as $, isPinned as A, codePackages as B, runnerBudget as C, requiredScripts as D, roadmapParses as E, noBuildOutput as F, matchesAny as G, inFolder as H, STRICT_OPTIONS as I, runGit as J, parseJsonc as K, cuePreset as L, DEFAULT_ALLOWED as M, HOME_PATTERNS as N, releaseFiles as O, noLocalPaths as P, packageFolders as Q, DEPENDENCY_FIELDS as R, repositoryOfRemote as S, roadmapOfLine as T, keyLine as U, hasFile as V, lineOf as W, globFolders as X, specifiersOf as Y, globToRegExp as Z, tsconfigTest as _, listRules as a, pathsOf as b, runCli as c, workspaceProtocol as d, defaultOptions as et, typedScripts as f, hasTests as g, typedFiles as h, formatResult as i, pinnedGitDeps as j, isGitSpecifier as k, summaryMarkdown as l, scriptsOf as m, annotations as n, readConfig as o, configsOfScript as p, readJsonc as q, createContext as r, runChecks as s, USAGE as t, parseConfig as tt, RULES as u, testsRequired as v, scheduleMinute as w, sourceMain as x, isSourcePath as y, cleanPath as z };
|
|
2919
2957
|
|
|
2920
|
-
//# sourceMappingURL=run-
|
|
2958
|
+
//# sourceMappingURL=run-B7ftggFF.js.map
|