@seangalie/precast 0.0.0-stage → 0.1.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 +28 -0
- package/LICENSE +202 -0
- package/README.md +217 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +3 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +140 -0
- package/dist/collect.d.ts +17 -0
- package/dist/collect.js +143 -0
- package/dist/context.d.ts +32 -0
- package/dist/context.js +159 -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 +17 -0
- package/dist/generate.js +67 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/output-path.d.ts +30 -0
- package/dist/output-path.js +84 -0
- package/dist/platforms.d.ts +17 -0
- package/dist/platforms.js +62 -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 +61 -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 +62 -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 +54 -0
- package/platforms/gitlab/platform.json +34 -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 +43 -0
- package/template/.repo/check-secrets.py +40 -0
- package/template/.repo/ci-checks.sh +18 -0
- package/template/AGENTS.md.tmpl +75 -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 +47 -0
- package/template/docs/CODE_OF_CONDUCT.md +85 -0
- package/template/docs/CONTRIBUTING.md.tmpl +54 -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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
I record notable changes using [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
4
|
+
and [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-11-17
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- A `precast` command, packaged for npm as `@seangalie/precast`, that generates
|
|
13
|
+
Forgejo, GitHub, and GitLab repositories from shared project content and
|
|
14
|
+
automatically discovered platform files. It needs Node.js 22.18 or newer and
|
|
15
|
+
has no runtime dependencies.
|
|
16
|
+
- Three cumulative tiers, `slim`, `regular` (the default), and `full`.
|
|
17
|
+
- GitLab subgroup support, native templates, label tooling, a CI starter, and
|
|
18
|
+
release notes.
|
|
19
|
+
- Input, descriptor, and collision validation, previews with `--dry-run`, and
|
|
20
|
+
`--help` and `--version`.
|
|
21
|
+
- Pre-commit checks for generated repositories, with platform CI jobs and
|
|
22
|
+
explicit local hook installation.
|
|
23
|
+
|
|
24
|
+
I ported Precast from my earlier Python generator. Its output is byte-identical
|
|
25
|
+
for every platform and tier, and the template format is unchanged. Two checks
|
|
26
|
+
are stricter than before: the output path is resolved through symlinks and
|
|
27
|
+
letter case before `..` applies, and file/directory collisions fail in every
|
|
28
|
+
tier, not only in the tier that includes both files.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Sean Galie
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,218 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Precast
|
|
4
|
+
|
|
5
|
+
Start a new project with its documentation, checks, and forge settings already in place
|
|
6
|
+
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<details open="open">
|
|
10
|
+
<summary>Table of Contents</summary>
|
|
11
|
+
|
|
12
|
+
- [About](#about)
|
|
13
|
+
- [Tiers](#tiers)
|
|
14
|
+
- [Platforms](#platforms)
|
|
15
|
+
- [Getting Started](#getting-started)
|
|
16
|
+
- [Prerequisites](#prerequisites)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [Generate a project](#generate-a-project)
|
|
20
|
+
- [Publish it](#publish-it)
|
|
21
|
+
- [Options](#options)
|
|
22
|
+
- [What Precast will not do](#what-precast-will-not-do)
|
|
23
|
+
- [Roadmap](#roadmap)
|
|
24
|
+
- [Changelog](#changelog)
|
|
25
|
+
- [Support](#support)
|
|
26
|
+
- [Contributing](#contributing)
|
|
27
|
+
- [Authors & contributors](#authors--contributors)
|
|
28
|
+
- [Security](#security)
|
|
29
|
+
- [License](#license)
|
|
30
|
+
|
|
31
|
+
</details>
|
|
32
|
+
|
|
33
|
+
## About
|
|
34
|
+
|
|
35
|
+
Every new repository I start needs the same groundwork: a README, a license, a
|
|
36
|
+
changelog, contributing and security policies, issue templates, CI checks, and
|
|
37
|
+
instructions for coding agents. Precast keeps one copy of all of that and turns
|
|
38
|
+
it into a fresh, personalized project folder for Forgejo, GitHub, or GitLab.
|
|
39
|
+
|
|
40
|
+
You run one command on your own computer. Precast fills in the project's name,
|
|
41
|
+
links, and default branch, writes the files into a new folder, and stops. Nothing
|
|
42
|
+
is uploaded and no accounts are touched; you look the result over and push it
|
|
43
|
+
when you are ready.
|
|
44
|
+
|
|
45
|
+
### Tiers
|
|
46
|
+
|
|
47
|
+
Not every project needs every file, so Precast comes in three sizes. Each tier
|
|
48
|
+
includes everything in the one before it.
|
|
49
|
+
|
|
50
|
+
| Tier | Good for | What you get |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `slim` | Personal projects, experiments, and notes | README, license, changelog, agent instructions, editor and Git settings, placeholder images, and a setup checklist |
|
|
53
|
+
| `regular` | Most projects; this is the default | Everything in slim, plus contributing, security, support, and conduct policies, issue and pull request templates, code owners, pre-commit checks, and CI that runs them |
|
|
54
|
+
| `full` | Projects other people will rely on | Everything in regular, plus a label catalog and label checks, release publishing from the changelog, and the platform's housekeeping: stale and lock workflows, Renovate or Dependabot, and CodeQL |
|
|
55
|
+
|
|
56
|
+
If you are not sure, start with `regular`. A project can always grow into the
|
|
57
|
+
extra files later.
|
|
58
|
+
|
|
59
|
+
### Platforms
|
|
60
|
+
|
|
61
|
+
| Platform | Default server | Platform files |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `forgejo` | `https://git.galie.io` | `.forgejo/`, plus `renovate.json` in full |
|
|
64
|
+
| `github` | `https://github.com` | `.github/` |
|
|
65
|
+
| `gitlab` | `https://git.pppl.gov` | `.gitlab/`, plus `.gitlab-ci.yml` in regular and full |
|
|
66
|
+
|
|
67
|
+
Each platform keeps its own native formats: Forgejo and GitHub use issue forms
|
|
68
|
+
and Actions workflows, and GitLab uses Markdown templates and GitLab CI. Any of
|
|
69
|
+
them can point at a different server with `--server-url`.
|
|
70
|
+
|
|
71
|
+
## Getting Started
|
|
72
|
+
|
|
73
|
+
### Prerequisites
|
|
74
|
+
|
|
75
|
+
- Node.js 22.18 or newer, which includes npm. Precast has no other runtime
|
|
76
|
+
dependencies.
|
|
77
|
+
- Git, to publish the project you generate.
|
|
78
|
+
- An account on the forge where the new project will live. For PPPL's GitLab,
|
|
79
|
+
you also need to be on PPPL's VPN when you push.
|
|
80
|
+
|
|
81
|
+
### Installation
|
|
82
|
+
|
|
83
|
+
You can run Precast without installing it, using `npx`:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
npx @seangalie/precast --help
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Or install the `precast` command once and run it from anywhere:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
npm install --global @seangalie/precast
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The examples below use `precast`. If you did not install it, use
|
|
96
|
+
`npx @seangalie/precast` in its place.
|
|
97
|
+
|
|
98
|
+
## Usage
|
|
99
|
+
|
|
100
|
+
### Generate a project
|
|
101
|
+
|
|
102
|
+
Run `precast` from the folder where you keep your projects. This creates a
|
|
103
|
+
`regular` GitHub project for the account `my-name` in a new folder:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
precast --platform github --namespace my-name \
|
|
107
|
+
--repo my-project --project-name 'My Project' \
|
|
108
|
+
--author 'My Name' --output my-project
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
To see what would be created without writing anything, add `--dry-run`. To
|
|
112
|
+
choose a different size, add `--tier slim` or `--tier full`:
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
precast --platform forgejo --namespace my-name \
|
|
116
|
+
--repo my-notes --tier slim --output my-notes --dry-run
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
For GitLab, the namespace can include subgroups:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
precast --platform gitlab --namespace group/subgroup \
|
|
123
|
+
--repo my-project --output my-project
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Publish it
|
|
127
|
+
|
|
128
|
+
Precast writes files and nothing else, so publishing is up to you:
|
|
129
|
+
|
|
130
|
+
1. Open the new folder and read `SETUP.md`. It lists what to fill in, such as
|
|
131
|
+
the `[?]` prompts in the README, and links to a checklist for your platform.
|
|
132
|
+
2. Create an **empty** repository on the forge with the same name and the
|
|
133
|
+
visibility you want. Do not let the forge add a README or license.
|
|
134
|
+
3. Initialize, commit, and push:
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
cd my-project
|
|
138
|
+
git init -b main
|
|
139
|
+
git add .
|
|
140
|
+
git commit -m "chore: start from Precast"
|
|
141
|
+
git remote add origin https://github.com/my-name/my-project.git
|
|
142
|
+
git push -u origin main
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
4. Work through the platform checklist, such as `.github/SETUP.md`. In the
|
|
146
|
+
regular and full tiers, it covers runners, code owners, and branch
|
|
147
|
+
protection; full adds labels and releases. Delete both checklists when you
|
|
148
|
+
are done.
|
|
149
|
+
|
|
150
|
+
If you used `--default-branch`, use that name in place of `main` above.
|
|
151
|
+
|
|
152
|
+
### Options
|
|
153
|
+
|
|
154
|
+
| Option | What it does |
|
|
155
|
+
| --- | --- |
|
|
156
|
+
| `--platform` | `forgejo`, `github`, or `gitlab` (required) |
|
|
157
|
+
| `--namespace` | The user, organization, or GitLab group that will own the project (required) |
|
|
158
|
+
| `--repo` | The repository name, such as `my-project` (required) |
|
|
159
|
+
| `--output` | A new folder for the project; it must not exist yet (required) |
|
|
160
|
+
| `--tier` | `slim`, `regular`, or `full`; defaults to `regular` |
|
|
161
|
+
| `--project-name` | The title shown in the README; defaults to the repository name |
|
|
162
|
+
| `--author` | Your display name; defaults to the namespace |
|
|
163
|
+
| `--description` | A one-line description for the README |
|
|
164
|
+
| `--default-branch` | The main branch name; defaults to `main` |
|
|
165
|
+
| `--codeowner` | A user or team to own every file, such as `@my-name`; without it, the code owners file holds a commented example |
|
|
166
|
+
| `--runner` | The Actions runner label or GitLab runner tag for CI |
|
|
167
|
+
| `--server-url` | A different server than the platform's default |
|
|
168
|
+
| `--dry-run` | Check everything and list the files without writing them |
|
|
169
|
+
|
|
170
|
+
`precast --help` prints the same list, and `precast --version` prints the version.
|
|
171
|
+
|
|
172
|
+
### What Precast will not do
|
|
173
|
+
|
|
174
|
+
Precast never contacts a forge, runs Git, or asks for passwords or tokens. It
|
|
175
|
+
refuses to write into a folder that already exists or into the Precast folder
|
|
176
|
+
itself, so it cannot overwrite your work. If something is wrong with the
|
|
177
|
+
options, it says what and writes nothing.
|
|
178
|
+
|
|
179
|
+
The generated files are a starting point. They keep clear `[?]` prompts where
|
|
180
|
+
only you know the answer, such as the build commands or a private security
|
|
181
|
+
contact, rather than guessing.
|
|
182
|
+
|
|
183
|
+
## Roadmap
|
|
184
|
+
|
|
185
|
+
I track planned work and known bugs in my own issue tracker, which is not
|
|
186
|
+
public.
|
|
187
|
+
|
|
188
|
+
## Changelog
|
|
189
|
+
|
|
190
|
+
I record notable changes in `CHANGELOG.md`, which is included in the package.
|
|
191
|
+
|
|
192
|
+
## Support
|
|
193
|
+
|
|
194
|
+
Precast's repository is on my own Forgejo server, which requires an account.
|
|
195
|
+
If you have one, its issue tracker is the quickest route to me.
|
|
196
|
+
|
|
197
|
+
## Contributing
|
|
198
|
+
|
|
199
|
+
Changes to Precast go through a pull request with passing CI. In the repository,
|
|
200
|
+
the maintainer guide (`docs/MAINTAINING.md`) explains how it is laid out, how to
|
|
201
|
+
run the checks, and how tiers and platforms are defined. The design guide
|
|
202
|
+
(`docs/ARCHITECTURE.md`) covers the rendering rules in depth.
|
|
203
|
+
|
|
204
|
+
## Authors & contributors
|
|
205
|
+
|
|
206
|
+
Precast is by Sean Galie.
|
|
207
|
+
|
|
208
|
+
## Security
|
|
209
|
+
|
|
210
|
+
Precast runs only on your computer and writes only to the folder you name. If
|
|
211
|
+
you find a security problem in it or in the files it generates, please email
|
|
212
|
+
<precast@galie.io> rather than opening a public issue.
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
This project is licensed under the **Apache 2.0 license**.
|
|
217
|
+
|
|
218
|
+
See `LICENSE`, included in the package, for more information.
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function main(argv: string[], root?: string): number;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { DEFAULT_BRANCH, DEFAULT_DESCRIPTION } from "./context.js";
|
|
5
|
+
import { isSystemError, PrecastError } from "./errors.js";
|
|
6
|
+
import { generate, ROOT } from "./generate.js";
|
|
7
|
+
import { platformNames } from "./platforms.js";
|
|
8
|
+
import { DEFAULT_TIER, isTier, TIERS } from "./tiers.js";
|
|
9
|
+
const OPTIONS = {
|
|
10
|
+
platform: { type: "string" },
|
|
11
|
+
namespace: { type: "string" },
|
|
12
|
+
repo: { type: "string" },
|
|
13
|
+
output: { type: "string" },
|
|
14
|
+
tier: { type: "string" },
|
|
15
|
+
"server-url": { type: "string" },
|
|
16
|
+
"project-name": { type: "string" },
|
|
17
|
+
author: { type: "string" },
|
|
18
|
+
description: { type: "string" },
|
|
19
|
+
"default-branch": { type: "string" },
|
|
20
|
+
codeowner: { type: "string" },
|
|
21
|
+
runner: { type: "string" },
|
|
22
|
+
"dry-run": { type: "boolean" },
|
|
23
|
+
help: { type: "boolean", short: "h" },
|
|
24
|
+
version: { type: "boolean", short: "v" },
|
|
25
|
+
};
|
|
26
|
+
const REQUIRED = ["platform", "namespace", "repo", "output"];
|
|
27
|
+
function usage(root) {
|
|
28
|
+
return `Usage: precast --platform <id> --namespace <owner> --repo <name> --output <dir> [options]
|
|
29
|
+
|
|
30
|
+
Render shared files and one platform's native files into a new project directory.
|
|
31
|
+
|
|
32
|
+
Required:
|
|
33
|
+
--platform <id> ${platformNames(root).join(", ")}
|
|
34
|
+
--namespace <owner> Owner, organization, or GitLab group/subgroup
|
|
35
|
+
--repo <name> Repository slug
|
|
36
|
+
--output <dir> New directory outside the Precast source directory
|
|
37
|
+
|
|
38
|
+
Options:
|
|
39
|
+
--tier <tier> ${TIERS.join(", ")}; each tier adds to the previous one (default: ${DEFAULT_TIER})
|
|
40
|
+
--server-url <url> Override the platform's default instance URL
|
|
41
|
+
--project-name <name> Human-readable title; defaults to the repository slug
|
|
42
|
+
--author <name> Display name; defaults to the namespace
|
|
43
|
+
--description <text> Defaults to "${DEFAULT_DESCRIPTION}"
|
|
44
|
+
--default-branch <name> Defaults to ${DEFAULT_BRANCH}
|
|
45
|
+
--codeowner <@owner> Explicit @user or @namespace/team; omitted means a commented example
|
|
46
|
+
--runner <label> Actions runner label or GitLab runner tag
|
|
47
|
+
--dry-run Validate and list files without writing
|
|
48
|
+
-h, --help Show this help
|
|
49
|
+
-v, --version Show the version
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
/** Thrown for unusable command lines, which exit with status 2 like other CLIs. */
|
|
53
|
+
class UsageError extends Error {
|
|
54
|
+
}
|
|
55
|
+
export function main(argv, root = ROOT) {
|
|
56
|
+
let values;
|
|
57
|
+
try {
|
|
58
|
+
values = parse(argv, root);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error instanceof UsageError ||
|
|
62
|
+
(isSystemError(error) && error.code.startsWith("ERR_PARSE_ARGS"))) {
|
|
63
|
+
process.stderr.write(`error: ${error.message}\nRun precast --help for usage.\n`);
|
|
64
|
+
return 2;
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
if (values.help) {
|
|
69
|
+
process.stdout.write(usage(root));
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
if (values.version) {
|
|
73
|
+
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
74
|
+
process.stdout.write(`${manifest.version}\n`);
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
const tier = values.tier ?? DEFAULT_TIER;
|
|
78
|
+
if (!isTier(tier)) {
|
|
79
|
+
throw new Error("unreachable: tier is validated during parsing");
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const { destination, files } = generate({
|
|
83
|
+
platform: values.platform,
|
|
84
|
+
namespace: values.namespace,
|
|
85
|
+
repo: values.repo,
|
|
86
|
+
output: values.output,
|
|
87
|
+
tier,
|
|
88
|
+
serverUrl: values["server-url"],
|
|
89
|
+
projectName: values["project-name"],
|
|
90
|
+
author: values.author,
|
|
91
|
+
description: values.description,
|
|
92
|
+
defaultBranch: values["default-branch"],
|
|
93
|
+
codeowner: values.codeowner,
|
|
94
|
+
runner: values.runner,
|
|
95
|
+
dryRun: values["dry-run"],
|
|
96
|
+
}, root);
|
|
97
|
+
const verb = values["dry-run"] ? "Would generate" : "Generated";
|
|
98
|
+
const lines = [
|
|
99
|
+
`${verb} ${files.length} files for ${values.platform} (${tier} tier): ${destination}`,
|
|
100
|
+
];
|
|
101
|
+
if (values["dry-run"]) {
|
|
102
|
+
lines.push(...files.map((file) => ` ${file}`));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
lines.push("Review SETUP.md before creating the destination repository and pushing.");
|
|
106
|
+
}
|
|
107
|
+
process.stdout.write(`${lines.join("\n")}\n`);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (error instanceof PrecastError || isSystemError(error)) {
|
|
112
|
+
process.stderr.write(`error: ${error.message}\n`);
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function parse(argv, root) {
|
|
119
|
+
const { values } = parseArgs({
|
|
120
|
+
args: argv,
|
|
121
|
+
options: OPTIONS,
|
|
122
|
+
strict: true,
|
|
123
|
+
allowPositionals: false,
|
|
124
|
+
});
|
|
125
|
+
if (values.help || values.version) {
|
|
126
|
+
return values;
|
|
127
|
+
}
|
|
128
|
+
const missing = REQUIRED.filter((name) => values[name] === undefined);
|
|
129
|
+
if (missing.length > 0) {
|
|
130
|
+
throw new UsageError(`missing required options: ${missing.map((name) => `--${name}`).join(", ")}`);
|
|
131
|
+
}
|
|
132
|
+
const platforms = platformNames(root);
|
|
133
|
+
if (!platforms.includes(values.platform)) {
|
|
134
|
+
throw new UsageError(`--platform must be one of: ${platforms.join(", ")}`);
|
|
135
|
+
}
|
|
136
|
+
if (values.tier !== undefined && !isTier(values.tier)) {
|
|
137
|
+
throw new UsageError(`--tier must be one of: ${TIERS.join(", ")}`);
|
|
138
|
+
}
|
|
139
|
+
return values;
|
|
140
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Context } from "./context.ts";
|
|
2
|
+
import { type Tier } from "./tiers.ts";
|
|
3
|
+
export interface OutputFile {
|
|
4
|
+
data: Buffer;
|
|
5
|
+
/** Permission bits copied from the source file. */
|
|
6
|
+
mode: number;
|
|
7
|
+
}
|
|
8
|
+
/** Output files keyed by POSIX relative path, in source order. */
|
|
9
|
+
export type OutputFiles = Map<string, OutputFile>;
|
|
10
|
+
/**
|
|
11
|
+
* Render `template/` and the platform's `files/` for one tier. Every source is
|
|
12
|
+
* checked for collisions, even files the tier omits, so a smaller tier cannot
|
|
13
|
+
* hide one.
|
|
14
|
+
*/
|
|
15
|
+
export declare function collectFiles(root: string, platformName: string, context: Context, tier?: Tier): OutputFiles;
|
|
16
|
+
/** Compare POSIX paths component by component, matching the dry-run listing order. */
|
|
17
|
+
export declare function comparePaths(left: string, right: string): number;
|