Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"fast-check": "^4.9.0",
"lefthook": "^2.1.10",
"markdownlint-cli2": "^0.23.1",
"oxfmt": "^0.62.0",
"oxfmt": "^0.65.0",
"oxlint": "^1.75.0",
"oxlint-tsgolint": "^7.0.2001",
"typescript": "^7.0.0",
Expand Down
618 changes: 309 additions & 309 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

109 changes: 53 additions & 56 deletions scripts/prepare-release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,34 @@
import { createInterface } from "node:readline/promises";
import { fileURLToPath } from "node:url";

const argumentOffset = 2;
const commandSuccess = 0;
const helpExitCode = 0;
const failureExitCode = 1;
const noHeadingFound = -1;
const releaseDatePattern = /^12\d{3}-\d{2}-\d{2}$/;
const optionAssignments = {
"--help": "help",
"--push": "pushTag",
"--skip-checks": "skipChecks",
"--skip-pack": "skipPack",
"--tag": "createTag",
"-h": "help",
};

const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
const repositoryRoot = path.join(scriptDirectory, "..");

const qualityCommands = [
["pnpm", ["run", "fmt:check"]],
["pnpm", ["run", "lint:ts"]],
["pnpm", ["run", "lint:md"]],
["pnpm", ["run", "typecheck"]],
["pnpm", ["run", "test"]],
["pnpm", ["run", "test:coverage"]],
["pnpm", ["run", "build"]],
["pnpm", ["run", "verify:package"]],
["pnpm", ["run", "smoke:runtime:node"]],
];

const options = parseArguments(process.argv.slice(argumentOffset));
const argumentOffset = 2,
commandSuccess = 0,
helpExitCode = 0,
failureExitCode = 1,
noHeadingFound = -1,
releaseDatePattern = /^12\d{3}-\d{2}-\d{2}$/,
optionAssignments = {
"--help": "help",
"--push": "pushTag",
"--skip-checks": "skipChecks",
"--skip-pack": "skipPack",
"--tag": "createTag",
"-h": "help",
},
scriptDirectory = path.dirname(fileURLToPath(import.meta.url)),
repositoryRoot = path.join(scriptDirectory, ".."),
qualityCommands = [
["pnpm", ["run", "fmt:check"]],
["pnpm", ["run", "lint:ts"]],
["pnpm", ["run", "lint:md"]],
["pnpm", ["run", "typecheck"]],
["pnpm", ["run", "test"]],
["pnpm", ["run", "test:coverage"]],
["pnpm", ["run", "build"]],
["pnpm", ["run", "verify:package"]],
["pnpm", ["run", "smoke:runtime:node"]],
],
options = parseArguments(process.argv.slice(argumentOffset));

if (options.help) {
printHelp();
Expand All @@ -59,8 +56,8 @@
runQualityChecks();
}

const packSummary = currentOptions.skipPack ? undefined : inspectPackageContents();
const notesPath = writeReleaseNotes(release.tagName, release.notes);
const packSummary = currentOptions.skipPack ? undefined : inspectPackageContents(),
notesPath = writeReleaseNotes(release.tagName, release.notes);

Check warning on line 60 in scripts/prepare-release.mjs

View workflow job for this annotation

GitHub Actions / Quality gates

eslint(one-var)

scripts/prepare-release.mjs:59:3: Combine this with the previous 'const' statement.

printPreparationSummary(release.tagName, notesPath, packSummary);
await maybeCreateTag(
Expand All @@ -71,9 +68,9 @@
}

function readReleaseContext() {
const version = readPackageVersion();
const tagName = `v${version}`;
const changelog = readFileSync("CHANGELOG.md", "utf8");
const version = readPackageVersion(),
tagName = `v${version}`,
changelog = readFileSync("CHANGELOG.md", "utf8");

assertCleanWorkingTree();
assertCurrentBranchIsMain();
Expand Down Expand Up @@ -105,8 +102,8 @@
return;
}

const annotationPath = writeTagAnnotation(tagName, tagAnnotation);
const finalAnnotation = await reviewTagAnnotation(annotationPath);
const annotationPath = writeTagAnnotation(tagName, tagAnnotation),
finalAnnotation = await reviewTagAnnotation(annotationPath);
writeFileSync(annotationPath, finalAnnotation, "utf8");

runCommand("git", ["tag", "-s", "-a", tagName, "-F", annotationPath]);
Expand Down Expand Up @@ -149,9 +146,9 @@

