@mark1russell7/conventions 0.14.1 → 0.16.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/README.md +1 -0
- package/build/cli.js +1 -1
- package/build/index.d.ts +14 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/{run-2K_CrANg.js → run-uE1CPx4q.js} +153 -3
- package/build/run-uE1CPx4q.js.map +1 -0
- package/package.json +1 -1
- package/build/run-2K_CrANg.js.map +0 -1
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ The rules come from the invariants audit of 2026-10-26 (strategy item s38). The
|
|
|
54
54
|
| `roadmap-parses` | Each call of the Pages workflow of the template (`reusable-pages.yml`) gives a `roadmap`, or `site-pages: false`. Without it, the Status page shows no item of the plan. Each roadmap that a workflow gives to the Status page (a `roadmap:` key) parses as `@mark1russell7/site-pages` reads it. The rule uses the parser of site-pages. Thus a pull request finds a bad row, and the Pages job on `main` does not stop on it. | fleet `fail-closed` (STRATEGY.md, 2026-10-30). |
|
|
55
55
|
| `runner-budget` | All repositories of the account share 40 runners. Each `strategy` with a `matrix` has a `max-parallel` of 3 or less. Each workflow has a concurrency group at the top or in each job. A job that calls a shared workflow of the option `grouped` gets its group from that workflow, and each job of that workflow has a group. The minute of each `cron` comes from a hash of the repository and the file (1 to 59), so the schedules of the repositories do not start together. The repository comes from `GITHUB_REPOSITORY` or from the remote `origin`. | fleet `runner-slots` (STRATEGY.md, 2026-10-30). |
|
|
56
56
|
| `gate-trigger` | No workflow has `paths` or `paths-ignore` on `on.pull_request` or `on.pull_request_target`. The ruleset needs the summary check `<Name> OK` of each gate, and a workflow with a path filter does not start on each pull request. Then its check is not there, the ruleset cannot ask for it, and a pull request can merge before the gate ends. A gate uses the actions `changes` and `gate-summary` of the template (`CI.md`, "A gate with paths"). | fleet `gate-trigger` (STRATEGY.md, 2026-11-02). |
|
|
57
|
+
| `license-file` | Each public package has a license field, and a license file with the same license in its own folder. A public repository, or a repository with a public package, has a license file at its root. In a GitHub Actions run, the event file tells if the repository is public, and the option `license` (MIT by default) is the license of a root with no public package. npm packs only the license file of the folder of the package, and GitHub reads only the one of the root: on 2026-11-02 five public repositories showed no license on GitHub while npm said MIT. `conventions fix` writes the missing files. | fleet strategy (2026-11-02). |
|
|
57
58
|
| `home-package` | A change does not add a function with a signature name of another home of the map (for example `median`, `mulberry32` or `writeFileAtomic`). A local copy drifts from the home and splits the fixes. On 2026-11-02 the fleet had 68 local statistics functions in 14 repositories. The rule examines only the lines that the change adds, so the copies that exist do not break. | fleet direction 18 (STRATEGY.md, 2026-11-02). |
|
|
58
59
|
|
|
59
60
|
The rule `release-files` needs the base of the change. On a pull request, the checkout is a merge commit, and the rule reads its two parents (`fetch-depth` 2 or more). In other runs, give `--base <ref>`. Without a base, the rule shows `skip`. The rule also needs each commit of the change. A shallow checkout can end inside the change. Then the authors and the messages that the rule reads are not those of the change, so the rule shows `error`. A pull request of one commit is complete at depth 2. For a longer one, the CI of the template deepens the checkout to the merge base.
|
package/build/cli.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -231,6 +231,20 @@ export declare function repoOf(context: RuleContext): string | undefined;
|
|
|
231
231
|
/** This function gives the message of a break: the home, and if the home already exports the name. */
|
|
232
232
|
export declare function messageOf(file: string, name: string, home: Home): string;
|
|
233
233
|
export declare const homePackage: Rule;
|
|
234
|
+
/** For each license that the rule knows, a pattern of its text. The text of another license is not checked. */
|
|
235
|
+
export declare const LICENSE_TEXTS: Readonly<Record<string, RegExp>>;
|
|
236
|
+
/** This function gives the name of the license file in a folder, or undefined. */
|
|
237
|
+
export declare function licenseFileOf(dir: string): string | undefined;
|
|
238
|
+
/** This function gives the name of the author of a manifest: the string before `<` or `(`, or the field `name`. */
|
|
239
|
+
export declare function authorOf(author: unknown): string | undefined;
|
|
240
|
+
/** This function gives the text of the MIT license. */
|
|
241
|
+
export declare function mitText(year: number, holder: string): string;
|
|
242
|
+
/**
|
|
243
|
+
* This function tells if the repository is public, from the event file of a GitHub Actions run. Outside a run, or with no
|
|
244
|
+
* field `repository.private` in the event, it gives undefined.
|
|
245
|
+
*/
|
|
246
|
+
export declare function repositoryIsPublic(context: RuleContext): boolean | undefined;
|
|
247
|
+
export declare const licenseFile: Rule;
|
|
234
248
|
/** The compare of two real paths. It is true through a link too, and it works on each Node version. */
|
|
235
249
|
export declare const REAL_COMPARE = "process.argv[1] !== undefined && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))";
|
|
236
250
|
/** This function tells if each Node version of the range has `import.meta.main`: 22.18 and later in 22, and 24.2 and later. Node 23 does not have it. */
|
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/gate-trigger.ts","../src/map.ts","../src/rules/home-package.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/home-exports.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;;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../src/config.ts","../src/rules/cue-preset.ts","../src/rules/gate-trigger.ts","../src/map.ts","../src/rules/home-package.ts","../src/rules/license-file.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/home-exports.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;;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;;UCrM9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS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ACd,SAAS,SAAS,0BAClB,cACA,OAAM;qBAkRK,YAAY;qBC/VZ,cAAc;;qBC3Bd;;qBAGA;qBA6DA,aAAa;qBCnEb,mBAAmB;;qBCiBnB,gBAAgB;;qBCvBhB,cAAc,SAAS;WAA0B;WAA0B;;;UCYvE;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;;UA2CjC;;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;;wBA6BG,OAAO,yBAAyB,IAAI;;;;;;wBC1RpC,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ct as ACTIONS_COMMIT, I as DEFAULT_ALLOWED, ht as DEPENDENCY_FIELDS, et as HOMES, st as HOME_EXPORTS, L as HOME_PATTERNS, p as IGNORE_AFTER, U as LICENSE_TEXTS, tt as MAP_RULE, B as REAL_COMPARE, d as RULES, pt as STRICT_OPTIONS, m as TRAIN_SCOPES, t as USAGE, n as annotations, W as authorOf, gt as cleanPath, _t as codePackages, _ as configsOfScript, lt as convertGate, r as createContext, mt as cuePreset, Y as declaredName, Mt as defaultOptions, nt as findHomes, i as formatResult, ut as gateTrigger, Ot as globFolders, kt as globToRegExp, vt as hasFile, V as hasImportMetaMain, x as hasTests, X as homePackage, yt as inFolder, N as isGitSpecifier, P as isPinned, C as isSourcePath, bt as keyLine, G as licenseFile, K as licenseFileOf, xt as lineOf, a as listRules, H as mainCheck, rt as mapMarkdown, it as mapText, St as matchesAny, at as mergeHomes, Z as messageOf, q as mitText, z as noBuildOutput, R as noLocalPaths, At as packageFolders, Nt as parseConfig, Ct as parseJsonc, w as pathsOf, F as pinnedGitDeps, dt as prPathFilters, o as readConfig, wt as readJsonc, ot as readOverlay, M as releaseFiles, Tt as replaceLine, Q as repoOf, J as repositoryIsPublic, E as repositoryOfRemote, j as requiredScripts, k as roadmapOfLine, A as roadmapParses, s as runChecks, c as runCli, l as runFix, Et as runGit, D as runnerBudget, O as scheduleMinute, v as scriptsOf, $ as signaturesOf, T as sourceMain, Dt as specifiersOf, u as summaryMarkdown, ft as summaryName, b as testsRequired, h as trustPolicy, S as tsconfigTest, y as typedFiles, g as typedScripts, jt as workspaceGlobs, f as workspaceProtocol } from "./run-uE1CPx4q.js";
|
|
@@ -6539,6 +6539,155 @@ const homePackage = {
|
|
|
6539
6539
|
return breaks;
|
|
6540
6540
|
}
|
|
6541
6541
|
};
|
|
6542
|
+
// src/rules/license-file.ts
|
|
6543
|
+
/**
|
|
6544
|
+
* The rule `license-file`. Each public package has a license field and, in its own folder, a license file with the
|
|
6545
|
+
* same license. A repository with a public package has a license file at its root.
|
|
6546
|
+
*/
|
|
6547
|
+
/** The names of a license file, without case. */
|
|
6548
|
+
const LICENSE_NAME = /^licen[cs]e(?:\.(?:md|txt))?$/i;
|
|
6549
|
+
/** For each license that the rule knows, a pattern of its text. The text of another license is not checked. */
|
|
6550
|
+
const LICENSE_TEXTS = {
|
|
6551
|
+
MIT: /\bMIT License\b|Permission is hereby granted, free of charge/,
|
|
6552
|
+
ISC: /\bISC License\b|Permission to use, copy, modify, and\/or distribute/,
|
|
6553
|
+
"Apache-2.0": /Apache License,?\s+Version 2\.0/,
|
|
6554
|
+
"BSD-3-Clause": /Redistribution and use in source and binary forms[\s\S]*Neither the name/
|
|
6555
|
+
};
|
|
6556
|
+
/** This function gives the name of the license file in a folder, or undefined. */
|
|
6557
|
+
function licenseFileOf(dir) {
|
|
6558
|
+
if (!existsSync(dir)) return void 0;
|
|
6559
|
+
return readdirSync(dir, { withFileTypes: true }).find((entry) => entry.isFile() && LICENSE_NAME.test(entry.name))?.name;
|
|
6560
|
+
}
|
|
6561
|
+
/** This function gives the name of the author of a manifest: the string before `<` or `(`, or the field `name`. */
|
|
6562
|
+
function authorOf(author) {
|
|
6563
|
+
const before = (text) => {
|
|
6564
|
+
const at = text.search(/[<(]/);
|
|
6565
|
+
return at === -1 ? text : text.slice(0, at);
|
|
6566
|
+
};
|
|
6567
|
+
const name = typeof author === "string" ? before(author) : typeof author === "object" && author !== null && typeof author.name === "string" ? author.name : void 0;
|
|
6568
|
+
return name === void 0 || name.trim() === "" ? void 0 : name.trim();
|
|
6569
|
+
}
|
|
6570
|
+
/** This function gives the text of the MIT license. */
|
|
6571
|
+
function mitText(year, holder) {
|
|
6572
|
+
return `MIT License
|
|
6573
|
+
|
|
6574
|
+
Copyright (c) ${year} ${holder}
|
|
6575
|
+
|
|
6576
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6577
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6578
|
+
in the Software without restriction, including without limitation the rights
|
|
6579
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
6580
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
6581
|
+
furnished to do so, subject to the following conditions:
|
|
6582
|
+
|
|
6583
|
+
The above copyright notice and this permission notice shall be included in all
|
|
6584
|
+
copies or substantial portions of the Software.
|
|
6585
|
+
|
|
6586
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
6587
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
6588
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
6589
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
6590
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
6591
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
6592
|
+
SOFTWARE.
|
|
6593
|
+
`;
|
|
6594
|
+
}
|
|
6595
|
+
const isPublic = (pkg) => pkg.manifest["private"] !== true;
|
|
6596
|
+
/**
|
|
6597
|
+
* This function tells if the repository is public, from the event file of a GitHub Actions run. Outside a run, or with no
|
|
6598
|
+
* field `repository.private` in the event, it gives undefined.
|
|
6599
|
+
*/
|
|
6600
|
+
function repositoryIsPublic(context) {
|
|
6601
|
+
const file = context.env["GITHUB_EVENT_PATH"];
|
|
6602
|
+
if (file === void 0 || file === "" || !existsSync(file)) return void 0;
|
|
6603
|
+
try {
|
|
6604
|
+
const event = JSON.parse(readFileSync(file, "utf8"));
|
|
6605
|
+
return typeof event.repository?.private === "boolean" ? !event.repository.private : void 0;
|
|
6606
|
+
} catch {
|
|
6607
|
+
return;
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6610
|
+
const licenseFile = {
|
|
6611
|
+
id: "license-file",
|
|
6612
|
+
title: "Each public package has a license field and, in its own folder, a license file with the same license. A public repository, or a repository with a public package, has a license file at its root.",
|
|
6613
|
+
reason: "npm packs the license file of the folder of the package only, and GitHub reads the license file of the root only. On 2026-11-02 five public repositories (packing, rigor, layout-contract, typeset, template) had no license file at the root, so GitHub showed them as without a license while their packages on npm said MIT.",
|
|
6614
|
+
fix: "Add a license field to package.json (the option `license`, MIT by default, is the license of the root of a public repository with no public package). `conventions fix` writes each missing license file: a copy of a license file of the repository with the same license, or else the MIT text with the author of the manifest. Correct a license file whose text is not the license of the field.",
|
|
6615
|
+
sources: [
|
|
6616
|
+
"vex",
|
|
6617
|
+
"coeval",
|
|
6618
|
+
"client",
|
|
6619
|
+
"highways"
|
|
6620
|
+
].map((repo) => ({
|
|
6621
|
+
repo,
|
|
6622
|
+
rule: "license-file",
|
|
6623
|
+
doc: "LICENSE (MIT, at the root, with license MIT in each package.json)"
|
|
6624
|
+
})),
|
|
6625
|
+
options: { license: {
|
|
6626
|
+
type: "string",
|
|
6627
|
+
default: "MIT",
|
|
6628
|
+
description: "The license of the root of a public repository with no public package."
|
|
6629
|
+
} },
|
|
6630
|
+
check(context, options) {
|
|
6631
|
+
const all = [context.rootPackage, ...codePackages(context)];
|
|
6632
|
+
const unique = all.filter((pkg, index) => all.findIndex((other) => other.file === pkg.file) === index);
|
|
6633
|
+
const published = unique.filter(isPublic);
|
|
6634
|
+
const publicRepo = repositoryIsPublic(context) === true;
|
|
6635
|
+
if (published.length === 0 && !publicRepo) return [];
|
|
6636
|
+
const breaks = [];
|
|
6637
|
+
const texts = /* @__PURE__ */ new Map();
|
|
6638
|
+
const licenseOf = (pkg) => typeof pkg.manifest["license"] === "string" ? pkg.manifest["license"] : void 0;
|
|
6639
|
+
for (const pkg of unique) {
|
|
6640
|
+
const name = licenseFileOf(pkg.dir);
|
|
6641
|
+
if (name === void 0) continue;
|
|
6642
|
+
const text = readFileSync(join(pkg.dir, name), "utf8");
|
|
6643
|
+
const license = Object.keys(LICENSE_TEXTS).find((id) => LICENSE_TEXTS[id]?.test(text) === true) ?? licenseOf(pkg);
|
|
6644
|
+
if (license !== void 0 && !texts.has(license)) texts.set(license, text);
|
|
6645
|
+
}
|
|
6646
|
+
const missing = (folder, license, author, why) => {
|
|
6647
|
+
const file = inFolder(folder, "LICENSE");
|
|
6648
|
+
const holder = authorOf(author) ?? authorOf(context.rootPackage.manifest["author"]);
|
|
6649
|
+
const text = texts.get(license) ?? (license === "MIT" && holder !== void 0 ? mitText((/* @__PURE__ */ new Date()).getFullYear(), holder) : void 0);
|
|
6650
|
+
breaks.push({
|
|
6651
|
+
file,
|
|
6652
|
+
message: `${folder === "" ? "The root" : folder} has no license file: ${why}`,
|
|
6653
|
+
...text === void 0 ? {} : { edits: [{
|
|
6654
|
+
file,
|
|
6655
|
+
before: "",
|
|
6656
|
+
after: text
|
|
6657
|
+
}] }
|
|
6658
|
+
});
|
|
6659
|
+
};
|
|
6660
|
+
for (const pkg of published) {
|
|
6661
|
+
const license = licenseOf(pkg);
|
|
6662
|
+
const name = String(pkg.manifest["name"] ?? pkg.folder);
|
|
6663
|
+
if (license === void 0) {
|
|
6664
|
+
breaks.push({
|
|
6665
|
+
file: pkg.file,
|
|
6666
|
+
message: `The public package ${name} has no license field.`
|
|
6667
|
+
});
|
|
6668
|
+
continue;
|
|
6669
|
+
}
|
|
6670
|
+
const found = licenseFileOf(pkg.dir);
|
|
6671
|
+
if (found === void 0) {
|
|
6672
|
+
missing(pkg.folder, license, pkg.manifest["author"], `npm packs only the license file of the folder of ${name} (${license}).`);
|
|
6673
|
+
continue;
|
|
6674
|
+
}
|
|
6675
|
+
const text = readFileSync(join(pkg.dir, found), "utf8");
|
|
6676
|
+
if (LICENSE_TEXTS[license]?.test(text) === false) {
|
|
6677
|
+
const line = lineOf(pkg.text, "\"license\"");
|
|
6678
|
+
breaks.push({
|
|
6679
|
+
file: inFolder(pkg.folder, found),
|
|
6680
|
+
message: `${inFolder(pkg.folder, found)} is not the text of ${license}, the license field of ${name}${line === void 0 ? "" : ` (${pkg.file}:${line})`}.`
|
|
6681
|
+
});
|
|
6682
|
+
}
|
|
6683
|
+
}
|
|
6684
|
+
if (!published.includes(context.rootPackage) && licenseFileOf(context.root) === void 0) {
|
|
6685
|
+
const license = published.map(licenseOf).find((item) => item !== void 0) ?? (publicRepo ? String(options["license"]) : void 0);
|
|
6686
|
+
if (license !== void 0) missing("", license, published[0]?.manifest["author"], "GitHub reads only the license file of the root.");
|
|
6687
|
+
}
|
|
6688
|
+
return breaks;
|
|
6689
|
+
}
|
|
6690
|
+
};
|
|
6542
6691
|
// src/rules/main-check.ts
|
|
6543
6692
|
/**
|
|
6544
6693
|
* The rule `main-check`: a script does not find out that it is the main module by a compare of `process.argv[1]` with
|
|
@@ -9206,7 +9355,8 @@ const RULES = [
|
|
|
9206
9355
|
roadmapParses,
|
|
9207
9356
|
runnerBudget,
|
|
9208
9357
|
gateTrigger,
|
|
9209
|
-
homePackage
|
|
9358
|
+
homePackage,
|
|
9359
|
+
licenseFile
|
|
9210
9360
|
];
|
|
9211
9361
|
// src/run.ts
|
|
9212
9362
|
/**
|
|
@@ -9602,6 +9752,6 @@ function runMap(args, io) {
|
|
|
9602
9752
|
else io.stdout(mapText(found));
|
|
9603
9753
|
return 0;
|
|
9604
9754
|
}
|
|
9605
|
-
export {
|
|
9755
|
+
export { signaturesOf as $, roadmapParses as A, packageFolders as At, REAL_COMPARE as B, isSourcePath as C, parseJsonc as Ct, runnerBudget as D, specifiersOf as Dt, repositoryOfRemote as E, runGit as Et, pinnedGitDeps as F, licenseFile as G, mainCheck as H, DEFAULT_ALLOWED as I, repositoryIsPublic as J, licenseFileOf as K, HOME_PATTERNS as L, releaseFiles as M, defaultOptions as Mt, isGitSpecifier as N, parseConfig as Nt, scheduleMinute as O, globFolders as Ot, isPinned as P, repoOf as Q, noLocalPaths as R, tsconfigTest as S, matchesAny as St, sourceMain as T, replaceLine as Tt, LICENSE_TEXTS as U, hasImportMetaMain as V, authorOf as W, homePackage as X, declaredName as Y, messageOf as Z, configsOfScript as _, codePackages as _t, listRules as a, mergeHomes as at, testsRequired as b, keyLine as bt, runCli as c, ACTIONS_COMMIT as ct, RULES as d, prPathFilters as dt, HOMES as et, workspaceProtocol as f, summaryName as ft, typedScripts as g, cleanPath as gt, trustPolicy as h, DEPENDENCY_FIELDS as ht, formatResult as i, mapText as it, requiredScripts as j, workspaceGlobs as jt, roadmapOfLine as k, globToRegExp as kt, runFix as l, convertGate as lt, TRAIN_SCOPES as m, cuePreset as mt, annotations as n, findHomes as nt, readConfig as o, readOverlay as ot, IGNORE_AFTER as p, STRICT_OPTIONS as pt, mitText as q, createContext as r, mapMarkdown as rt, runChecks as s, HOME_EXPORTS as st, USAGE as t, MAP_RULE as tt, summaryMarkdown as u, gateTrigger as ut, scriptsOf as v, hasFile as vt, pathsOf as w, readJsonc as wt, hasTests as x, lineOf as xt, typedFiles as y, inFolder as yt, noBuildOutput as z };
|
|
9606
9756
|
|
|
9607
|
-
//# sourceMappingURL=run-
|
|
9757
|
+
//# sourceMappingURL=run-uE1CPx4q.js.map
|