@detergent-software/atk 8.5.0-dev.1 → 8.5.0-dev.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/CHANGELOG.md +12 -0
- package/build/commands/publish.d.ts +2 -1
- package/build/commands/publish.d.ts.map +1 -1
- package/build/commands/publish.js +73 -12
- package/build/commands/publish.js.map +1 -1
- package/build/hooks/usePublishState.d.ts +43 -2
- package/build/hooks/usePublishState.d.ts.map +1 -1
- package/build/hooks/usePublishState.js +237 -24
- package/build/hooks/usePublishState.js.map +1 -1
- package/build/lib/api-client.d.ts +5 -2
- package/build/lib/api-client.d.ts.map +1 -1
- package/build/lib/api-client.js +15 -4
- package/build/lib/api-client.js.map +1 -1
- package/build/lib/publisher.d.ts +51 -5
- package/build/lib/publisher.d.ts.map +1 -1
- package/build/lib/publisher.js +161 -40
- package/build/lib/publisher.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAA+B,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAA+B,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGtH,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAI/D,+EAA+E;AAC/E,eAAO,MAAM,eAAe,4CAA4C,CAAC;AAEzE,uEAAuE;AACvE,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,YAAY;IACvC,IA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E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAKpF"}
|
package/build/lib/api-client.js
CHANGED
|
@@ -28,13 +28,16 @@ export const API_URL_ENV_VAR = 'ATK_API_URL';
|
|
|
28
28
|
* `status` is the HTTP status (0 for a network failure). `code` is the API's
|
|
29
29
|
* machine-readable error code (`not_found`, `version_not_bumped`, ...), or a
|
|
30
30
|
* synthetic one (`network_error`, `http_error`) when the API did not send an
|
|
31
|
-
* envelope.
|
|
31
|
+
* envelope. `issues` are the API's detail lines for a 4xx validation problem
|
|
32
|
+
* (`/dependencies/<i>`, ...), empty for anything else.
|
|
32
33
|
*/
|
|
33
34
|
export class ApiRequestError extends ApiCodeError {
|
|
35
|
+
issues;
|
|
34
36
|
name = 'ApiRequestError';
|
|
35
37
|
status;
|
|
36
38
|
constructor(message, options) {
|
|
37
39
|
super(message, options);
|
|
40
|
+
this.issues = options.issues ?? [];
|
|
38
41
|
this.status = options.status;
|
|
39
42
|
}
|
|
40
43
|
}
|
|
@@ -49,7 +52,7 @@ const AMBIGUOUS_NAME_HINT = 'Pass `--type <type>` (or `--type bundle`) to choose
|
|
|
49
52
|
const REGISTRY_CHANGED_HINT = 'The registry changed while the pull request was being prepared. Retry the command.';
|
|
50
53
|
const OUTDATED_MESSAGE = 'This ATK CLI is too old for the ATK API. Update it, then run the command again.';
|
|
51
54
|
const DEPENDENCY_HINTS = {
|
|
52
|
-
dependency_not_found: 'Publish each missing dependency first (`atk publish <its folder>`), or fix its entry in manifest.json `dependencies`.',
|
|
55
|
+
dependency_not_found: 'Publish each missing dependency first (`atk publish <its folder>`), include its folder in this publish (`--with <folder>`), or fix its entry in manifest.json `dependencies`.',
|
|
53
56
|
dependency_version_unsatisfied: "Change the entry's range in manifest.json `dependencies`, or publish a version of the dependency that satisfies it.",
|
|
54
57
|
};
|
|
55
58
|
/**
|
|
@@ -175,8 +178,15 @@ export function presentProblem(error, resource) {
|
|
|
175
178
|
case 'invalid': {
|
|
176
179
|
const hint = DEPENDENCY_HINTS[problem.code];
|
|
177
180
|
if (LISTED_INVALID_CODES.has(problem.code) && problem.issues.length > 0) {
|
|
178
|
-
const lines = problem.issues.map((issue) => ` ${issue.path ?? '-'}: ${issue.message}`);
|
|
179
181
|
const heading = DEPENDENCY_HEADINGS[problem.code] ?? apiMessage ?? 'Validation failed.';
|
|
182
|
+
// An issue in a publish's `dependencies` entry is named the way the API's messages name it,
|
|
183
|
+
// and the API's message already repeats an entry problem it had no details for.
|
|
184
|
+
const lines = problem.issues
|
|
185
|
+
.map((issue) => issue.entry === undefined
|
|
186
|
+
? `${issue.path ?? '-'}: ${issue.message}`
|
|
187
|
+
: `dependencies[${issue.entry}]${issue.path ? ` ${issue.path}` : ''}: ${issue.message}`)
|
|
188
|
+
.filter((line) => !heading.includes(line))
|
|
189
|
+
.map((line) => ` ${line}`);
|
|
180
190
|
return { ...(hint ? { hint } : {}), message: [heading, ...lines].join('\n') };
|
|
181
191
|
}
|
|
182
192
|
return hint ? { ...fallback, hint } : fallback;
|
|
@@ -232,7 +242,8 @@ export function resolveApiUrl(config) {
|
|
|
232
242
|
export function toApiRequestError(error, resource) {
|
|
233
243
|
const { message, ...guidance } = presentProblem(error, resource);
|
|
234
244
|
const code = error.apiCode ?? SYNTHETIC_CODES[error.problem.kind] ?? 'http_error';
|
|
235
|
-
|
|
245
|
+
const issues = error.problem.kind === 'invalid' ? error.problem.issues : [];
|
|
246
|
+
return new ApiRequestError(message, { code, ...guidance, issues, status: error.status });
|
|
236
247
|
}
|
|
237
248
|
/** `Sunset` is an HTTP-date; show it as `YYYY-MM-DD`, or verbatim if unparseable. */
|
|
238
249
|
function formatSunsetDate(headerValue) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAiC,eAAe,EAAE,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CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,cAAc,CAAC,KAA6B,EAAE,IAAkB;IAC7E,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,MAAM,EAAE,CAAC;QACX,SAAS,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/build/lib/publisher.d.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import type { PublishDependency, PublishInput } from './atk-api/index.js';
|
|
1
|
+
import type { PublishDependency, PublishEntryPlan, PublishInput, ValidationIssue } from './atk-api/index.js';
|
|
2
2
|
import type { Adapter } from './schemas/adapter.js';
|
|
3
3
|
import type { Bundle } from './schemas/index.js';
|
|
4
4
|
import type { AssetType, Manifest } from './schemas/index.js';
|
|
5
5
|
import type { Registry } from './schemas/index.js';
|
|
6
|
+
/** A dependency as a manifest declares it, which is all a sibling folder is matched on. */
|
|
7
|
+
export interface DeclaredDependency {
|
|
8
|
+
name: string;
|
|
9
|
+
type: AssetType;
|
|
10
|
+
version?: string;
|
|
11
|
+
}
|
|
12
|
+
/** A {@link PublishEntry} in a plan, with what the API plans for it once it has been asked. */
|
|
13
|
+
export interface PlannedEntry extends PublishEntry {
|
|
14
|
+
plan?: PublishEntryPlan;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* An asset published in the same pull request as the root asset (`--with`, or
|
|
18
|
+
* a folder next to the root that the run offered): a new dependency of it.
|
|
19
|
+
*/
|
|
20
|
+
export interface PublishEntry {
|
|
21
|
+
/** The folder as the user named it, or as found next to the root; names the entry in messages. */
|
|
22
|
+
label: string;
|
|
23
|
+
target: PublishTarget;
|
|
24
|
+
}
|
|
6
25
|
export interface PublishPlan {
|
|
7
26
|
branchName: string;
|
|
8
27
|
checksum: string;
|
|
@@ -11,6 +30,8 @@ export interface PublishPlan {
|
|
|
11
30
|
* Set by {@link resolvePlanDependencies} for an asset that declares any.
|
|
12
31
|
*/
|
|
13
32
|
dependencies?: readonly PublishDependency[];
|
|
33
|
+
/** The assets published with this one, in request order (`dependencies[i]` is `entries[i]`). */
|
|
34
|
+
entries?: readonly PlannedEntry[];
|
|
14
35
|
files: string[];
|
|
15
36
|
isUpdate: boolean;
|
|
16
37
|
/** Optional author notes appended to the PR body. */
|
|
@@ -26,6 +47,8 @@ export type PublishResult = {
|
|
|
26
47
|
branchName: string;
|
|
27
48
|
/** The manifest's dependencies as the API resolved them for the pull request. */
|
|
28
49
|
dependencies: readonly PublishDependency[];
|
|
50
|
+
/** The plan's entries, published in the same pull request. */
|
|
51
|
+
entries?: readonly PlannedEntry[];
|
|
29
52
|
mode: 'pr';
|
|
30
53
|
/** Pull request number on the registry repo. */
|
|
31
54
|
prNumber?: number;
|
|
@@ -83,9 +106,10 @@ export type VersionCheckResult = {
|
|
|
83
106
|
* sends each as `utf8` or `base64`). A bundle may only add `README.md`.
|
|
84
107
|
* - `reviewers` is sent only for org-scoped targets; the API assigns the
|
|
85
108
|
* default reviewers for global targets and rejects an explicit list.
|
|
109
|
+
* - The plan's entries go as `dependencies`, each read the same way as the root.
|
|
86
110
|
*/
|
|
87
111
|
export declare function buildPublishInput(plan: PublishPlan): Promise<PublishInput>;
|
|
88
|
-
export declare function buildPublishPlan(target: PublishTarget, resolvedVersion: string, isUpdate: boolean, message?: string, orgReviewers?: string[]): Promise<PublishPlan>;
|
|
112
|
+
export declare function buildPublishPlan(target: PublishTarget, resolvedVersion: string, isUpdate: boolean, message?: string, orgReviewers?: string[], entries?: readonly PublishEntry[]): Promise<PublishPlan>;
|
|
89
113
|
/**
|
|
90
114
|
* Build a temporary staging directory containing the collected files and a
|
|
91
115
|
* programmatically generated `manifest.json`, ready for the existing publish
|
|
@@ -118,6 +142,15 @@ export declare function detectPublishType(directoryPath: string): Promise<Publis
|
|
|
118
142
|
* already exists from an earlier attempt, retry once replacing it.
|
|
119
143
|
*/
|
|
120
144
|
export declare function executePublish(plan: PublishPlan, progressCallback: (msg: string) => void): Promise<PublishResult>;
|
|
145
|
+
/**
|
|
146
|
+
* The folders next to `rootDir` (its parent's immediate subfolders) whose
|
|
147
|
+
* `manifest.json` is one of `wanted` (same type and name), at most one per
|
|
148
|
+
* dependency, skipping `rootDir` and the `exclude` folders. A folder whose
|
|
149
|
+
* manifest is missing or invalid is skipped, and so is one in an org other than
|
|
150
|
+
* `rootOrg`, which the root's dependencies never resolve to. Each entry is
|
|
151
|
+
* labelled with its path relative to the working directory.
|
|
152
|
+
*/
|
|
153
|
+
export declare function findSiblingDependencies(rootDir: string, wanted: readonly DeclaredDependency[], exclude?: readonly string[], rootOrg?: string): Promise<PublishEntry[]>;
|
|
121
154
|
/**
|
|
122
155
|
* One resolved dependency as a line: `skill:foo ^1.0.0 → 1.2.0 (@acme)`.
|
|
123
156
|
* The org is `global` when the dependency resolved outside any org, and
|
|
@@ -136,20 +169,33 @@ export declare function isOrgAsset(plan: PublishPlan): boolean;
|
|
|
136
169
|
* Returns true if the given publish target is org-scoped (asset or bundle).
|
|
137
170
|
*/
|
|
138
171
|
export declare function isOrgScopedTarget(target: PublishTarget): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Read each `--with` folder the same way as the root asset. Each one must be an
|
|
174
|
+
* asset folder (a `manifest.json`), other than `rootDir` and named once; the
|
|
175
|
+
* error names the folder as given.
|
|
176
|
+
*/
|
|
177
|
+
export declare function loadPublishEntries(paths: readonly string[], rootDir: string): Promise<PublishEntry[]>;
|
|
139
178
|
/**
|
|
140
179
|
* Turn a publish failure into the message shown to the user.
|
|
141
180
|
*
|
|
142
181
|
* API errors keep the wording chosen by the api-client mapping (auth,
|
|
143
182
|
* membership, validation detail lines, verbatim 409 conflicts) with one
|
|
144
183
|
* publish-specific rewrite for `branch_exists`. Anything else is passed
|
|
145
|
-
* through as-is.
|
|
184
|
+
* through as-is. The API names a problem in a request entry `dependencies[i]`;
|
|
185
|
+
* with `entryLabels` that becomes the entry's folder.
|
|
186
|
+
*/
|
|
187
|
+
export declare function mapPublishError(error: unknown, entryLabels?: readonly string[]): string;
|
|
188
|
+
/**
|
|
189
|
+
* The root manifest's dependencies that a `422 dependency_*` reported
|
|
190
|
+
* (`/dependencies/<i>` issues on the root asset, not on a request entry).
|
|
146
191
|
*/
|
|
147
|
-
export declare function
|
|
192
|
+
export declare function missingDependencies(manifest: Manifest, issues: readonly ValidationIssue[]): DeclaredDependency[];
|
|
148
193
|
/**
|
|
149
194
|
* Resolve the manifest's dependencies through `POST /publish/plan` so the
|
|
150
195
|
* preview, `--dry-run` and `--json` can show them, and a dependency the
|
|
151
196
|
* registry can't satisfy (`422 dependency_*`) stops the run before the
|
|
152
|
-
* confirm prompt.
|
|
197
|
+
* confirm prompt. A plan with entries gets each entry's plan too. Bundles, and
|
|
198
|
+
* assets with neither dependencies nor entries, skip the call.
|
|
153
199
|
*/
|
|
154
200
|
export declare function resolvePlanDependencies(plan: PublishPlan): Promise<PublishPlan>;
|
|
155
201
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publisher.d.ts","sourceRoot":"","sources":["../../src/lib/publisher.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"publisher.d.ts","sourceRoot":"","sources":["../../src/lib/publisher.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,iBAAiB,EAEjB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AAe,EAAE,GAAG,kBAAkB,EAAE,CAUhH;AAED;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAWrF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,CAKnE;AAED,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAMf;AAMD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,gBAAgB,CAAC,CAuK3B"}
|
package/build/lib/publisher.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { stat } from 'node:fs/promises';
|
|
2
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
3
3
|
import { cp, mkdir, mkdtemp, readFile, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
|
-
import { dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
6
6
|
import { compare as semverCompare, inc as semverInc, valid as semverValid } from 'semver';
|
|
7
7
|
import { callApi, isApiError } from './api-client.js';
|
|
8
8
|
import { collectFilesRecursive, hashDirectory } from './checksum.js';
|
|
@@ -28,15 +28,11 @@ import { writeJsonFile } from './write-file.js';
|
|
|
28
28
|
* sends each as `utf8` or `base64`). A bundle may only add `README.md`.
|
|
29
29
|
* - `reviewers` is sent only for org-scoped targets; the API assigns the
|
|
30
30
|
* default reviewers for global targets and rejects an explicit list.
|
|
31
|
+
* - The plan's entries go as `dependencies`, each read the same way as the root.
|
|
31
32
|
*/
|
|
32
33
|
export async function buildPublishInput(plan) {
|
|
33
34
|
const { target } = plan;
|
|
34
|
-
const
|
|
35
|
-
const raw = await readFile(join(target.sourceDir, manifestFileName), 'utf-8');
|
|
36
|
-
const manifest = JSON.parse(raw);
|
|
37
|
-
if (target.type === 'asset' && target.data.files === 'auto') {
|
|
38
|
-
manifest.files = await resolveAutoFiles(target.sourceDir, target.data.entrypoint);
|
|
39
|
-
}
|
|
35
|
+
const manifest = await readPublishManifest(target);
|
|
40
36
|
const reviewers = isOrgScopedTarget(target) ? resolveReviewersForPlan(plan) : [];
|
|
41
37
|
const extras = {
|
|
42
38
|
...(plan.message ? { message: plan.message } : {}),
|
|
@@ -49,15 +45,23 @@ export async function buildPublishInput(plan) {
|
|
|
49
45
|
: undefined;
|
|
50
46
|
return { kind: 'bundle', manifest: manifest, ...(readme === undefined ? {} : { readme }), ...extras };
|
|
51
47
|
}
|
|
52
|
-
const files =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
const files = await readAssetFiles(target.sourceDir, plan.files);
|
|
49
|
+
const dependencies = [];
|
|
50
|
+
for (const entry of plan.entries ?? []) {
|
|
51
|
+
dependencies.push({
|
|
52
|
+
files: await readAssetFiles(entry.target.sourceDir, await collectFilesToPublish(entry.target)),
|
|
53
|
+
manifest: (await readPublishManifest(entry.target)),
|
|
54
|
+
});
|
|
57
55
|
}
|
|
58
|
-
return {
|
|
56
|
+
return {
|
|
57
|
+
...(dependencies.length > 0 ? { dependencies } : {}),
|
|
58
|
+
files,
|
|
59
|
+
kind: 'asset',
|
|
60
|
+
manifest: manifest,
|
|
61
|
+
...extras,
|
|
62
|
+
};
|
|
59
63
|
}
|
|
60
|
-
export async function buildPublishPlan(target, resolvedVersion, isUpdate, message, orgReviewers) {
|
|
64
|
+
export async function buildPublishPlan(target, resolvedVersion, isUpdate, message, orgReviewers, entries) {
|
|
61
65
|
const checksum = await hashDirectory(target.sourceDir);
|
|
62
66
|
const name = target.data.name;
|
|
63
67
|
let branchName;
|
|
@@ -91,6 +95,7 @@ export async function buildPublishPlan(target, resolvedVersion, isUpdate, messag
|
|
|
91
95
|
return {
|
|
92
96
|
branchName,
|
|
93
97
|
checksum,
|
|
98
|
+
...(entries && entries.length > 0 ? { entries } : {}),
|
|
94
99
|
files,
|
|
95
100
|
isUpdate,
|
|
96
101
|
...(message ? { message } : {}),
|
|
@@ -344,9 +349,11 @@ export async function executePublish(plan, progressCallback) {
|
|
|
344
349
|
onReplacingBranch: () => progressCallback('Replacing existing branch...'),
|
|
345
350
|
}));
|
|
346
351
|
const warnings = [...new Set([...(apiPlan.warnings ?? []), ...(published.warnings ?? [])])];
|
|
352
|
+
const entries = withEntryPlans(plan.entries, apiPlan.entries);
|
|
347
353
|
return {
|
|
348
354
|
branchName: published.branchName || apiPlan.branchName || plan.branchName,
|
|
349
355
|
dependencies: apiPlan.dependencies,
|
|
356
|
+
...(entries ? { entries } : {}),
|
|
350
357
|
mode: 'pr',
|
|
351
358
|
prNumber: published.prNumber,
|
|
352
359
|
prUrl: published.prUrl,
|
|
@@ -357,6 +364,44 @@ export async function executePublish(plan, progressCallback) {
|
|
|
357
364
|
// ---------------------------------------------------------------------------
|
|
358
365
|
// Publish plan
|
|
359
366
|
// ---------------------------------------------------------------------------
|
|
367
|
+
/**
|
|
368
|
+
* The folders next to `rootDir` (its parent's immediate subfolders) whose
|
|
369
|
+
* `manifest.json` is one of `wanted` (same type and name), at most one per
|
|
370
|
+
* dependency, skipping `rootDir` and the `exclude` folders. A folder whose
|
|
371
|
+
* manifest is missing or invalid is skipped, and so is one in an org other than
|
|
372
|
+
* `rootOrg`, which the root's dependencies never resolve to. Each entry is
|
|
373
|
+
* labelled with its path relative to the working directory.
|
|
374
|
+
*/
|
|
375
|
+
export async function findSiblingDependencies(rootDir, wanted, exclude = [], rootOrg) {
|
|
376
|
+
const parent = dirname(resolve(rootDir));
|
|
377
|
+
const skip = new Set([resolve(rootDir), ...exclude.map((dir) => resolve(dir))]);
|
|
378
|
+
const found = [];
|
|
379
|
+
for (const name of (await readdir(parent)).sort((a, b) => a.localeCompare(b))) {
|
|
380
|
+
const dir = join(parent, name);
|
|
381
|
+
// A linked folder counts too; existsSync and detectPublishType follow the link.
|
|
382
|
+
if (skip.has(dir) || !existsSync(join(dir, 'manifest.json'))) {
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
let target;
|
|
386
|
+
try {
|
|
387
|
+
target = await detectPublishType(dir);
|
|
388
|
+
}
|
|
389
|
+
catch {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const manifest = target.data;
|
|
393
|
+
const sameAsset = (t) => t.assetType === manifest.type && t.data.name === manifest.name;
|
|
394
|
+
if (wanted.some((d) => d.type === manifest.type && d.name === manifest.name) &&
|
|
395
|
+
(manifest.org === undefined || manifest.org === rootOrg) &&
|
|
396
|
+
!found.some((e) => sameAsset(e.target))) {
|
|
397
|
+
const relative = toRelativePosix(process.cwd(), dir);
|
|
398
|
+
// On another drive there is no relative path; the absolute one is the label.
|
|
399
|
+
const label = isAbsolute(relative) ? dir : relative.startsWith('.') ? relative : `./${relative}`;
|
|
400
|
+
found.push({ label, target });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return found;
|
|
404
|
+
}
|
|
360
405
|
/**
|
|
361
406
|
* One resolved dependency as a line: `skill:foo ^1.0.0 → 1.2.0 (@acme)`.
|
|
362
407
|
* The org is `global` when the dependency resolved outside any org, and
|
|
@@ -460,51 +505,89 @@ export function generatePrBody(target, name, version, isUpdate, files, message)
|
|
|
460
505
|
export function isOrgAsset(plan) {
|
|
461
506
|
return isOrgScopedTarget(plan.target);
|
|
462
507
|
}
|
|
508
|
+
// ---------------------------------------------------------------------------
|
|
509
|
+
// Org detection
|
|
510
|
+
// ---------------------------------------------------------------------------
|
|
463
511
|
/**
|
|
464
512
|
* Returns true if the given publish target is org-scoped (asset or bundle).
|
|
465
513
|
*/
|
|
466
514
|
export function isOrgScopedTarget(target) {
|
|
467
515
|
return !!target.data.org;
|
|
468
516
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
517
|
+
/**
|
|
518
|
+
* Read each `--with` folder the same way as the root asset. Each one must be an
|
|
519
|
+
* asset folder (a `manifest.json`), other than `rootDir` and named once; the
|
|
520
|
+
* error names the folder as given.
|
|
521
|
+
*/
|
|
522
|
+
export async function loadPublishEntries(paths, rootDir) {
|
|
523
|
+
const entries = [];
|
|
524
|
+
const seen = new Set([resolve(rootDir)]);
|
|
525
|
+
for (const label of paths) {
|
|
526
|
+
const dir = resolve(label);
|
|
527
|
+
if (dir === resolve(rootDir)) {
|
|
528
|
+
throw new Error(`--with ${label}: that is the asset being published.`);
|
|
529
|
+
}
|
|
530
|
+
if (seen.has(dir)) {
|
|
531
|
+
throw new Error(`--with ${label}: the folder is given more than once.`);
|
|
532
|
+
}
|
|
533
|
+
seen.add(dir);
|
|
534
|
+
let target;
|
|
535
|
+
try {
|
|
536
|
+
target = await detectPublishType(dir);
|
|
537
|
+
}
|
|
538
|
+
catch (err) {
|
|
539
|
+
throw new Error(`--with ${label}: ${errorMessage(err)}`);
|
|
540
|
+
}
|
|
541
|
+
if (target.type !== 'asset') {
|
|
542
|
+
throw new Error(`--with ${label}: a bundle is published on its own; --with takes asset folders only.`);
|
|
543
|
+
}
|
|
544
|
+
entries.push({ label, target });
|
|
545
|
+
}
|
|
546
|
+
return entries;
|
|
547
|
+
}
|
|
472
548
|
/**
|
|
473
549
|
* Turn a publish failure into the message shown to the user.
|
|
474
550
|
*
|
|
475
551
|
* API errors keep the wording chosen by the api-client mapping (auth,
|
|
476
552
|
* membership, validation detail lines, verbatim 409 conflicts) with one
|
|
477
553
|
* publish-specific rewrite for `branch_exists`. Anything else is passed
|
|
478
|
-
* through as-is.
|
|
554
|
+
* through as-is. The API names a problem in a request entry `dependencies[i]`;
|
|
555
|
+
* with `entryLabels` that becomes the entry's folder.
|
|
479
556
|
*/
|
|
480
|
-
export function mapPublishError(error) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
557
|
+
export function mapPublishError(error, entryLabels = []) {
|
|
558
|
+
return publishErrorMessage(error).replace(/dependencies\[(\d+)\]/g, (match, index) => entryLabels[Number(index)] ?? match);
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* The root manifest's dependencies that a `422 dependency_*` reported
|
|
562
|
+
* (`/dependencies/<i>` issues on the root asset, not on a request entry).
|
|
563
|
+
*/
|
|
564
|
+
export function missingDependencies(manifest, issues) {
|
|
565
|
+
const missing = [];
|
|
566
|
+
for (const issue of issues) {
|
|
567
|
+
const index = issue.entry === undefined ? /^\/dependencies\/(\d+)$/.exec(issue.path ?? '')?.[1] : undefined;
|
|
568
|
+
const dependency = index === undefined ? undefined : manifest.dependencies?.[Number(index)];
|
|
569
|
+
if (dependency && !missing.includes(dependency)) {
|
|
570
|
+
missing.push(dependency);
|
|
490
571
|
}
|
|
491
|
-
return error.message;
|
|
492
572
|
}
|
|
493
|
-
return
|
|
573
|
+
return missing;
|
|
494
574
|
}
|
|
495
575
|
/**
|
|
496
576
|
* Resolve the manifest's dependencies through `POST /publish/plan` so the
|
|
497
577
|
* preview, `--dry-run` and `--json` can show them, and a dependency the
|
|
498
578
|
* registry can't satisfy (`422 dependency_*`) stops the run before the
|
|
499
|
-
* confirm prompt.
|
|
579
|
+
* confirm prompt. A plan with entries gets each entry's plan too. Bundles, and
|
|
580
|
+
* assets with neither dependencies nor entries, skip the call.
|
|
500
581
|
*/
|
|
501
582
|
export async function resolvePlanDependencies(plan) {
|
|
502
|
-
if (plan.target.type !== 'asset' ||
|
|
583
|
+
if (plan.target.type !== 'asset' ||
|
|
584
|
+
(!plan.target.data.dependencies?.length && !plan.entries?.length)) {
|
|
503
585
|
return plan;
|
|
504
586
|
}
|
|
505
587
|
const input = await buildPublishInput(plan);
|
|
506
588
|
const apiPlan = await callApi('publish plan', (atk) => atk.publish.plan(input));
|
|
507
|
-
|
|
589
|
+
const entries = withEntryPlans(plan.entries, apiPlan.entries);
|
|
590
|
+
return { ...plan, dependencies: apiPlan.dependencies, ...(entries ? { entries } : {}) };
|
|
508
591
|
}
|
|
509
592
|
/**
|
|
510
593
|
* Resolve the PR reviewers for a publish plan.
|
|
@@ -529,9 +612,6 @@ export async function updateManifestField(sourceDir, manifestFile, field, value)
|
|
|
529
612
|
}
|
|
530
613
|
await writeJsonFile(filePath, parsed);
|
|
531
614
|
}
|
|
532
|
-
// ---------------------------------------------------------------------------
|
|
533
|
-
// PR content generation
|
|
534
|
-
// ---------------------------------------------------------------------------
|
|
535
615
|
export async function updateManifestVersion(sourceDir, manifestFile, newVersion) {
|
|
536
616
|
const filePath = join(sourceDir, manifestFile);
|
|
537
617
|
const raw = await readFile(filePath, 'utf-8');
|
|
@@ -539,6 +619,9 @@ export async function updateManifestVersion(sourceDir, manifestFile, newVersion)
|
|
|
539
619
|
parsed['version'] = newVersion;
|
|
540
620
|
await writeJsonFile(filePath, parsed);
|
|
541
621
|
}
|
|
622
|
+
// ---------------------------------------------------------------------------
|
|
623
|
+
// PR content generation
|
|
624
|
+
// ---------------------------------------------------------------------------
|
|
542
625
|
export async function validatePublishTarget(target, context) {
|
|
543
626
|
const errors = [];
|
|
544
627
|
const warnings = [];
|
|
@@ -725,9 +808,6 @@ function generatePrTitle(target, name, version, isUpdate) {
|
|
|
725
808
|
? `feat(registry): update ${assetType} ${name} to ${version}`
|
|
726
809
|
: `feat(registry): add ${assetType} ${name}@${version}`;
|
|
727
810
|
}
|
|
728
|
-
// ---------------------------------------------------------------------------
|
|
729
|
-
// Publish execution
|
|
730
|
-
// ---------------------------------------------------------------------------
|
|
731
811
|
/**
|
|
732
812
|
* Match a project-relative path against an adapter placement path template.
|
|
733
813
|
* Returns the extracted `{name}` value if the path matches, or null otherwise.
|
|
@@ -756,6 +836,43 @@ function matchPlacementPattern(inputRelPath, placementPath) {
|
|
|
756
836
|
}
|
|
757
837
|
return null;
|
|
758
838
|
}
|
|
839
|
+
// ---------------------------------------------------------------------------
|
|
840
|
+
// Publish execution
|
|
841
|
+
// ---------------------------------------------------------------------------
|
|
842
|
+
function publishErrorMessage(error) {
|
|
843
|
+
if (isApiError(error)) {
|
|
844
|
+
if (error.code === 'branch_exists') {
|
|
845
|
+
return 'Branch already exists. A PR may already be open for this version.';
|
|
846
|
+
}
|
|
847
|
+
if (error.status === 401 || error.status === 403) {
|
|
848
|
+
return error.message;
|
|
849
|
+
}
|
|
850
|
+
if (error.status === 0 || error.status >= 500) {
|
|
851
|
+
return error.hint ? `${error.message} ${error.hint}` : error.message;
|
|
852
|
+
}
|
|
853
|
+
return error.message;
|
|
854
|
+
}
|
|
855
|
+
return errorMessage(error);
|
|
856
|
+
}
|
|
857
|
+
/** The bytes of every planned file of an asset except its manifest, which is sent as an object. */
|
|
858
|
+
async function readAssetFiles(sourceDir, files) {
|
|
859
|
+
const read = [];
|
|
860
|
+
for (const file of files) {
|
|
861
|
+
if (file !== 'manifest.json') {
|
|
862
|
+
read.push({ bytes: Buffer.from(await readFile(join(sourceDir, file))), path: file });
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return read;
|
|
866
|
+
}
|
|
867
|
+
/** The on-disk manifest (or bundle.json) as written, with an asset's `files: "auto"` expanded. */
|
|
868
|
+
async function readPublishManifest(target) {
|
|
869
|
+
const manifestFileName = target.type === 'asset' ? 'manifest.json' : 'bundle.json';
|
|
870
|
+
const manifest = JSON.parse(await readFile(join(target.sourceDir, manifestFileName), 'utf-8'));
|
|
871
|
+
if (target.type === 'asset' && target.data.files === 'auto') {
|
|
872
|
+
manifest.files = await resolveAutoFiles(target.sourceDir, target.data.entrypoint);
|
|
873
|
+
}
|
|
874
|
+
return manifest;
|
|
875
|
+
}
|
|
759
876
|
/**
|
|
760
877
|
* Resolve the concrete list of additional files for an asset whose manifest uses
|
|
761
878
|
* `files: "auto"`. Globs the asset directory, excluding files tracked separately
|
|
@@ -776,4 +893,8 @@ async function resolveAutoFiles(sourceDir, entrypoint) {
|
|
|
776
893
|
// ---------------------------------------------------------------------------
|
|
777
894
|
// Error helpers
|
|
778
895
|
// ---------------------------------------------------------------------------
|
|
896
|
+
/** The plan's entries with the API's plan for each (`entries[i]` answers `dependencies[i]`). */
|
|
897
|
+
function withEntryPlans(entries, plans) {
|
|
898
|
+
return entries?.length ? entries.map((entry, i) => ({ ...entry, plan: plans[i] })) : undefined;
|
|
899
|
+
}
|
|
779
900
|
//# sourceMappingURL=publisher.js.map
|