try {
const answer = await readline.question(
"\nEdit tag annotation before creating the signed tag? [y/N] ",
);
const normalizedAnswer = answer.trim().toLowerCase();
"\nEdit tag annotation before creating the signed tag? [y/N] ",
),
normalizedAnswer = answer.trim().toLowerCase();

return normalizedAnswer === "y" || normalizedAnswer === "yes";
} finally {
Expand All @@ -160,12 +157,12 @@
}

function openEditor(annotationPath) {
const editor = process.env.GIT_EDITOR || process.env.VISUAL || process.env.EDITOR || "vi";
const [command, ...editorArguments] = parseEditorCommand(editor);
const result = spawnSync(command, [...editorArguments, annotationPath], {
cwd: repositoryRoot,
stdio: "inherit",
});
const editor = process.env.GIT_EDITOR || process.env.VISUAL || process.env.EDITOR || "vi",
[command, ...editorArguments] = parseEditorCommand(editor),
result = spawnSync(command, [...editorArguments, annotationPath], {
cwd: repositoryRoot,
stdio: "inherit",
});

if (result.error) {
throw result.error;
Expand Down Expand Up @@ -305,9 +302,9 @@
throw new Error(`CHANGELOG.md must contain a Human Era section for ${version}`);
}

const sectionStart = headingMatch.index + headingMatch.text.length;
const sectionBody = releaseSectionBody(changelog, sectionStart);
const notes = sectionBody.trim();
const sectionStart = headingMatch.index + headingMatch.text.length,
sectionBody = releaseSectionBody(changelog, sectionStart),
notes = sectionBody.trim();

Check warning on line 307 in scripts/prepare-release.mjs

View workflow job for this annotation

GitHub Actions / Quality gates

eslint(one-var)

scripts/prepare-release.mjs:305:3: Combine this with the previous 'const' statement.

assertReleaseNotesNotEmpty(notes, version);

Expand Down Expand Up @@ -342,8 +339,8 @@
}

