@decohere/ci-tools 0.0.1-dev.20261105.46 → 0.0.1-dev.20261105.64
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decohere/ci-tools",
|
|
3
|
-
"version": "0.0.1-dev.20261105.
|
|
3
|
+
"version": "0.0.1-dev.20261105.64",
|
|
4
4
|
"description": "CI utility scripts for badge generation, coverage reporting, pages artifact assembly, and GitHub API tooling",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Publishes every public @decohere package in a build folder to CI's temporary registry, named by
|
|
4
|
+
* DECOHERE_E2E_REGISTRY. Plain `npm publish`: `forge publish` ignores the user's npm config on
|
|
5
|
+
* purpose, so that a real publish can't pick up stray credentials. npm refuses to publish without
|
|
6
|
+
* a login, so this gives it a made-up one; the registry takes anything.
|
|
7
|
+
*
|
|
8
|
+
* Usage: publish-to-temporary-registry.mjs <build folder>
|
|
9
|
+
*/
|
|
10
|
+
import { spawnSync } from "node:child_process";
|
|
11
|
+
import { mkdtempSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join, resolve } from "node:path";
|
|
14
|
+
import { pathToFileURL } from "node:url";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} dir
|
|
18
|
+
* @returns {string[]} folders of public @decohere packages
|
|
19
|
+
*/
|
|
20
|
+
export function findPublicPackages(dir) {
|
|
21
|
+
const found = [];
|
|
22
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
23
|
+
if (entry.name === "node_modules") continue;
|
|
24
|
+
const path = join(dir, entry.name);
|
|
25
|
+
if (entry.isDirectory()) {
|
|
26
|
+
found.push(...findPublicPackages(path));
|
|
27
|
+
} else if (entry.name === "package.json") {
|
|
28
|
+
const pkg = JSON.parse(readFileSync(path, "utf8"));
|
|
29
|
+
if (pkg.name?.startsWith("@decohere/") && pkg.private !== true) found.push(dir);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return found;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (process.argv[1] != null && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
36
|
+
const registry = process.env.DECOHERE_E2E_REGISTRY;
|
|
37
|
+
if (!registry) {
|
|
38
|
+
console.error("DECOHERE_E2E_REGISTRY is required");
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
const { host } = new URL(registry);
|
|
42
|
+
const userConfig = join(mkdtempSync(join(tmpdir(), "temporary-registry-")), ".npmrc");
|
|
43
|
+
writeFileSync(userConfig, `registry=${registry}\n//${host}/:_authToken=made-up\n`);
|
|
44
|
+
|
|
45
|
+
const packages = findPublicPackages(resolve(process.argv[2] ?? "dist/release"));
|
|
46
|
+
if (packages.length === 0) {
|
|
47
|
+
console.error("No public @decohere packages found");
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
for (const dir of packages) {
|
|
51
|
+
const result = spawnSync("npm", ["publish", dir, "--tag", "dev"], {
|
|
52
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
53
|
+
env: {
|
|
54
|
+
...process.env,
|
|
55
|
+
NPM_CONFIG_REGISTRY: registry,
|
|
56
|
+
NPM_CONFIG_USERCONFIG: userConfig,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
if (result.status !== 0) {
|
|
60
|
+
console.error(`Publishing ${dir} failed`);
|
|
61
|
+
process.exit(result.status ?? 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
console.log(`Published ${packages.length} packages`);
|
|
65
|
+
}
|