template-git-repo 0.1.11 → 0.1.12

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 CHANGED
@@ -1,3 +1,25 @@
1
+ <!-- template-git-repo:badges:start -->
2
+ <p align="center">
3
+ <a href="https://starterdocs.vtempest.workers.dev/docs/packages/template-git-repo"><img src="https://img.shields.io/badge/Docs-blue?logo=ReadTheDocs&logoColor=white" alt="Documentation" /></a>
4
+ <a href="https://stackblitz.com/github/OpenSourceAGI/dev-tools-starter-agent/tree/master/packages/template-git-repo"><img height="20px" src="https://developer.stackblitz.com/img/open_in_stackblitz.svg" alt="Open in StackBlitz" /></a>
5
+ <br />
6
+ <a href="https://www.npmjs.com/package/template-git-repo"><img src="https://img.shields.io/npm/dm/template-git-repo.svg" alt="NPM Monthly Downloads" /></a>
7
+ <a href="https://www.npmjs.com/package/template-git-repo"><img src="https://img.shields.io/npm/v/template-git-repo.svg" alt="npm version" /></a>
8
+ <a href="https://www.npmjs.com/package/template-git-repo"><img src="https://img.shields.io/npm/dt/template-git-repo.svg" alt="NPM Total Downloads" /></a>
9
+ <a href="https://www.npmjs.com/package/template-git-repo"><img src="https://img.shields.io/npm/types/template-git-repo" alt="TypeScript types" /></a>
10
+ <a href="https://packagephobia.com/result?p=template-git-repo"><img src="https://packagephobia.com/badge?p=template-git-repo" alt="Install size" /></a>
11
+ <a href="https://app.codecov.io/gh/OpenSourceAGI/dev-tools-starter-agent/flags"><img src="https://img.shields.io/codecov/c/github/OpenSourceAGI/dev-tools-starter-agent?flag=template-git-repo&label=template-git-repo%20coverage&logo=codecov&logoColor=white" alt="Coverage" /></a>
12
+ </p>
13
+ <!-- template-git-repo:badges:end -->
14
+
15
+ <!-- skills:install:start -->
16
+ **🤖 Agent skills**
17
+ <br />
18
+ `npx skills@latest add https://github.com/OpenSourceAGI/dev-tools-starter-agent --skill template-git-repo` ([what it covers](../../skills/template-git-repo/SKILL.md))
19
+ <br />
20
+ `npx skills@latest add https://github.com/OpenSourceAGI/dev-tools-starter-agent --skill repo-badges` ([what it covers](../../skills/repo-badges/SKILL.md))
21
+ <!-- skills:install:end -->
22
+
1
23
  # template-git-repo
2
24
 
3
25
  One command to give a repository the CI, publishing, badges and Turborepo wiring
@@ -56,6 +56,7 @@ Badge inputs (each enables the badge that needs it)
56
56
  --youtube <url> --uptime <url> --test-report <url>
57
57
  --discord-id <id> --discord-invite <url>
58
58
  --stack <A,B,C> --cloudflare-deploy
59
+ --stackblitz <url> --codecov-flag <name>
59
60
  --exclude <id,id> --only <id,id>
60
61
 
61
62
  Badge ids: ${BADGES.map((b) => b.id).join(', ')}
@@ -116,6 +117,8 @@ function overridesFrom(flags) {
116
117
  discordInvite: text('discord-invite'),
117
118
  stack: text('stack'),
118
119
  cloudflareDeploy: flags['cloudflare-deploy'] ? 'true' : undefined,
120
+ stackblitzUrl: text('stackblitz'),
121
+ codecovFlag: text('codecov-flag'),
119
122
  };
120
123
  }
121
124
 