function releaseSectionBody(changelog, sectionStart) {
const remainingChangelog = changelog.slice(sectionStart);
const sectionEndIndex = firstSectionTerminatorIndex(remainingChangelog);
const remainingChangelog = changelog.slice(sectionStart),
sectionEndIndex = firstSectionTerminatorIndex(remainingChangelog);

if (sectionEndIndex === noHeadingFound) {
return remainingChangelog;
Expand All @@ -353,8 +350,8 @@
}

function firstSectionTerminatorIndex(markdown) {
const nextHeadingIndex = markdown.search(/^## /m);
const linkReferenceIndex = markdown.search(/^\[[^\]]+\]: /m);
const nextHeadingIndex = markdown.search(/^## /m),
linkReferenceIndex = markdown.search(/^\[[^\]]+\]: /m);

if (nextHeadingIndex === noHeadingFound) {
return linkReferenceIndex;
Expand Down Expand Up @@ -382,8 +379,8 @@
}

function inspectPackageContents() {
const output = captureCommand("pnpm", ["pack", "--json", "--dry-run"], { inheritStderr: true });
const packResult = JSON.parse(output);
const output = captureCommand("pnpm", ["pack", "--json", "--dry-run"], { inheritStderr: true }),
packResult = JSON.parse(output);

return {
entryCount: packResult.files.length,
Expand All @@ -396,7 +393,7 @@
const releaseDirectory = path.join(repositoryRoot, ".release");
mkdirSync(releaseDirectory, { recursive: true });

const notesPath = path.join(releaseDirectory, `release-notes-${tagName}.md`);

Check warning on line 396 in scripts/prepare-release.mjs

View workflow job for this annotation

GitHub Actions / Quality gates

eslint(one-var)

scripts/prepare-release.mjs:396:3: Combine this with the previous 'const' statement.
writeFileSync(notesPath, releaseNotes, "utf8");

return notesPath;
Expand Down
72 changes: 36 additions & 36 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@
VersVersionComparator,
} from "./types.ts";

const MAX_INPUT_LENGTH = 1024;
const MAX_ISSUES = 16;
const SCHEME = "vers";
const SCHEME_PREFIX = "vers:";
const ASCII_TAB = 9;
const ASCII_LINE_FEED = 10;
const ASCII_VERTICAL_TAB = 11;
const ASCII_FORM_FEED = 12;
const ASCII_CARRIAGE_RETURN = 13;
const ASCII_SPACE = 32;
const ASCII_PERCENT = 37;
const LOWERCASE_A = 97;
const LOWERCASE_F = 102;
const LOWERCASE_Z = 122;
const UPPERCASE_A = 65;
const UPPERCASE_F = 70;
const UPPERCASE_Z = 90;
const DIGIT_ZERO = 48;
const DIGIT_NINE = 57;
const ASCII_DASH = 45;
const ASCII_DOT = 46;
const ASCII_UNDERSCORE = 95;
const ASCII_TILDE = 126;
const HEX_RADIX = 16;
const HEX_ESCAPE_WIDTH = 2;
const ESCAPE_WIDTH = 3;
const FIRST_INDEX = 0;
const NOT_FOUND = -1;
const FIRST_ESCAPE_HEX_INDEX = 1;
const SECOND_ESCAPE_HEX_INDEX = 2;
const MAX_INPUT_LENGTH = 1024,
MAX_ISSUES = 16,
SCHEME = "vers",
SCHEME_PREFIX = "vers:",
ASCII_TAB = 9,
ASCII_LINE_FEED = 10,
ASCII_VERTICAL_TAB = 11,
ASCII_FORM_FEED = 12,
ASCII_CARRIAGE_RETURN = 13,
ASCII_SPACE = 32,
ASCII_PERCENT = 37,
LOWERCASE_A = 97,
LOWERCASE_F = 102,
LOWERCASE_Z = 122,
UPPERCASE_A = 65,
UPPERCASE_F = 70,
UPPERCASE_Z = 90,
DIGIT_ZERO = 48,
DIGIT_NINE = 57,
ASCII_DASH = 45,
ASCII_DOT = 46,
ASCII_UNDERSCORE = 95,
ASCII_TILDE = 126,
HEX_RADIX = 16,
HEX_ESCAPE_WIDTH = 2,
ESCAPE_WIDTH = 3,
FIRST_INDEX = 0,
NOT_FOUND = -1,
FIRST_ESCAPE_HEX_INDEX = 1,
SECOND_ESCAPE_HEX_INDEX = 2;

interface ParseSuccess {
ok: true;
Expand Down Expand Up @@ -116,7 +116,7 @@
return this.#failure();
}

const constraints = this.#parseSegments(segments);

Check warning on line 119 in src/parser.ts

View workflow job for this annotation

GitHub Actions / Auto-fix formatting and lint issues

eslint(one-var)

src/parser.ts:119:5: Combine this with the previous 'const' statement.

if (this.#hasIssues()) {
return this.#failure();
Expand Down Expand Up @@ -181,8 +181,8 @@
}

private static compareIssues(left: VersIssue, right: VersIssue): number {
const leftStart = left.span?.start ?? Number.POSITIVE_INFINITY;
const rightStart = right.span?.start ?? Number.POSITIVE_INFINITY;
const leftStart = left.span?.start ?? Number.POSITIVE_INFINITY,
rightStart = right.span?.start ?? Number.POSITIVE_INFINITY;

if (leftStart !== rightStart) {
return leftStart - rightStart;
Expand Down Expand Up @@ -247,7 +247,7 @@
return undefined;
}

const slashIndex = this.#constraintSeparatorIndex();

Check warning on line 250 in src/parser.ts

View workflow job for this annotation

GitHub Actions / Auto-fix formatting and lint issues

eslint(one-var)

src/parser.ts:250:5: Combine this with the previous 'const' statement.

if (slashIndex === undefined) {
return this.#parseMissingSlash();
Expand Down Expand Up @@ -353,10 +353,10 @@
}

#addTypeIssue(type: string, offset: number, index: number): void {
const codeUnit = type.charCodeAt(index);
const code = Parser.isUppercaseLetter(codeUnit)
? "syntax.invalid_type_case"
: "lexical.invalid_character";
const codeUnit = type.charCodeAt(index),
code = Parser.isUppercaseLetter(codeUnit)
? "syntax.invalid_type_case"
: "lexical.invalid_character";
this.#add({ code, span: { end: offset + index + 1, start: offset + index } });
}

Expand Down Expand Up @@ -485,7 +485,7 @@
return undefined;
}

const decoded = this.#decodeVersion(region);

Check warning on line 488 in src/parser.ts

View workflow job for this annotation

GitHub Actions / Auto-fix formatting and lint issues

eslint(one-var)

src/parser.ts:488:5: Combine this with the previous 'const' statement.

if (decoded === undefined) {
return undefined;
Expand All @@ -505,7 +505,7 @@
return undefined;
}

const raw = segment.text.slice(comparator.length);

Check warning on line 508 in src/parser.ts

View workflow job for this annotation

GitHub Actions / Auto-fix formatting and lint issues

eslint(one-var)

src/parser.ts:508:5: Combine this with the previous 'const' statement.

if (raw.length === 0) {
const point = segment.start + comparator.length;
Expand Down
Loading