@10stars/config 17.0.1 → 17.0.2
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/package.json
CHANGED
package/src/link-remote.ts
CHANGED
|
@@ -126,23 +126,15 @@ const bfsSiblings = async (cwd: string, visit: (sib: string) => Promise<void>):
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
130
|
-
* `ls-remote
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* as "No branch found".
|
|
129
|
+
* The first of `candidates` (priority order) that exists as a branch on the remote, else null.
|
|
130
|
+
* Queries only those specific refs in one `ls-remote` — no full head listing. A non-zero exit means
|
|
131
|
+
* the repo is unreadable (private + missing/unauthorized clone token → "Repository not found") —
|
|
132
|
+
* surfaced immediately rather than masquerading as a missing branch.
|
|
134
133
|
*/
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
process.env.GITHUB_HEAD_REF, // pull_request events
|
|
138
|
-
process.env.GITHUB_REF_NAME, // push events
|
|
139
|
-
`develop`,
|
|
140
|
-
`production`,
|
|
141
|
-
].filter((v): v is string => Boolean(v))
|
|
142
|
-
|
|
143
|
-
let heads: string
|
|
134
|
+
const matchRemoteBranch = (url: string, candidates: string[]): string | null => {
|
|
135
|
+
let out: string
|
|
144
136
|
try {
|
|
145
|
-
|
|
137
|
+
out = git([`ls-remote`, url, ...candidates.map((c) => `refs/heads/${c}`)])
|
|
146
138
|
} catch (err) {
|
|
147
139
|
const stderr = (err as { stderr?: string | Buffer })?.stderr
|
|
148
140
|
throw new Error(
|
|
@@ -151,18 +143,41 @@ const resolveRef = (url: string, repo: string): string => {
|
|
|
151
143
|
`with contents:read.\n${(stderr ?? (err as Error)?.message ?? ``).toString().trim()}`,
|
|
152
144
|
)
|
|
153
145
|
}
|
|
154
|
-
|
|
155
|
-
// Each line is "<sha>\trefs/heads/<branch>"; a branch may itself contain slashes (e.g. alice/x).
|
|
146
|
+
// Lines are "<sha>\trefs/heads/<branch>"; a branch may itself contain slashes (e.g. alice/x).
|
|
156
147
|
const present = new Set(
|
|
157
|
-
|
|
148
|
+
out
|
|
158
149
|
.split(`\n`)
|
|
159
150
|
.map((line) => line.split(`refs/heads/`)[1])
|
|
160
151
|
.filter(Boolean),
|
|
161
152
|
)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
153
|
+
return candidates.find((c) => present.has(c)) ?? null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Clone a missing sibling as a flat peer, returning the branch it landed on. Prefers a branch
|
|
158
|
+
* matching the consumer's coordinated branch (PR head, then push branch) when the sibling has one;
|
|
159
|
+
* otherwise clones the sibling's own default branch directly. A default-branch clone needs no
|
|
160
|
+
* `--branch`, so the `ls-remote` probe is skipped entirely when no coordinated branch is set — one
|
|
161
|
+
* fewer round-trip for local/manual runs (in GitHub Actions GITHUB_REF_NAME is always set).
|
|
162
|
+
*/
|
|
163
|
+
const cloneSibling = (url: string, repo: string, sib: string, dest: string): string | null => {
|
|
164
|
+
const coordinated = [
|
|
165
|
+
process.env.GITHUB_HEAD_REF, // pull_request events
|
|
166
|
+
process.env.GITHUB_REF_NAME, // push events
|
|
167
|
+
].filter((v): v is string => Boolean(v))
|
|
168
|
+
const ref = coordinated.length ? matchRemoteBranch(url, coordinated) : null
|
|
169
|
+
|
|
170
|
+
console.info(`linkRemote: cloning ${repo}@${ref ?? `(default)`} -> ${dest}`)
|
|
171
|
+
gitInherit([
|
|
172
|
+
`clone`,
|
|
173
|
+
`--depth`,
|
|
174
|
+
`1`,
|
|
175
|
+
`--single-branch`,
|
|
176
|
+
...(ref ? [`--branch`, ref] : []),
|
|
177
|
+
url,
|
|
178
|
+
sib,
|
|
179
|
+
])
|
|
180
|
+
return ref ?? currentRef(sib)
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
const headSha = (dir: string): string | null => tryGit([`rev-parse`, `HEAD`], dir)
|
|
@@ -194,10 +209,7 @@ const cloneClosureBranchFirst = async (cwd: string): Promise<Sibling[]> => {
|
|
|
194
209
|
ref = currentRef(sib)
|
|
195
210
|
} else {
|
|
196
211
|
const repo = path.basename(sib)
|
|
197
|
-
|
|
198
|
-
ref = resolveRef(url, repo)
|
|
199
|
-
console.info(`linkRemote: cloning ${repo}@${ref} -> ${path.relative(cwd, sib)}`)
|
|
200
|
-
gitInherit([`clone`, `--depth`, `1`, `--single-branch`, `--branch`, ref, url, sib])
|
|
212
|
+
ref = cloneSibling(repoUrl(repo), repo, sib, path.relative(cwd, sib))
|
|
201
213
|
}
|
|
202
214
|
order.push({ abs: sib, ref })
|
|
203
215
|
})
|
|
@@ -22,15 +22,29 @@ const PATCHED = String.raw`/(?:^|[/\\])css\.(js|cjs|mjs|jsx|ts|tsx)(\?used)?$/`
|
|
|
22
22
|
*/
|
|
23
23
|
export const patchVanillaExtract = async (cwd: string): Promise<boolean> => {
|
|
24
24
|
const nodeModules = path.join(cwd, `node_modules`)
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
// Recursively collect `@vanilla-extract/integration/dist/*.js` WITHOUT following directory
|
|
27
|
+
// symlinks. A `file:` self-dep (e.g. frontend-toolkit's `frontend-toolkit: file:.` creates
|
|
28
|
+
// node_modules/frontend-toolkit -> .) makes symlink-following recurse forever — Bun.Glob does,
|
|
29
|
+
// even with `followSymlinks: false`. A linked sibling patches its own VE during its own install,
|
|
30
|
+
// and this repo's own copy is hoisted as a real dir, so real-dir-only recursion is sufficient.
|
|
31
|
+
const integrationDist = /[/\\]@vanilla-extract[/\\]integration[/\\]dist[/\\][^/\\]+\.js$/
|
|
32
|
+
const findFiles = async (dir: string, out: string[] = []): Promise<string[]> => {
|
|
33
|
+
for (const entry of await fs.readdir(dir, { withFileTypes: true }).catch(() => [])) {
|
|
34
|
+
if (entry.isSymbolicLink()) continue
|
|
35
|
+
const full = path.join(dir, entry.name)
|
|
36
|
+
if (entry.isDirectory()) await findFiles(full, out)
|
|
37
|
+
else if (entry.isFile() && integrationDist.test(full)) out.push(full)
|
|
38
|
+
}
|
|
39
|
+
return out
|
|
40
|
+
}
|
|
26
41
|
|
|
27
42
|
let integrationFound = false
|
|
28
43
|
let definitionFound = false
|
|
29
44
|
const patched: string[] = []
|
|
30
45
|
|
|
31
|
-
for
|
|
46
|
+
for (const file of await findFiles(nodeModules)) {
|
|
32
47
|
integrationFound = true
|
|
33
|
-
const file = path.join(nodeModules, rel)
|
|
34
48
|
const content = await fs.readFile(file, `utf8`)
|
|
35
49
|
|
|
36
50
|
if (content.includes(PATCHED)) {
|
|
@@ -41,7 +55,7 @@ export const patchVanillaExtract = async (cwd: string): Promise<boolean> => {
|
|
|
41
55
|
|
|
42
56
|
definitionFound = true
|
|
43
57
|
await fs.writeFile(file, content.replaceAll(ORIGINAL, PATCHED))
|
|
44
|
-
patched.push(
|
|
58
|
+
patched.push(path.relative(nodeModules, file))
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
if (!integrationFound) return false // VE not installed here
|