package/docs/BADGES.md CHANGED
@@ -27,10 +27,15 @@ package or finish setting up Codecov.
27
27
  | [API reference](#api) `api` | apiUrl | `--api <url>` |
28
28
  | [YouTube demo](#youtube) `youtube` | youtubeUrl | `--youtube <url>` |
29
29
  | [Deploy to Cloudflare Workers](#deploy-cloudflare) `deploy-cloudflare` | cloudflareDeploy | `--cloudflare-deploy` |
30
+ | [Open in StackBlitz](#stackblitz) `stackblitz` | stackblitzUrl | `--stackblitz <url>` |
30
31
  | [GitHub stars](#stars) `stars` | — | on by default |
31
32
  | [npm monthly downloads](#npm-downloads) `npm-downloads` | npmPackage | `--npm-package <name>` |
32
33
  | [npm version](#npm-version) `npm-version` | npmPackage | `--npm-package <name>` |
34
+ | [npm total downloads](#npm-total-downloads) `npm-total-downloads` | npmPackage | `--npm-package <name>` |
35
+ | [TypeScript types](#npm-types) `npm-types` | npmPackage | `--npm-package <name>` |
36
+ | [Install size](#install-size) `install-size` | npmPackage | `--npm-package <name>` |
33
37
  | [Code coverage](#codecov) `codecov` | — | on by default |
38
+ | [Coverage for one package](#codecov-flag) `codecov-flag` | codecovFlag | `--codecov-flag <name>` |
34
39
  | [CI status](#workflow) `workflow` | workflowFile | `--workflow <file>` |
35
40
  | [Hosted test report](#test-report) `test-report` | testReportUrl | `--test-report <url>` |
36
41
  | [Uptime](#uptime) `uptime` | uptimeUrl | `--uptime <url>` |
@@ -91,6 +96,14 @@ The repo must contain a wrangler.toml (or wrangler.jsonc) at the path the button
91
96
 
92
97
  Enable with: `--cloudflare-deploy`
93
98
 
99
+ ### stackblitz
100
+
101
+ **Open in StackBlitz**
102
+
103
+ Nothing to configure — StackBlitz imports a public repo straight from a URL: `https://stackblitz.com/github/<owner>/<repo>/tree/<branch>/<path>`. Point it at a directory that boots on its own (a package with its own package.json, or an `examples/` folder), because StackBlitz installs from the manifest at that path and a bare monorepo root will not run. Node APIs need the WebContainer runtime, which means the directory must be ESM and its deps must be installable from npm.
104
+
105
+ Enable with: `--stackblitz <url>`
106
+
94
107
  ## Quality — is it working, is it tested, is it shipped
95
108
 
96
109
  ### npm-downloads
@@ -109,6 +122,30 @@ Shows the `latest` dist-tag. Publishing under a different tag will not move it.
109
122
 
110
123
  Enable with: `--npm-package <name>`
111
124
 
125
+ ### npm-total-downloads
126
+
127
+ **npm total downloads**
128
+
129
+ All-time downloads for one package. Worth pairing with the monthly count rather than showing alone: a large total and a flat month say different things, and only the monthly number tells you the project is still being installed.
130
+
131
+ Enable with: `--npm-package <name>`
132
+
133
+ ### npm-types
134
+
135
+ **TypeScript types**
136
+
137
+ Reads the published tarball: it says "TypeScript" when the manifest has a `types`/`typings` field pointing at a real `.d.ts`, and stays grey when the declarations were left out of `files`. Publish once and check it — this is the badge that catches a build that shipped JS without its types.
138
+
139
+ Enable with: `--npm-package <name>`
140
+
141
+ ### install-size
142
+
143
+ **Install size**
144
+
145
+ Nothing to configure, but read what it measures: packagephobia reports what `npm install` writes to disk, dependencies included — not the bundled browser size. A package whose one dependency is an AWS SDK client looks enormous here and tree-shakes to very little in a bundler.
146
+
147
+ Enable with: `--npm-package <name>`
148
+
112
149
  ### codecov
113
150
 
114
151
  **Code coverage**
@@ -117,6 +154,14 @@ Add the repo at codecov.io, copy its upload token into a CODECOV_TOKEN repositor
117
154
 
118
155
  Included by default — no configuration needed.
119
156
 
157
+ ### codecov-flag
158
+
159
+ **Coverage for one package**
160
+
161
+ The repo-wide number is the wrong one to put on a package README in a monorepo — it mixes in every other package. This one narrows to a single Codecov flag, so it needs that flag to exist: an entry under `flag_management.individual_flags` in codecov.yml, and an upload that passes `flags: <name>` (tests.yml does, from its matrix). The flag name has to match both exactly, or the badge reads "unknown" while the repo-wide badge looks fine.
162
+
163
+ Enable with: `--codecov-flag <name>`
164
+
120
165
  ### workflow
121
166
 
122
167
  **CI status**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "template-git-repo",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "One command to set up a repo with GitHub Actions, README badges, Turborepo and Codecov — the CI setup from qwksearch-research-agent, as a template",
5
5
  "type": "module",
6
6
  "bin": {
package/src/badges.js CHANGED
@@ -107,6 +107,18 @@ export const BADGES = [
107
107
  'The repo must contain a wrangler.toml (or wrangler.jsonc) at the path the button clones. Cloudflare forks the repo into the visitor\'s account and runs the build, so anything the build needs must come from `[vars]` or be prompted for — a build that requires a secret fails for every visitor.',
108
108
  height: '24px',
109
109
  },
110
+ {
111
+ id: 'stackblitz',
112
+ title: 'Open in StackBlitz',
113
+ group: 'identity',
114
+ needs: ['stackblitzUrl'],
115
+ alt: 'Open in StackBlitz',
116
+ href: (c) => c.stackblitzUrl,
117
+ img: () => 'https://developer.stackblitz.com/img/open_in_stackblitz.svg',
118
+ setup:
119
+ 'Nothing to configure — StackBlitz imports a public repo straight from a URL: `https://stackblitz.com/github/<owner>/<repo>/tree/<branch>/<path>`. Point it at a directory that boots on its own (a package with its own package.json, or an `examples/` folder), because StackBlitz installs from the manifest at that path and a bare monorepo root will not run. Node APIs need the WebContainer runtime, which means the directory must be ESM and its deps must be installable from npm.',
120
+ height: '20px',
121
+ },
110
122
  {
111
123
  id: 'stars',
112
124
  title: 'GitHub stars',
@@ -138,6 +150,39 @@ export const BADGES = [
138
150
  img: (c) => `https://img.shields.io/npm/v/${c.npmPackage}.svg`,
139
151
  setup: 'Shows the `latest` dist-tag. Publishing under a different tag will not move it.',
140
152
  },
153
+ {
154
+ id: 'npm-total-downloads',
155
+ title: 'npm total downloads',
156
+ group: 'quality',
157
+ needs: ['npmPackage'],
158
+ alt: 'NPM Total Downloads',
159
+ href: (c) => `https://www.npmjs.com/package/${c.npmPackage}`,
160
+ img: (c) => `https://img.shields.io/npm/dt/${c.npmPackage}.svg`,
161
+ setup:
162
+ 'All-time downloads for one package. Worth pairing with the monthly count rather than showing alone: a large total and a flat month say different things, and only the monthly number tells you the project is still being installed.',
163
+ },
164
+ {
165
+ id: 'npm-types',
166
+ title: 'TypeScript types',
167
+ group: 'quality',
168
+ needs: ['npmPackage'],
169
+ alt: 'TypeScript types',
170
+ href: (c) => `https://www.npmjs.com/package/${c.npmPackage}`,
171
+ img: (c) => `https://img.shields.io/npm/types/${c.npmPackage}`,
172
+ setup:
173
+ 'Reads the published tarball: it says "TypeScript" when the manifest has a `types`/`typings` field pointing at a real `.d.ts`, and stays grey when the declarations were left out of `files`. Publish once and check it — this is the badge that catches a build that shipped JS without its types.',
174
+ },
175
+ {
176
+ id: 'install-size',
177
+ title: 'Install size',
178
+ group: 'quality',
179
+ needs: ['npmPackage'],
180
+ alt: 'Install size',
181
+ href: (c) => `https://packagephobia.com/result?p=${c.npmPackage}`,
182
+ img: (c) => `https://packagephobia.com/badge?p=${c.npmPackage}`,
183
+ setup:
184
+ 'Nothing to configure, but read what it measures: packagephobia reports what `npm install` writes to disk, dependencies included — not the bundled browser size. A package whose one dependency is an AWS SDK client looks enormous here and tree-shakes to very little in a bundler.',
185
+ },
141
186
  {
142
187
  id: 'codecov',
143
188
  title: 'Code coverage',
@@ -149,6 +194,20 @@ export const BADGES = [
149
194
  setup:
150
195
  'Add the repo at codecov.io, copy its upload token into a CODECOV_TOKEN repository secret, and make sure a workflow uploads `coverage/lcov.info` (tests.yml does). Until the first successful upload the badge reads "unknown", which looks identical to a broken badge — check the Codecov dashboard, not the badge, when debugging.',
151
196
  },
197
+ {
198
+ id: 'codecov-flag',
199
+ title: 'Coverage for one package',
200
+ group: 'quality',
201
+ needs: ['codecovFlag'],
202
+ alt: 'Coverage',
203
+ href: (c) => `https://app.codecov.io/gh/${c.repoSlug}/flags`,
204
+ img: (c) =>
205
+ `https://img.shields.io/codecov/c/github/${c.repoSlug}?flag=${encodeURIComponent(
206
+ String(c.codecovFlag),
207
+ )}&label=${encodeURIComponent(`${c.codecovFlag} coverage`)}&logo=codecov&logoColor=white`,
208
+ setup:
209
+ 'The repo-wide number is the wrong one to put on a package README in a monorepo — it mixes in every other package. This one narrows to a single Codecov flag, so it needs that flag to exist: an entry under `flag_management.individual_flags` in codecov.yml, and an upload that passes `flags: <name>` (tests.yml does, from its matrix). The flag name has to match both exactly, or the badge reads "unknown" while the repo-wide badge looks fine.',
210
+ },
152
211
  {
153
212
  id: 'workflow',
154
213
  title: 'CI status',
package/src/context.js CHANGED
@@ -71,6 +71,14 @@ export function detectDefaultBranch(root) {
71
71
  const symbolic = git(['symbolic-ref', '--short', 'refs/remotes/origin/HEAD'], root);
72
72
  if (symbolic) return symbolic.replace(/^origin\//, '');
73
73
 
74
+ // origin/HEAD is unset in plenty of clones (a shallow CI checkout, anything
75
+ // cloned with --single-branch). Falling straight through to the current branch
76
+ // there is how badges end up pinned to whatever feature branch they were
77
+ // generated on, so try the conventional names on the remote first.
78
+ for (const name of ['main', 'master', 'canary']) {
79
+ if (git(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${name}`], root)) return name;
80
+ }
81
+
74
82
  const current = git(['rev-parse', '--abbrev-ref', 'HEAD'], root);
75
83
  // A detached HEAD reports "HEAD", which is not a branch name.
76
84
  if (current && current !== 'HEAD') return current;
@@ -195,6 +203,8 @@ export function buildContext(options = {}) {
195
203
  discordInvite: overrides.discordInvite,
196
204
  stack: overrides.stack,
197
205
  cloudflareDeploy: overrides.cloudflareDeploy,
206
+ stackblitzUrl: overrides.stackblitzUrl,
207
+ codecovFlag: overrides.codecovFlag,
198
208
  };
199
209
 
200
210
  return context;