@theholocron/cli 5.0.0-alpha.239 → 5.0.0-alpha.240
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/dist/cli.mjs +29 -36
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
package/dist/cli.mjs
CHANGED
|
@@ -17,14 +17,14 @@ import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
|
17
17
|
import { homedir, hostname, tmpdir, userInfo } from "node:os";
|
|
18
18
|
import { PostHogSink } from "@theholocron/observability/analytics";
|
|
19
19
|
import { SentrySink } from "@theholocron/observability/errors";
|
|
20
|
-
import { KNOWN_WORKFLOWS, createAlexignore, createAlexrc, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, extractPreviewConfig, readWorkspacePackages, reusableTemplates, workspacePackages } from "@theholocron/astromech";
|
|
20
|
+
import { KNOWN_WORKFLOWS, createAlexignore, createAlexrc, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, discoverWorkspacePackages, extractPreviewConfig, readWorkspacePackages, resolveWorkspaceGlobs, reusableTemplates, workspacePackages } from "@theholocron/astromech";
|
|
21
21
|
import { loadTasksConfig } from "@theholocron/astromech/config";
|
|
22
22
|
import { pathToFileURL } from "node:url";
|
|
23
23
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
24
24
|
import path, { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
25
25
|
import { ConfigFileError, loadConfigFile } from "@theholocron/datapad";
|
|
26
26
|
import { readGitRemote, updateGitignore } from "@theholocron/git-utils";
|
|
27
|
-
import {
|
|
27
|
+
import { readPackageJson, readPackageJsonSync } from "@theholocron/pkg-utils";
|
|
28
28
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
29
29
|
import { access, copyFile, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
30
30
|
import { createServer } from "node:http";
|
|
@@ -7120,7 +7120,8 @@ function runPluginCreate(input) {
|
|
|
7120
7120
|
}
|
|
7121
7121
|
function preflight$1(cwd) {
|
|
7122
7122
|
if (!existsSync(path.join(cwd, "pnpm-workspace.yaml"))) throw new PluginCreateError(`\`pnpm-workspace.yaml\` not found in \`${cwd}\`. Run \`holocron new plugin\` from the monorepo root.`);
|
|
7123
|
-
|
|
7123
|
+
const { include } = resolveWorkspaceGlobs(cwd);
|
|
7124
|
+
if (!include.some((glob) => existsSync(path.join(cwd, glob.replace(/\/\*$/, ""))))) throw new PluginCreateError(`\`pnpm-workspace.yaml\` in \`${cwd}\` declares no package directory.`);
|
|
7124
7125
|
}
|
|
7125
7126
|
/**
|
|
7126
7127
|
* npm-package-name conventions: kebab-case, starts with lowercase
|
|
@@ -9144,8 +9145,9 @@ async function runNpmBumpVersions(input) {
|
|
|
9144
9145
|
}
|
|
9145
9146
|
bumpFile(join(cwd, "package.json"), "root");
|
|
9146
9147
|
const listed = /* @__PURE__ */ new Set();
|
|
9147
|
-
const workspace =
|
|
9148
|
+
const workspace = discoverWorkspacePackages(cwd, {
|
|
9148
9149
|
readFile,
|
|
9150
|
+
readText: readFile,
|
|
9149
9151
|
listDirs: (dir) => {
|
|
9150
9152
|
let names;
|
|
9151
9153
|
try {
|
|
@@ -9256,32 +9258,23 @@ const defaultLogin = async (cwd) => {
|
|
|
9256
9258
|
}).status ?? -1 };
|
|
9257
9259
|
};
|
|
9258
9260
|
//#endregion
|
|
9259
|
-
//#region src/commands/publish/has-packages-dir.ts
|
|
9260
|
-
function hasPackagesDir(cwd) {
|
|
9261
|
-
return existsSync(join(cwd, "packages"));
|
|
9262
|
-
}
|
|
9263
|
-
//#endregion
|
|
9264
|
-
//#region src/commands/publish/has-plugins-dir.ts
|
|
9265
|
-
/** `plugins/` — vendor capability providers, split from `packages/` as a sibling workspace root (#993). */
|
|
9266
|
-
function hasPluginsDir(cwd) {
|
|
9267
|
-
return existsSync(join(cwd, "plugins"));
|
|
9268
|
-
}
|
|
9269
|
-
//#endregion
|
|
9270
9261
|
//#region src/commands/publish/discover-manifests.ts
|
|
9271
9262
|
/**
|
|
9272
|
-
* Monorepo (
|
|
9273
|
-
*
|
|
9263
|
+
* Monorepo (the workspace declares public packages): every workspace
|
|
9264
|
+
* package. Single package (it declares none -- no `pnpm-workspace.yaml`, or one
|
|
9265
|
+
* listing only private members like a docs site): the root `package.json`.
|
|
9274
9266
|
* Callers keep the public ones.
|
|
9275
9267
|
*/
|
|
9276
9268
|
function discoverManifests(cwd) {
|
|
9277
|
-
|
|
9269
|
+
const workspace = discoverWorkspacePackages(cwd);
|
|
9270
|
+
if (!workspace.some(({ manifest }) => !manifest.private)) {
|
|
9278
9271
|
const manifest = readPackageJsonSync(cwd);
|
|
9279
9272
|
return manifest ? [{
|
|
9280
9273
|
manifest,
|
|
9281
9274
|
dir: "."
|
|
9282
9275
|
}] : [];
|
|
9283
9276
|
}
|
|
9284
|
-
return
|
|
9277
|
+
return workspace.map(({ manifest, relativeDir }) => ({
|
|
9285
9278
|
manifest,
|
|
9286
9279
|
dir: `./${relativeDir}`
|
|
9287
9280
|
}));
|
|
@@ -9400,6 +9393,20 @@ async function resolveRepoIdentity(cwd, exec) {
|
|
|
9400
9393
|
};
|
|
9401
9394
|
}
|
|
9402
9395
|
//#endregion
|
|
9396
|
+
//#region src/commands/publish/workspace-filter-args.ts
|
|
9397
|
+
/**
|
|
9398
|
+
* `-r --filter=./clients/* --filter=./observability` -- one filter per
|
|
9399
|
+
* workspace glob that holds a package. Empty (single-package repo, no `-r`)
|
|
9400
|
+
* when the workspace declares no package. Shared by every `pnpm publish`
|
|
9401
|
+
* invocation below so a repo with several package roots is covered the same as
|
|
9402
|
+
* a `packages/*`-only one.
|
|
9403
|
+
*/
|
|
9404
|
+
function workspaceFilterArgs(cwd) {
|
|
9405
|
+
const found = discoverWorkspacePackages(cwd).filter(({ manifest }) => !manifest.private);
|
|
9406
|
+
const globs = resolveWorkspaceGlobs(cwd).include.filter((glob) => found.some(({ relativeDir }) => glob.endsWith("/*") ? relativeDir.startsWith(glob.slice(0, -1)) : relativeDir === glob));
|
|
9407
|
+
return globs.length > 0 ? ["-r", ...globs.map((glob) => `--filter=./${glob}`)] : [];
|
|
9408
|
+
}
|
|
9409
|
+
//#endregion
|
|
9403
9410
|
//#region src/commands/publish/run-publish/run-publish.ts
|
|
9404
9411
|
/**
|
|
9405
9412
|
* `holocron package publish --initial` — bottles up the chicken-and-egg bootstrap
|
|
@@ -9535,7 +9542,7 @@ async function runPublish(input = {}) {
|
|
|
9535
9542
|
};
|
|
9536
9543
|
}
|
|
9537
9544
|
const publishArgs = [
|
|
9538
|
-
...
|
|
9545
|
+
...workspaceFilterArgs(cwd).length > 0 ? ["-r", ...packageNames.map((name) => `--filter=${name}`)] : [],
|
|
9539
9546
|
"publish",
|
|
9540
9547
|
"--access",
|
|
9541
9548
|
"public",
|
|
@@ -9606,20 +9613,6 @@ async function runPublish(input = {}) {
|
|
|
9606
9613
|
};
|
|
9607
9614
|
}
|
|
9608
9615
|
//#endregion
|
|
9609
|
-
//#region src/commands/publish/workspace-filter-args.ts
|
|
9610
|
-
/**
|
|
9611
|
-
* `-r --filter=./packages/* --filter=./plugins/*` — whichever workspace
|
|
9612
|
-
* roots exist. Empty (single-package repo, no `-r`) when neither does.
|
|
9613
|
-
* Shared by every `pnpm publish` invocation below so a repo with only
|
|
9614
|
-
* `plugins/*` (or both) is covered the same as `packages/*`-only.
|
|
9615
|
-
*/
|
|
9616
|
-
function workspaceFilterArgs(cwd) {
|
|
9617
|
-
const filters = [];
|
|
9618
|
-
if (hasPackagesDir(cwd)) filters.push("--filter=./packages/*");
|
|
9619
|
-
if (hasPluginsDir(cwd)) filters.push("--filter=./plugins/*");
|
|
9620
|
-
return filters.length > 0 ? ["-r", ...filters] : [];
|
|
9621
|
-
}
|
|
9622
|
-
//#endregion
|
|
9623
9616
|
//#region src/commands/publish/run-steady-publish/run-steady-publish.ts
|
|
9624
9617
|
/**
|
|
9625
9618
|
* `holocron package publish` (no `--initial`) — the steady-state publish
|
|
@@ -10653,8 +10646,8 @@ function deriveCompliance(capabilities) {
|
|
|
10653
10646
|
*/
|
|
10654
10647
|
async function readWorkspacePackageJsons(repoRoot, workspacePackages) {
|
|
10655
10648
|
const results = [];
|
|
10656
|
-
for (const { slug, dir = "packages" } of workspacePackages) {
|
|
10657
|
-
const pkg = await readPackageJson(join(repoRoot, dir, slug));
|
|
10649
|
+
for (const { slug, dir = "packages", path } of workspacePackages) {
|
|
10650
|
+
const pkg = await readPackageJson(join(repoRoot, path ?? join(dir, slug)));
|
|
10658
10651
|
if (pkg) results.push(pkg);
|
|
10659
10652
|
}
|
|
10660
10653
|
return results;
|