@seangalie/precast 0.0.0-stage → 0.2.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/CHANGELOG.md +64 -0
- package/LICENSE +202 -0
- package/README.md +274 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +3 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +251 -0
- package/dist/collect.d.ts +17 -0
- package/dist/collect.js +143 -0
- package/dist/context.d.ts +38 -0
- package/dist/context.js +206 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +8 -0
- package/dist/fnmatch.d.ts +9 -0
- package/dist/fnmatch.js +110 -0
- package/dist/generate.d.ts +23 -0
- package/dist/generate.js +76 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/output-path.d.ts +30 -0
- package/dist/output-path.js +84 -0
- package/dist/platforms.d.ts +22 -0
- package/dist/platforms.js +81 -0
- package/dist/profiles.d.ts +23 -0
- package/dist/profiles.js +79 -0
- package/dist/prompts.d.ts +30 -0
- package/dist/prompts.js +103 -0
- package/dist/style.d.ts +14 -0
- package/dist/style.js +34 -0
- package/dist/tiers.d.ts +23 -0
- package/dist/tiers.js +96 -0
- package/package.json +44 -4
- package/platforms/forgejo/files/.forgejo/CODEOWNERS.tmpl +2 -0
- package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/01_bug_report.yml.tmpl +83 -0
- package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/02_feature_request.yml.tmpl +57 -0
- package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/03_codebase_improvement.yml.tmpl +44 -0
- package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/04_support_question.yml.tmpl +47 -0
- package/platforms/forgejo/files/.forgejo/ISSUE_TEMPLATE/config.yml.tmpl +13 -0
- package/platforms/forgejo/files/.forgejo/PULL_REQUEST_TEMPLATE.md.tmpl +49 -0
- package/platforms/forgejo/files/.forgejo/SETUP.md.tmpl +65 -0
- package/platforms/forgejo/files/.forgejo/labels.yml.tmpl +99 -0
- package/platforms/forgejo/files/.forgejo/scripts/check-labels.sh.tmpl +91 -0
- package/platforms/forgejo/files/.forgejo/scripts/sync-labels.sh.tmpl +165 -0
- package/platforms/forgejo/files/.forgejo/workflows/labels.yml.tmpl +45 -0
- package/platforms/forgejo/files/.forgejo/workflows/lint.yml.tmpl +78 -0
- package/platforms/forgejo/files/.forgejo/workflows/pr-labels.yml.tmpl +51 -0
- package/platforms/forgejo/files/.forgejo/workflows/pre-commit.yml.tmpl +24 -0
- package/platforms/forgejo/files/.forgejo/workflows/release.yml.tmpl +130 -0
- package/platforms/forgejo/files/.forgejo/workflows/renovate.yml.tmpl +61 -0
- package/platforms/forgejo/files/.forgejo/workflows/stale.yml.tmpl +260 -0
- package/platforms/forgejo/files/renovate.json +36 -0
- package/platforms/forgejo/platform.json +41 -0
- package/platforms/github/files/.github/CODEOWNERS.tmpl +2 -0
- package/platforms/github/files/.github/ISSUE_TEMPLATE/01_bug_report.yml.tmpl +83 -0
- package/platforms/github/files/.github/ISSUE_TEMPLATE/02_feature_request.yml.tmpl +57 -0
- package/platforms/github/files/.github/ISSUE_TEMPLATE/03_codebase_improvement.yml.tmpl +44 -0
- package/platforms/github/files/.github/ISSUE_TEMPLATE/04_support_question.yml.tmpl +47 -0
- package/platforms/github/files/.github/ISSUE_TEMPLATE/config.yml.tmpl +16 -0
- package/platforms/github/files/.github/PULL_REQUEST_TEMPLATE.md.tmpl +49 -0
- package/platforms/github/files/.github/SETUP.md.tmpl +46 -0
- package/platforms/github/files/.github/dependabot.yml.tmpl +75 -0
- package/platforms/github/files/.github/labels.yml.tmpl +103 -0
- package/platforms/github/files/.github/release.yml.tmpl +47 -0
- package/platforms/github/files/.github/workflows/ci.yml.tmpl +55 -0
- package/platforms/github/files/.github/workflows/codeql.yml.tmpl +63 -0
- package/platforms/github/files/.github/workflows/labels.yml.tmpl +34 -0
- package/platforms/github/files/.github/workflows/lint-workflows.yml.tmpl +75 -0
- package/platforms/github/files/.github/workflows/lint.yml.tmpl +69 -0
- package/platforms/github/files/.github/workflows/lock.yml.tmpl +46 -0
- package/platforms/github/files/.github/workflows/pr-labels.yml.tmpl +26 -0
- package/platforms/github/files/.github/workflows/pre-commit.yml.tmpl +25 -0
- package/platforms/github/files/.github/workflows/release.yml.tmpl +101 -0
- package/platforms/github/files/.github/workflows/stale.yml.tmpl +57 -0
- package/platforms/github/platform.json +44 -0
- package/platforms/gitlab/files/.gitlab/CODEOWNERS.tmpl +2 -0
- package/platforms/gitlab/files/.gitlab/SETUP.md.tmpl +65 -0
- package/platforms/gitlab/files/.gitlab/issue_templates/01_bug_report.md +18 -0
- package/platforms/gitlab/files/.gitlab/issue_templates/02_feature_request.md +11 -0
- package/platforms/gitlab/files/.gitlab/issue_templates/03_codebase_improvement.md +11 -0
- package/platforms/gitlab/files/.gitlab/issue_templates/04_support_question.md +12 -0
- package/platforms/gitlab/files/.gitlab/labels.json +122 -0
- package/platforms/gitlab/files/.gitlab/merge_request_templates/Default.md +14 -0
- package/platforms/gitlab/files/.gitlab/scripts/project.py +159 -0
- package/platforms/gitlab/files/.gitlab-ci.yml.tmpl +56 -0
- package/platforms/gitlab/platform.json +38 -0
- package/template/.editorconfig.tmpl +54 -0
- package/template/.gitattributes +107 -0
- package/template/.gitignore.tmpl +244 -0
- package/template/.pre-commit-config.yaml.tmpl +55 -0
- package/template/.repo/check-secrets.py +40 -0
- package/template/.repo/ci-checks.sh +20 -0
- package/template/AGENTS.md.tmpl +78 -0
- package/template/CHANGELOG.md.tmpl +24 -0
- package/template/CLAUDE.md +1 -0
- package/template/LICENSE +202 -0
- package/template/README.md.tmpl +101 -0
- package/template/SETUP.md.tmpl +56 -0
- package/template/docs/CODE_OF_CONDUCT.md +85 -0
- package/template/docs/CONTRIBUTING.md.tmpl +59 -0
- package/template/docs/SECURITY.md.tmpl +26 -0
- package/template/docs/SUPPORT.md.tmpl +19 -0
- package/template/docs/logo.svg +84 -0
- package/template/docs/screenshot.png +0 -0
- package/tiers.json +10 -0
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { createInterface } from "node:readline/promises";
|
|
2
|
+
import { checkNamespace, checkRepo } from "./context.js";
|
|
3
|
+
import { PrecastError } from "./errors.js";
|
|
4
|
+
import { checkOutput } from "./generate.js";
|
|
5
|
+
import { platformNames, readPlatform } from "./platforms.js";
|
|
6
|
+
import { paint } from "./style.js";
|
|
7
|
+
import { DEFAULT_TIER, isTier, TIERS } from "./tiers.js";
|
|
8
|
+
const TIER_SUMMARIES = {
|
|
9
|
+
slim: "the essentials, for personal projects and experiments",
|
|
10
|
+
regular: "adds policies, templates, pre-commit, and CI",
|
|
11
|
+
full: "adds labels, releases, and housekeeping automation",
|
|
12
|
+
};
|
|
13
|
+
/** Thrown when the person cancels a prompt, so nothing is generated. */
|
|
14
|
+
export class Cancelled extends Error {
|
|
15
|
+
constructor() {
|
|
16
|
+
super("Cancelled; no files were written");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Ask for each missing required value in turn. Answers go through the same
|
|
21
|
+
* checks as command-line options, and an invalid answer is asked again.
|
|
22
|
+
*/
|
|
23
|
+
export async function promptForMissing(values, ask, write, root, { stream, askTier = false } = {}) {
|
|
24
|
+
const answer = async (label, hint, check) => {
|
|
25
|
+
const shown = hint ? ` ${paint("dim", hint, stream)}` : "";
|
|
26
|
+
const question = `${paint("cyan", "?", stream)} ${paint("bold", label, stream)}${shown} ${paint("dim", "›", stream)} `;
|
|
27
|
+
for (;;) {
|
|
28
|
+
const reply = await ask(question);
|
|
29
|
+
if (reply === undefined)
|
|
30
|
+
throw new Cancelled();
|
|
31
|
+
try {
|
|
32
|
+
return check(reply.trim());
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (!(error instanceof PrecastError))
|
|
36
|
+
throw error;
|
|
37
|
+
write(` ${paint("red", `✗ ${error.message}`, stream)}\n`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
let platform = values.platform;
|
|
42
|
+
if (platform === undefined) {
|
|
43
|
+
const names = platformNames(root);
|
|
44
|
+
write(`${paint("bold", "Platforms", stream)}\n`);
|
|
45
|
+
for (const [index, name] of names.entries()) {
|
|
46
|
+
write(` ${paint("cyan", String(index + 1), stream)} ${name}\n`);
|
|
47
|
+
}
|
|
48
|
+
platform = await answer("Platform", `(1-${names.length} or a name)`, (reply) => {
|
|
49
|
+
const chosen = names[Number(reply) - 1] ?? reply;
|
|
50
|
+
if (!names.includes(chosen)) {
|
|
51
|
+
throw new PrecastError(`Choose 1-${names.length} or one of: ${names.join(", ")}`);
|
|
52
|
+
}
|
|
53
|
+
return chosen;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
let tier;
|
|
57
|
+
if (askTier) {
|
|
58
|
+
write(`${paint("bold", "Tiers", stream)} ${paint("dim", "(each adds to the one before)", stream)}\n`);
|
|
59
|
+
const width = Math.max(...TIERS.map((name) => name.length));
|
|
60
|
+
for (const [index, name] of TIERS.entries()) {
|
|
61
|
+
const summary = paint("dim", TIER_SUMMARIES[name], stream);
|
|
62
|
+
write(` ${paint("cyan", String(index + 1), stream)} ${name.padEnd(width)} ${summary}\n`);
|
|
63
|
+
}
|
|
64
|
+
tier = await answer("Tier", `(1-${TIERS.length} or a name, Enter for ${DEFAULT_TIER})`, (reply) => {
|
|
65
|
+
const chosen = reply === "" ? DEFAULT_TIER : (TIERS[Number(reply) - 1] ?? reply);
|
|
66
|
+
if (!isTier(chosen)) {
|
|
67
|
+
throw new PrecastError(`Choose 1-${TIERS.length} or one of: ${TIERS.join(", ")}`);
|
|
68
|
+
}
|
|
69
|
+
return chosen;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const nested = readPlatform(root, platform).nested_namespaces;
|
|
73
|
+
const namespace = values.namespace ??
|
|
74
|
+
(await answer("Namespace", nested ? "(owner, organization, or group/subgroup)" : "(owner or organization)", (reply) => checkNamespace(reply, nested)));
|
|
75
|
+
const repo = values.repo ?? (await answer("Repository name", "", checkRepo));
|
|
76
|
+
const output = values.output ??
|
|
77
|
+
(await answer("Output folder", `(${repo})`, (reply) => {
|
|
78
|
+
const folder = reply || repo;
|
|
79
|
+
// The generator's own check, so an answer it would refuse is asked again.
|
|
80
|
+
checkOutput(folder, root);
|
|
81
|
+
return folder;
|
|
82
|
+
}));
|
|
83
|
+
return tier === undefined
|
|
84
|
+
? { platform, namespace, repo, output }
|
|
85
|
+
: { platform, namespace, repo, output, tier };
|
|
86
|
+
}
|
|
87
|
+
/** Ask questions on the terminal, treating Ctrl+C and Ctrl+D as cancelling. */
|
|
88
|
+
export async function withTerminal(input, output, use) {
|
|
89
|
+
const terminal = createInterface({ input, output });
|
|
90
|
+
const closed = new Promise((resolve) => terminal.once("close", () => resolve(undefined)));
|
|
91
|
+
terminal.on("SIGINT", () => terminal.close());
|
|
92
|
+
try {
|
|
93
|
+
// Closing the terminal can also reject the pending question; both mean cancel.
|
|
94
|
+
return await use((question) => Promise.race([terminal.question(question).catch(() => undefined), closed]));
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
terminal.close();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Quote an argument for a POSIX shell only when it needs it. */
|
|
101
|
+
export function shellQuote(value) {
|
|
102
|
+
return /^[A-Za-z0-9_@%+=:,./-]+$/.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
|
|
103
|
+
}
|
package/dist/style.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
type Format = Parameters<typeof styleText>[0];
|
|
3
|
+
/**
|
|
4
|
+
* Whether to color output for `stream`: only a terminal, and never when
|
|
5
|
+
* `NO_COLOR`, `NODE_DISABLE_COLORS`, `FORCE_COLOR=0`, or `TERM=dumb` asks for
|
|
6
|
+
* plain text. `FORCE_COLOR` cannot turn color on for a pipe or file, so logs
|
|
7
|
+
* and tests never contain escape codes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function colorEnabled(stream?: NodeJS.WritableStream, env?: NodeJS.ProcessEnv): boolean;
|
|
10
|
+
/** Style text for `stream` when `colorEnabled` allows it; otherwise return it unchanged. */
|
|
11
|
+
export declare function paint(format: Format, text: string, stream?: NodeJS.WritableStream): string;
|
|
12
|
+
/** The banner shown before the first question. */
|
|
13
|
+
export declare function header(version: string, stream?: NodeJS.WritableStream): string;
|
|
14
|
+
export {};
|
package/dist/style.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
/**
|
|
3
|
+
* Whether to color output for `stream`: only a terminal, and never when
|
|
4
|
+
* `NO_COLOR`, `NODE_DISABLE_COLORS`, `FORCE_COLOR=0`, or `TERM=dumb` asks for
|
|
5
|
+
* plain text. `FORCE_COLOR` cannot turn color on for a pipe or file, so logs
|
|
6
|
+
* and tests never contain escape codes.
|
|
7
|
+
*/
|
|
8
|
+
export function colorEnabled(stream = process.stdout, env = process.env) {
|
|
9
|
+
if (stream.isTTY !== true)
|
|
10
|
+
return false;
|
|
11
|
+
return !(env.NO_COLOR ||
|
|
12
|
+
env.NODE_DISABLE_COLORS ||
|
|
13
|
+
env.FORCE_COLOR === "0" ||
|
|
14
|
+
env.TERM === "dumb");
|
|
15
|
+
}
|
|
16
|
+
/** Style text for `stream` when `colorEnabled` allows it; otherwise return it unchanged. */
|
|
17
|
+
export function paint(format, text, stream = process.stdout) {
|
|
18
|
+
return colorEnabled(stream) ? styleText(format, text, { validateStream: false }) : text;
|
|
19
|
+
}
|
|
20
|
+
// figlet's Standard font at full width, kept to ASCII so every terminal shows it.
|
|
21
|
+
const WORDMARK = [
|
|
22
|
+
" _",
|
|
23
|
+
" _ __ _ __ ___ ___ __ _ ___ | |_",
|
|
24
|
+
"| '_ \\ | '__| / _ \\ / __| / _` |/ __|| __|",
|
|
25
|
+
"| |_) || | | __/| (__ | (_| |\\__ \\| |_",
|
|
26
|
+
"| .__/ |_| \\___| \\___| \\__,_||___/ \\__|",
|
|
27
|
+
"|_|",
|
|
28
|
+
];
|
|
29
|
+
/** The banner shown before the first question. */
|
|
30
|
+
export function header(version, stream) {
|
|
31
|
+
const art = WORDMARK.map((line) => ` ${paint("cyan", line, stream)}`).join("\n");
|
|
32
|
+
const tagline = paint("dim", ` Start a new project with its checks in place · v${version}`, stream);
|
|
33
|
+
return `\n${art}\n\n${tagline}\n\n`;
|
|
34
|
+
}
|
package/dist/tiers.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Each tier includes everything in the tiers before it. */
|
|
2
|
+
export declare const TIERS: readonly ["slim", "regular", "full"];
|
|
3
|
+
export type Tier = (typeof TIERS)[number];
|
|
4
|
+
export declare const DEFAULT_TIER: Tier;
|
|
5
|
+
export declare function isTier(value: string): value is Tier;
|
|
6
|
+
export declare function tierIndex(tier: Tier): number;
|
|
7
|
+
export interface TierPattern {
|
|
8
|
+
/** The first tier that includes matching files. */
|
|
9
|
+
tier: Tier;
|
|
10
|
+
regex: RegExp;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Map output patterns to the first tier that includes them. Files no pattern
|
|
14
|
+
* matches belong to every tier, so only `regular` and `full` may be listed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function tierPatterns(manifest: unknown, label: string): Map<string, TierPattern>;
|
|
17
|
+
/**
|
|
18
|
+
* Keep the lines of `@@TIERS ...@@` blocks that list `tier` and drop the rest.
|
|
19
|
+
* Every line is checked, including those the selected tier drops, so a
|
|
20
|
+
* malformed block fails in every tier rather than only where it is kept.
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderTierBlocks(text: string, tier: Tier, source: string): string;
|
|
23
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
package/dist/tiers.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { PrecastError } from "./errors.js";
|
|
2
|
+
import { compilePattern } from "./fnmatch.js";
|
|
3
|
+
/** Each tier includes everything in the tiers before it. */
|
|
4
|
+
export const TIERS = ["slim", "regular", "full"];
|
|
5
|
+
export const DEFAULT_TIER = "regular";
|
|
6
|
+
const TIER_OPEN = /^[ \t]*@@TIERS((?: [a-z]+)+)@@[ \t]*\n$/;
|
|
7
|
+
const TIER_CLOSE = /^[ \t]*@@END_TIERS@@[ \t]*\n$/;
|
|
8
|
+
const TIER_MARKER = /@@(?:TIERS[ @]|END_TIERS@@)/;
|
|
9
|
+
export function isTier(value) {
|
|
10
|
+
return TIERS.includes(value);
|
|
11
|
+
}
|
|
12
|
+
export function tierIndex(tier) {
|
|
13
|
+
return TIERS.indexOf(tier);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Map output patterns to the first tier that includes them. Files no pattern
|
|
17
|
+
* matches belong to every tier, so only `regular` and `full` may be listed.
|
|
18
|
+
*/
|
|
19
|
+
export function tierPatterns(manifest, label) {
|
|
20
|
+
if (manifest === undefined) {
|
|
21
|
+
return new Map();
|
|
22
|
+
}
|
|
23
|
+
if (!isPlainObject(manifest)) {
|
|
24
|
+
throw new PrecastError(`${label} tiers must be an object of pattern lists`);
|
|
25
|
+
}
|
|
26
|
+
const patterns = new Map();
|
|
27
|
+
for (const [tier, entries] of Object.entries(manifest)) {
|
|
28
|
+
if (tier !== "regular" && tier !== "full") {
|
|
29
|
+
throw new PrecastError(`${label} lists files for an unknown or base tier: '${tier}'`);
|
|
30
|
+
}
|
|
31
|
+
if (!Array.isArray(entries) || !entries.every((entry) => typeof entry === "string")) {
|
|
32
|
+
throw new PrecastError(`${label} tier '${tier}' must be a list of patterns`);
|
|
33
|
+
}
|
|
34
|
+
for (const pattern of entries) {
|
|
35
|
+
if (patterns.has(pattern)) {
|
|
36
|
+
throw new PrecastError(`${label} assigns '${pattern}' to more than one tier`);
|
|
37
|
+
}
|
|
38
|
+
let regex;
|
|
39
|
+
try {
|
|
40
|
+
regex = compilePattern(pattern);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new PrecastError(`${label} has an invalid pattern '${pattern}': ${error.message}`);
|
|
44
|
+
}
|
|
45
|
+
patterns.set(pattern, { tier, regex });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return patterns;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Keep the lines of `@@TIERS ...@@` blocks that list `tier` and drop the rest.
|
|
52
|
+
* Every line is checked, including those the selected tier drops, so a
|
|
53
|
+
* malformed block fails in every tier rather than only where it is kept.
|
|
54
|
+
*/
|
|
55
|
+
export function renderTierBlocks(text, tier, source) {
|
|
56
|
+
const output = [];
|
|
57
|
+
let block;
|
|
58
|
+
let number = 0;
|
|
59
|
+
for (const line of splitLines(text)) {
|
|
60
|
+
number += 1;
|
|
61
|
+
const opening = TIER_OPEN.exec(line);
|
|
62
|
+
if (opening) {
|
|
63
|
+
if (block !== undefined) {
|
|
64
|
+
throw new PrecastError(`Nested tier block at ${source}:${number}`);
|
|
65
|
+
}
|
|
66
|
+
block = (opening[1] ?? "").trim().split(" ");
|
|
67
|
+
const unknown = block.filter((name) => !isTier(name)).sort();
|
|
68
|
+
if (unknown.length > 0) {
|
|
69
|
+
throw new PrecastError(`Unknown tier '${unknown[0]}' at ${source}:${number}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (TIER_CLOSE.test(line)) {
|
|
73
|
+
if (block === undefined) {
|
|
74
|
+
throw new PrecastError(`Unmatched end of tier block at ${source}:${number}`);
|
|
75
|
+
}
|
|
76
|
+
block = undefined;
|
|
77
|
+
}
|
|
78
|
+
else if (TIER_MARKER.test(line)) {
|
|
79
|
+
throw new PrecastError(`Malformed tier block marker at ${source}:${number}`);
|
|
80
|
+
}
|
|
81
|
+
else if (block === undefined || block.includes(tier)) {
|
|
82
|
+
output.push(line);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (block !== undefined) {
|
|
86
|
+
throw new PrecastError(`Unterminated tier block in ${source}`);
|
|
87
|
+
}
|
|
88
|
+
return output.join("");
|
|
89
|
+
}
|
|
90
|
+
/** Split after each LF, keeping the terminators so joining restores the input. */
|
|
91
|
+
function splitLines(text) {
|
|
92
|
+
return text.match(/[^\n]*\n|[^\n]+$/g) ?? [];
|
|
93
|
+
}
|
|
94
|
+
export function isPlainObject(value) {
|
|
95
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
96
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seangalie/precast",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Generate new Forgejo, GitHub, and GitLab projects with documentation, checks, and forge settings in place",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Sean Galie",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"precast": "dist/bin.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"dist/",
|
|
20
|
+
"platforms/",
|
|
21
|
+
"template/",
|
|
22
|
+
"tiers.json",
|
|
23
|
+
"!**/__pycache__/**"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22.18"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
|
|
30
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
31
|
+
"lint": "biome check",
|
|
32
|
+
"format": "biome check --write",
|
|
33
|
+
"test": "node --test --experimental-strip-types \"test/**/*.test.ts\"",
|
|
34
|
+
"check-generated": "node --experimental-strip-types scripts/check-generated.ts",
|
|
35
|
+
"prepack": "npm run build",
|
|
36
|
+
"prepublishOnly": "npm run build && npm test && node scripts/check-package.ts"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@biomejs/biome": "2.6.8",
|
|
40
|
+
"@types/node": "22.20.5",
|
|
41
|
+
"typescript": "7.0.2"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 🐛 Bug Report
|
|
3
|
+
description: Report a defect so that this project can be fixed
|
|
4
|
+
title: "bug: "
|
|
5
|
+
labels: ["bug"]
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
Thanks for taking the time to file a report. The more precisely you can
|
|
11
|
+
describe the problem, the faster it can be reproduced and fixed.
|
|
12
|
+
|
|
13
|
+
- type: checkboxes
|
|
14
|
+
id: preflight
|
|
15
|
+
attributes:
|
|
16
|
+
label: Before you start
|
|
17
|
+
options:
|
|
18
|
+
- label: I searched the open and closed issues and this has not been reported yet.
|
|
19
|
+
required: true
|
|
20
|
+
- label: I am running the most recent version of this project.
|
|
21
|
+
required: true
|
|
22
|
+
|
|
23
|
+
- type: input
|
|
24
|
+
id: version
|
|
25
|
+
attributes:
|
|
26
|
+
label: Version
|
|
27
|
+
description: The release tag or commit SHA you are running.
|
|
28
|
+
placeholder: "v1.2.3, or 0a1b2c3"
|
|
29
|
+
validations:
|
|
30
|
+
required: true
|
|
31
|
+
|
|
32
|
+
- type: textarea
|
|
33
|
+
id: current
|
|
34
|
+
attributes:
|
|
35
|
+
label: Current behavior
|
|
36
|
+
description: What happens today? Describe how the bug manifests.
|
|
37
|
+
validations:
|
|
38
|
+
required: true
|
|
39
|
+
|
|
40
|
+
- type: textarea
|
|
41
|
+
id: expected
|
|
42
|
+
attributes:
|
|
43
|
+
label: Expected behavior
|
|
44
|
+
description: What did you expect to happen instead?
|
|
45
|
+
validations:
|
|
46
|
+
required: true
|
|
47
|
+
|
|
48
|
+
- type: textarea
|
|
49
|
+
id: steps
|
|
50
|
+
attributes:
|
|
51
|
+
label: Steps to reproduce
|
|
52
|
+
description: The exact sequence someone else can follow to see the same result.
|
|
53
|
+
value: |
|
|
54
|
+
1.
|
|
55
|
+
2.
|
|
56
|
+
3.
|
|
57
|
+
validations:
|
|
58
|
+
required: true
|
|
59
|
+
|
|
60
|
+
- type: textarea
|
|
61
|
+
id: environment
|
|
62
|
+
attributes:
|
|
63
|
+
label: Environment
|
|
64
|
+
description: Operating system, runtime version, browser -- whatever is relevant here.
|
|
65
|
+
validations:
|
|
66
|
+
required: false
|
|
67
|
+
|
|
68
|
+
- type: textarea
|
|
69
|
+
id: logs
|
|
70
|
+
attributes:
|
|
71
|
+
label: Relevant logs, errors, or code
|
|
72
|
+
description: This is rendered as a code block automatically, so no backticks are needed.
|
|
73
|
+
render: shell
|
|
74
|
+
validations:
|
|
75
|
+
required: false
|
|
76
|
+
|
|
77
|
+
- type: textarea
|
|
78
|
+
id: context
|
|
79
|
+
attributes:
|
|
80
|
+
label: Anything else?
|
|
81
|
+
description: Related issues, suggested fixes, or links to discussion elsewhere.
|
|
82
|
+
validations:
|
|
83
|
+
required: false
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ✨ Feature Request
|
|
3
|
+
description: Suggest an idea for this project
|
|
4
|
+
title: "feat: "
|
|
5
|
+
labels: ["enhancement"]
|
|
6
|
+
body:
|
|
7
|
+
- type: checkboxes
|
|
8
|
+
id: preflight
|
|
9
|
+
attributes:
|
|
10
|
+
label: Before you start
|
|
11
|
+
options:
|
|
12
|
+
- label: I searched the open and closed issues and this has not been requested yet.
|
|
13
|
+
required: true
|
|
14
|
+
|
|
15
|
+
- type: textarea
|
|
16
|
+
id: problem
|
|
17
|
+
attributes:
|
|
18
|
+
label: What problem does this solve?
|
|
19
|
+
description: Describe the problem or limitation you are running into.
|
|
20
|
+
validations:
|
|
21
|
+
required: true
|
|
22
|
+
|
|
23
|
+
- type: textarea
|
|
24
|
+
id: solution
|
|
25
|
+
attributes:
|
|
26
|
+
label: Preferred solution
|
|
27
|
+
description: A clear description of what you would like to happen.
|
|
28
|
+
validations:
|
|
29
|
+
required: true
|
|
30
|
+
|
|
31
|
+
- type: textarea
|
|
32
|
+
id: alternatives
|
|
33
|
+
attributes:
|
|
34
|
+
label: Alternatives considered
|
|
35
|
+
description: Other approaches you looked at, and why they fall short.
|
|
36
|
+
validations:
|
|
37
|
+
required: false
|
|
38
|
+
|
|
39
|
+
- type: textarea
|
|
40
|
+
id: context
|
|
41
|
+
attributes:
|
|
42
|
+
label: Additional context
|
|
43
|
+
description: Use cases, example code, screenshots, links to prior art.
|
|
44
|
+
validations:
|
|
45
|
+
required: false
|
|
46
|
+
|
|
47
|
+
- type: dropdown
|
|
48
|
+
id: contribute
|
|
49
|
+
attributes:
|
|
50
|
+
label: Would you be willing to submit a pull request for this?
|
|
51
|
+
description: Help is available if you would like to try but are not sure where to start.
|
|
52
|
+
options:
|
|
53
|
+
- "Yes"
|
|
54
|
+
- "Yes, with guidance"
|
|
55
|
+
- "No"
|
|
56
|
+
validations:
|
|
57
|
+
required: true
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 🛠 Codebase Improvement
|
|
3
|
+
description: Suggest a better algorithm, structure, tool, or developer workflow
|
|
4
|
+
title: "dev: "
|
|
5
|
+
labels: ["enhancement", "refactor"]
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
Use this for changes that improve the codebase without changing what
|
|
11
|
+
@@PROJECT_NAME@@ does for its users -- refactors, tooling, build times,
|
|
12
|
+
test coverage, developer ergonomics.
|
|
13
|
+
|
|
14
|
+
- type: textarea
|
|
15
|
+
id: area
|
|
16
|
+
attributes:
|
|
17
|
+
label: What part of the codebase?
|
|
18
|
+
description: Files, modules, or workflows this concerns. Links to lines are welcome.
|
|
19
|
+
validations:
|
|
20
|
+
required: true
|
|
21
|
+
|
|
22
|
+
- type: textarea
|
|
23
|
+
id: current
|
|
24
|
+
attributes:
|
|
25
|
+
label: What is the current approach?
|
|
26
|
+
description: Describe how it works today and what makes it worth changing.
|
|
27
|
+
validations:
|
|
28
|
+
required: true
|
|
29
|
+
|
|
30
|
+
- type: textarea
|
|
31
|
+
id: proposal
|
|
32
|
+
attributes:
|
|
33
|
+
label: What would you change it to?
|
|
34
|
+
description: The improvement you have in mind, and the benefit it brings.
|
|
35
|
+
validations:
|
|
36
|
+
required: true
|
|
37
|
+
|
|
38
|
+
- type: textarea
|
|
39
|
+
id: tradeoffs
|
|
40
|
+
attributes:
|
|
41
|
+
label: Trade-offs and risks
|
|
42
|
+
description: What would this cost, break, or make harder?
|
|
43
|
+
validations:
|
|
44
|
+
required: false
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ❓ Support Question
|
|
3
|
+
description: Ask how to use this project
|
|
4
|
+
title: "support: "
|
|
5
|
+
labels: ["question"]
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
Use this form when you have a question about using @@PROJECT_NAME@@.
|
|
11
|
+
Something that looks like a defect belongs in a bug report instead.
|
|
12
|
+
|
|
13
|
+
- type: checkboxes
|
|
14
|
+
id: preflight
|
|
15
|
+
attributes:
|
|
16
|
+
label: Before you start
|
|
17
|
+
options:
|
|
18
|
+
- label: I read the README and the documentation.
|
|
19
|
+
required: true
|
|
20
|
+
- label: I searched the existing open and closed issues.
|
|
21
|
+
required: true
|
|
22
|
+
|
|
23
|
+
- type: textarea
|
|
24
|
+
id: question
|
|
25
|
+
attributes:
|
|
26
|
+
label: What are you trying to do?
|
|
27
|
+
description: Describe your goal, not only the step you are stuck on.
|
|
28
|
+
validations:
|
|
29
|
+
required: true
|
|
30
|
+
|
|
31
|
+
- type: textarea
|
|
32
|
+
id: tried
|
|
33
|
+
attributes:
|
|
34
|
+
label: What have you tried so far?
|
|
35
|
+
description: Commands, configuration, or code you have already attempted.
|
|
36
|
+
render: shell
|
|
37
|
+
validations:
|
|
38
|
+
required: false
|
|
39
|
+
|
|
40
|
+
- type: input
|
|
41
|
+
id: version
|
|
42
|
+
attributes:
|
|
43
|
+
label: Version
|
|
44
|
+
description: The release tag or commit SHA you are running.
|
|
45
|
+
placeholder: "v1.2.3, or 0a1b2c3"
|
|
46
|
+
validations:
|
|
47
|
+
required: false
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
blank_issues_enabled: false
|
|
3
|
+
|
|
4
|
+
contact_links:
|
|
5
|
+
- name: 📖 Contributing guide
|
|
6
|
+
url: @@REPO_URL@@/src/branch/@@BRANCH_URL@@/docs/CONTRIBUTING.md
|
|
7
|
+
about: How to set up a development environment and open a pull request.
|
|
8
|
+
- name: 🔒 Report a security vulnerability
|
|
9
|
+
url: @@REPO_URL@@/src/branch/@@BRANCH_URL@@/docs/SECURITY.md
|
|
10
|
+
about: Never open a public issue for a vulnerability. The security policy explains how to report one privately.
|
|
11
|
+
- name: 💬 Support guide
|
|
12
|
+
url: @@REPO_URL@@/src/branch/@@BRANCH_URL@@/docs/SUPPORT.md
|
|
13
|
+
about: Where to ask what, and what to expect.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<!--- Please provide a general summary of your changes in the title above -->
|
|
2
|
+
|
|
3
|
+
## Pull Request type
|
|
4
|
+
|
|
5
|
+
<!-- Please try to limit your pull request to one type; submit multiple pull requests if needed. -->
|
|
6
|
+
|
|
7
|
+
Please check the type of change your PR introduces:
|
|
8
|
+
|
|
9
|
+
- [ ] Bugfix
|
|
10
|
+
- [ ] Feature
|
|
11
|
+
- [ ] Code style update (formatting, renaming)
|
|
12
|
+
- [ ] Refactoring (no functional changes, no API changes)
|
|
13
|
+
- [ ] Build-related changes
|
|
14
|
+
- [ ] Documentation content changes
|
|
15
|
+
- [ ] Other (please describe):
|
|
16
|
+
|
|
17
|
+
## What is the current behavior?
|
|
18
|
+
|
|
19
|
+
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
|
|
20
|
+
|
|
21
|
+
Issue Number: N/A
|
|
22
|
+
|
|
23
|
+
## What is the new behavior?
|
|
24
|
+
|
|
25
|
+
<!-- Please describe the behavior or changes that are being added by this PR. -->
|
|
26
|
+
|
|
27
|
+
-
|
|
28
|
+
-
|
|
29
|
+
-
|
|
30
|
+
|
|
31
|
+
## Does this introduce a breaking change?
|
|
32
|
+
|
|
33
|
+
- [ ] Yes
|
|
34
|
+
- [ ] No
|
|
35
|
+
|
|
36
|
+
<!-- If this does introduce a breaking change, please describe the impact and migration path for existing applications below. -->
|
|
37
|
+
|
|
38
|
+
## Other information
|
|
39
|
+
|
|
40
|
+
<!-- Any other information that is important to this PR, such as screenshots of how the component looks before and after the change. -->
|
|
41
|
+
|
|
42
|
+
## Checklist
|
|
43
|
+
|
|
44
|
+
@@TIERS full@@
|
|
45
|
+
- [ ] This PR has a label saying what kind of change it is, such as `bugfix`, `new-feature` or `documentation`. The `PR Labels` check lists the accepted ones if it is missing, and a maintainer can add it for you.
|
|
46
|
+
@@END_TIERS@@
|
|
47
|
+
- [ ] User-visible changes are recorded under `## [Unreleased]` in [CHANGELOG.md](@@REPO_URL@@/src/branch/@@BRANCH_URL@@/CHANGELOG.md).
|
|
48
|
+
- [ ] Commit messages follow [conventional commits](https://www.conventionalcommits.org).
|
|
49
|
+
- [ ] Documentation has been updated where it was affected.
|