@sanity/workflows-cli 0.0.0-stage → 0.0.0
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 +1574 -0
- package/LICENSE +21 -0
- package/README.md +797 -2
- package/bin/run.js +8 -0
- package/dist/command-ids.d.ts +10 -0
- package/dist/command-ids.js +10 -0
- package/dist/commands/workflows/abort.d.ts +29 -0
- package/dist/commands/workflows/abort.js +50 -0
- package/dist/commands/workflows/blueprints/generate.d.ts +12 -0
- package/dist/commands/workflows/blueprints/generate.js +46 -0
- package/dist/commands/workflows/codemod/packages.d.ts +13 -0
- package/dist/commands/workflows/codemod/packages.js +41 -0
- package/dist/commands/workflows/definitions/delete.d.ts +44 -0
- package/dist/commands/workflows/definitions/delete.js +74 -0
- package/dist/commands/workflows/definitions/diff.d.ts +23 -0
- package/dist/commands/workflows/definitions/diff.js +55 -0
- package/dist/commands/workflows/definitions/list.d.ts +51 -0
- package/dist/commands/workflows/definitions/list.js +139 -0
- package/dist/commands/workflows/definitions/show.d.ts +65 -0
- package/dist/commands/workflows/definitions/show.js +129 -0
- package/dist/commands/workflows/definitions/validate.d.ts +14 -0
- package/dist/commands/workflows/definitions/validate.js +50 -0
- package/dist/commands/workflows/deploy.d.ts +117 -0
- package/dist/commands/workflows/deploy.js +266 -0
- package/dist/commands/workflows/diagnose.d.ts +52 -0
- package/dist/commands/workflows/diagnose.js +195 -0
- package/dist/commands/workflows/fire-action.d.ts +53 -0
- package/dist/commands/workflows/fire-action.js +182 -0
- package/dist/commands/workflows/list.d.ts +78 -0
- package/dist/commands/workflows/list.js +248 -0
- package/dist/commands/workflows/nuke.d.ts +73 -0
- package/dist/commands/workflows/nuke.js +176 -0
- package/dist/commands/workflows/reset-activity.d.ts +32 -0
- package/dist/commands/workflows/reset-activity.js +60 -0
- package/dist/commands/workflows/show.d.ts +29 -0
- package/dist/commands/workflows/show.js +156 -0
- package/dist/commands/workflows/start.d.ts +57 -0
- package/dist/commands/workflows/start.js +196 -0
- package/dist/commands/workflows/tail.d.ts +23 -0
- package/dist/commands/workflows/tail.js +83 -0
- package/dist/commands/workflows/whoami.d.ts +15 -0
- package/dist/commands/workflows/whoami.js +53 -0
- package/dist/help.d.ts +13 -0
- package/dist/help.js +50 -0
- package/dist/hooks/finally/telemetry.d.ts +3 -0
- package/dist/hooks/finally/telemetry.js +9 -0
- package/dist/hooks/prerun/telemetry.d.ts +28 -0
- package/dist/hooks/prerun/telemetry.js +37 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/base-command.d.ts +14 -0
- package/dist/lib/base-command.js +34 -0
- package/dist/lib/blueprint-emit.d.ts +56 -0
- package/dist/lib/blueprint-emit.js +233 -0
- package/dist/lib/blueprint-needs.d.ts +5 -0
- package/dist/lib/blueprint-needs.js +205 -0
- package/dist/lib/blueprint-stacks.d.ts +6 -0
- package/dist/lib/blueprint-stacks.js +88 -0
- package/dist/lib/cause-detail.d.ts +9 -0
- package/dist/lib/cause-detail.js +112 -0
- package/dist/lib/client.d.ts +24 -0
- package/dist/lib/client.js +40 -0
- package/dist/lib/codemod/manifest-rewrite.d.ts +14 -0
- package/dist/lib/codemod/manifest-rewrite.js +97 -0
- package/dist/lib/codemod/package-map.d.ts +22 -0
- package/dist/lib/codemod/package-map.js +72 -0
- package/dist/lib/codemod/report.d.ts +5 -0
- package/dist/lib/codemod/report.js +43 -0
- package/dist/lib/codemod/run.d.ts +23 -0
- package/dist/lib/codemod/run.js +103 -0
- package/dist/lib/codemod/source-rewrite.d.ts +18 -0
- package/dist/lib/codemod/source-rewrite.js +155 -0
- package/dist/lib/command-context.d.ts +20 -0
- package/dist/lib/command-context.js +24 -0
- package/dist/lib/command-telemetry.d.ts +54 -0
- package/dist/lib/command-telemetry.js +82 -0
- package/dist/lib/context.d.ts +155 -0
- package/dist/lib/context.js +268 -0
- package/dist/lib/default-partition.d.ts +23 -0
- package/dist/lib/default-partition.js +48 -0
- package/dist/lib/definition-files.d.ts +11 -0
- package/dist/lib/definition-files.js +58 -0
- package/dist/lib/definitions.d.ts +63 -0
- package/dist/lib/definitions.js +84 -0
- package/dist/lib/diff.d.ts +12 -0
- package/dist/lib/diff.js +93 -0
- package/dist/lib/env.d.ts +7 -0
- package/dist/lib/env.js +8 -0
- package/dist/lib/fail.d.ts +29 -0
- package/dist/lib/fail.js +46 -0
- package/dist/lib/flags.d.ts +49 -0
- package/dist/lib/flags.js +117 -0
- package/dist/lib/follow-up-command.d.ts +18 -0
- package/dist/lib/follow-up-command.js +12 -0
- package/dist/lib/history-rows.d.ts +3 -0
- package/dist/lib/history-rows.js +44 -0
- package/dist/lib/load-config.d.ts +46 -0
- package/dist/lib/load-config.js +110 -0
- package/dist/lib/nuke.d.ts +124 -0
- package/dist/lib/nuke.js +206 -0
- package/dist/lib/operation-args.d.ts +42 -0
- package/dist/lib/operation-args.js +21 -0
- package/dist/lib/ops-report.d.ts +47 -0
- package/dist/lib/ops-report.js +31 -0
- package/dist/lib/params.d.ts +3 -0
- package/dist/lib/params.js +21 -0
- package/dist/lib/pick-dataset.d.ts +10 -0
- package/dist/lib/pick-dataset.js +30 -0
- package/dist/lib/prompt.d.ts +35 -0
- package/dist/lib/prompt.js +11 -0
- package/dist/lib/read-fanout.d.ts +45 -0
- package/dist/lib/read-fanout.js +44 -0
- package/dist/lib/select-deployment.d.ts +31 -0
- package/dist/lib/select-deployment.js +91 -0
- package/dist/lib/share-definitions.d.ts +101 -0
- package/dist/lib/share-definitions.js +188 -0
- package/dist/lib/telemetry-setup.d.ts +81 -0
- package/dist/lib/telemetry-setup.js +111 -0
- package/dist/lib/telemetry.d.ts +78 -0
- package/dist/lib/telemetry.js +90 -0
- package/dist/lib/ui.d.ts +91 -0
- package/dist/lib/ui.js +116 -0
- package/dist/standalone-argv.d.ts +14 -0
- package/dist/standalone-argv.js +57 -0
- package/oclif.manifest.json +1731 -0
- package/package.json +118 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { FUNCTIONS_DIR, hasDocumentFunctions, HEARTBEAT_BLUEPRINT_PATH, HEARTBEAT_STACK_DIR, } from '@sanity/workflows/blueprints/generate';
|
|
2
|
+
import logSymbols from 'log-symbols';
|
|
3
|
+
import { sectionHeader } from './ui.js';
|
|
4
|
+
const DEPLOY_COMMAND = 'npx sanity@latest blueprints deploy';
|
|
5
|
+
function heartbeatStackWrites(args) {
|
|
6
|
+
const functionDirs = args.plan.deployments.flatMap(({ emission }) => emission?.heartbeat === undefined ? [] : [`${FUNCTIONS_DIR}/${emission.heartbeat.name}/`]);
|
|
7
|
+
return args.applied.filter((write) => write.path.startsWith(`${HEARTBEAT_STACK_DIR}/`) ||
|
|
8
|
+
functionDirs.some((dir) => write.path.startsWith(dir)));
|
|
9
|
+
}
|
|
10
|
+
export function stackDeployLines(args) {
|
|
11
|
+
const lines = [
|
|
12
|
+
...projectStackLines(args.plan),
|
|
13
|
+
...heartbeatStackLines({ ...args, heartbeat: heartbeatStackWrites(args) }),
|
|
14
|
+
];
|
|
15
|
+
return lines.length === 0 ? [] : [sectionHeader('Deploy'), ...lines];
|
|
16
|
+
}
|
|
17
|
+
const changedWrites = (writes) => writes.filter((write) => write.status !== 'unchanged');
|
|
18
|
+
function projectStackLines(plan) {
|
|
19
|
+
const projectStack = plan.deployments.some(({ emission }) => emission !== undefined && hasDocumentFunctions(emission));
|
|
20
|
+
if (!projectStack)
|
|
21
|
+
return [];
|
|
22
|
+
return [
|
|
23
|
+
` project stack: \`${DEPLOY_COMMAND}\` here, with a token that can deploy to the` +
|
|
24
|
+
` project. It holds every document function; redeploy it after any definition change.`,
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
function heartbeatStackLines(args) {
|
|
28
|
+
const { heartbeat, verbose } = args;
|
|
29
|
+
if (heartbeat.length === 0)
|
|
30
|
+
return [];
|
|
31
|
+
const changed = changedWrites(heartbeat);
|
|
32
|
+
const created = changed.some((write) => write.path === HEARTBEAT_BLUEPRINT_PATH && write.status === 'created');
|
|
33
|
+
if (!verbose && changed.length === 0)
|
|
34
|
+
return [];
|
|
35
|
+
return [
|
|
36
|
+
` heartbeat stack: \`${DEPLOY_COMMAND}\` in ${HEARTBEAT_STACK_DIR}/, with an` +
|
|
37
|
+
` organization deploy token. It holds only the scheduled heartbeat.`,
|
|
38
|
+
...(created ? [] : [heartbeatRedeployLine(changed)]),
|
|
39
|
+
...(verbose || created ? missingHeartbeatLines(args.plan) : []),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
function heartbeatRedeployLine(changed) {
|
|
43
|
+
if (changed.length === 0) {
|
|
44
|
+
return (` ${logSymbols.info} the heartbeat stack's files are unchanged: these definitions need no` +
|
|
45
|
+
` heartbeat redeploy. Redeploy both stacks after upgrading the Workflows packages.`);
|
|
46
|
+
}
|
|
47
|
+
return (` ${logSymbols.warning} ${changed.map((write) => write.path).join(', ')} changed: if you` +
|
|
48
|
+
` have deployed the heartbeat stack, redeploy it with the organization deploy token.`);
|
|
49
|
+
}
|
|
50
|
+
function missingHeartbeatLines(plan) {
|
|
51
|
+
const waiting = plan.deployments.flatMap(waitingWithoutHeartbeat);
|
|
52
|
+
if (waiting.length === 0)
|
|
53
|
+
return [];
|
|
54
|
+
return [
|
|
55
|
+
` ${logSymbols.warning} Without the heartbeat stack nothing checks these on a schedule, and nothing reports it:`,
|
|
56
|
+
...waiting.map((line) => ` ${line}`),
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
function waitingWithoutHeartbeat(plan) {
|
|
60
|
+
const heartbeat = plan.emission?.heartbeat;
|
|
61
|
+
if (heartbeat === undefined)
|
|
62
|
+
return [];
|
|
63
|
+
const ticked = new Set(heartbeat.definitions);
|
|
64
|
+
const within = (sites) => [
|
|
65
|
+
...new Set(sites.map((site) => site.definition).filter((name) => ticked.has(name))),
|
|
66
|
+
];
|
|
67
|
+
const deadlines = within(plan.needs.heartbeat.timeSites);
|
|
68
|
+
const spawners = within(plan.needs.heartbeat.spawnSites);
|
|
69
|
+
const effects = plan.hosting.effects.function;
|
|
70
|
+
return [
|
|
71
|
+
...(deadlines.length === 0
|
|
72
|
+
? []
|
|
73
|
+
: [
|
|
74
|
+
`$now deadlines take effect only when another engine call evaluates them in ${deadlines.join(', ')}`,
|
|
75
|
+
]),
|
|
76
|
+
...(spawners.length === 0
|
|
77
|
+
? []
|
|
78
|
+
: [
|
|
79
|
+
`a parent that missed a child settling waits for another engine call in ${spawners.join(', ')}`,
|
|
80
|
+
]),
|
|
81
|
+
...(effects.length === 0
|
|
82
|
+
? []
|
|
83
|
+
: [
|
|
84
|
+
`an effect queued before its drain existed, or whose drain timed out, waits until` +
|
|
85
|
+
` a later drain picks it up: ${effects.join(', ')}`,
|
|
86
|
+
]),
|
|
87
|
+
];
|
|
88
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Diagnosis, type MissingDocument, type StuckCause, type SuggestedRemediation } from '@sanity/workflows';
|
|
2
|
+
export declare function stuckHeadline(cause: StuckCause): string;
|
|
3
|
+
export interface InstanceDiagnostic {
|
|
4
|
+
diagnosis: Diagnosis;
|
|
5
|
+
/** Full evaluation evidence, including references outside the blocking subset. */
|
|
6
|
+
allMissingDocuments?: MissingDocument[] | undefined;
|
|
7
|
+
remediations: SuggestedRemediation[];
|
|
8
|
+
}
|
|
9
|
+
export declare function stuckDiagnosisLines({ diagnosis, allMissingDocuments, remediations, }: InstanceDiagnostic): string[];
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { styleText } from 'node:util';
|
|
2
|
+
import { formatDateTime } from '@sanity/cli-core/dates';
|
|
3
|
+
import { _additionalMissingDocuments, _fieldTargetLabel, _missingDocumentsSummary, } from '@sanity/workflows';
|
|
4
|
+
import logSymbols from 'log-symbols';
|
|
5
|
+
import { sectionHeader } from './ui.js';
|
|
6
|
+
function missingDocumentsDetail(documents) {
|
|
7
|
+
return {
|
|
8
|
+
headline: 'referenced document missing',
|
|
9
|
+
why: [
|
|
10
|
+
...documents.map(({ target, reference }) => `${_fieldTargetLabel(target)}: ${reference.id}`),
|
|
11
|
+
_missingDocumentsSummary(documents),
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function additionalDocumentLines(diagnosis, allMissingDocuments) {
|
|
16
|
+
const documents = _additionalMissingDocuments(diagnosis, allMissingDocuments);
|
|
17
|
+
if (documents.length === 0)
|
|
18
|
+
return [];
|
|
19
|
+
return ['', sectionHeader('Missing references'), ...missingDocumentsDetail(documents).why];
|
|
20
|
+
}
|
|
21
|
+
function failedEffectDetail(effect) {
|
|
22
|
+
const ran = effect.durationMs !== undefined ? ` (after ${effect.durationMs}ms)` : '';
|
|
23
|
+
return {
|
|
24
|
+
headline: `a failed effect from action '${effect.origin.name}' is blocking its activity`,
|
|
25
|
+
why: [
|
|
26
|
+
styleText('red', `${logSymbols.error} failed effect: ${effect.name}`),
|
|
27
|
+
` queued by action '${effect.origin.name}', failed ${formatDateTime(effect.ranAt)}${ran}`,
|
|
28
|
+
...(effect.error !== undefined ? [` error: ${effect.error.message}`] : []),
|
|
29
|
+
'',
|
|
30
|
+
`The activity that fired '${effect.origin.name}' is waiting on this effect. It failed`,
|
|
31
|
+
`against an external system, so the activity never resolves and the stage can't advance.`,
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function hungEffectDetail(effect) {
|
|
36
|
+
return {
|
|
37
|
+
headline: `effect '${effect.name}' was claimed but never completed`,
|
|
38
|
+
why: [
|
|
39
|
+
styleText('yellow', `${logSymbols.warning} hung effect: ${effect.name}`),
|
|
40
|
+
` claimed ${formatDateTime(effect.claim?.claimedAt ?? '?')} but never reported back — the`,
|
|
41
|
+
` drainer likely died mid-dispatch, so it won't drain on its own.`,
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function failedActivityDetail(activity) {
|
|
46
|
+
return {
|
|
47
|
+
headline: `activity '${activity}' failed`,
|
|
48
|
+
why: [
|
|
49
|
+
styleText('red', `${logSymbols.error} activity '${activity}' is in a terminal failed state.`),
|
|
50
|
+
`Any exit transition gated on '${activity}' being done can never fire.`,
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function noTransitionDetail() {
|
|
55
|
+
return {
|
|
56
|
+
headline: `no exit transition's trigger is satisfied`,
|
|
57
|
+
why: [
|
|
58
|
+
`${logSymbols.info} every activity is resolved, but no exit transition's \`when\` is true.`,
|
|
59
|
+
`Likely a routing state value a trigger reads never got written.`,
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function transitionUnevaluableDetail(transitions) {
|
|
64
|
+
return {
|
|
65
|
+
headline: `an exit transition's trigger could not be evaluated`,
|
|
66
|
+
why: [
|
|
67
|
+
`${logSymbols.info} every activity is resolved, but ${transitions.join(', ')} reads an operand`,
|
|
68
|
+
`that is missing or unreadable (GROQ null), so routing is held rather than`,
|
|
69
|
+
`falling through. Make the data the trigger reads readable — publish the`,
|
|
70
|
+
`subject (or fill the field) — and the next tick or commit re-checks the`,
|
|
71
|
+
`transitions; the instance advances only if one is then satisfied. No`,
|
|
72
|
+
`remediation verb fixes this.`,
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function remediationLines(remediations) {
|
|
77
|
+
return remediations.map((r) => ` • ${r.verb} — ${r.rationale}`);
|
|
78
|
+
}
|
|
79
|
+
function causeDetail(cause) {
|
|
80
|
+
switch (cause.kind) {
|
|
81
|
+
case 'document-missing':
|
|
82
|
+
return missingDocumentsDetail(cause.documents);
|
|
83
|
+
case 'failed-effect':
|
|
84
|
+
return failedEffectDetail(cause.effect);
|
|
85
|
+
case 'hung-effect':
|
|
86
|
+
return hungEffectDetail(cause.effect);
|
|
87
|
+
case 'failed-activity':
|
|
88
|
+
return failedActivityDetail(cause.activity);
|
|
89
|
+
case 'no-transition-fires':
|
|
90
|
+
return noTransitionDetail();
|
|
91
|
+
case 'transition-unevaluable':
|
|
92
|
+
return transitionUnevaluableDetail(cause.transitions);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function stuckHeadline(cause) {
|
|
96
|
+
return `${logSymbols.warning} ${styleText('yellow', 'STUCK')} — ${causeDetail(cause).headline}`;
|
|
97
|
+
}
|
|
98
|
+
export function stuckDiagnosisLines({ diagnosis, allMissingDocuments, remediations, }) {
|
|
99
|
+
if (diagnosis.state !== 'stuck')
|
|
100
|
+
return [];
|
|
101
|
+
const detail = causeDetail(diagnosis.cause);
|
|
102
|
+
const runnable = remediations.filter((remediation) => remediation.available);
|
|
103
|
+
return [
|
|
104
|
+
'',
|
|
105
|
+
sectionHeader("Why it's stuck"),
|
|
106
|
+
...detail.why,
|
|
107
|
+
...additionalDocumentLines(diagnosis, allMissingDocuments),
|
|
108
|
+
...(runnable.length > 0
|
|
109
|
+
? ['', sectionHeader('Suggested fix'), ...remediationLines(runnable)]
|
|
110
|
+
: []),
|
|
111
|
+
];
|
|
112
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type SanityClient } from '@sanity/client';
|
|
2
|
+
import { type WorkflowResource } from '@sanity/workflows';
|
|
3
|
+
/**
|
|
4
|
+
* The API host to hit: an explicit `SANITY_API_HOST` wins; otherwise mirror
|
|
5
|
+
* the Sanity CLI — staging routes to the staging API, prod falls through to
|
|
6
|
+
* `@sanity/client`'s default (`undefined` here). Pairs with
|
|
7
|
+
* {@link resolveToken}, which reads the matching session token. Exported so a
|
|
8
|
+
* destructive command can display the environment its clients will hit.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveApiHost(): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the Sanity auth token. An explicit `SANITY_AUTH_TOKEN` wins (CI /
|
|
13
|
+
* scripted use); otherwise fall back to the `sanity login` session token.
|
|
14
|
+
* Throws when neither exists rather than building an unauthenticated client
|
|
15
|
+
* that only 401s once it hits the API.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveToken(): Promise<string>;
|
|
18
|
+
/** {@link resolveToken}, funnelling the no-token case through the clean
|
|
19
|
+
* {@link fail} path rather than letting it surface as an oclif stack. */
|
|
20
|
+
export declare function resolveTokenOrFail(): Promise<string>;
|
|
21
|
+
/** Build a client for a workflow resource, authenticated with `token`. */
|
|
22
|
+
export declare function clientFor(resource: WorkflowResource, token: string): SanityClient;
|
|
23
|
+
/** Build a client for the global API host, not bound to any project or resource. */
|
|
24
|
+
export declare function globalClient(token: string): SanityClient;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getCliToken, isStaging } from '@sanity/cli-core';
|
|
2
|
+
import { createClient } from '@sanity/client';
|
|
3
|
+
import { clientConfigFromResource, ENGINE_API_VERSION, errorMessage, } from '@sanity/workflows';
|
|
4
|
+
import { ENV, envAuthToken } from './env.js';
|
|
5
|
+
import { fail } from './fail.js';
|
|
6
|
+
const API_VERSION = ENGINE_API_VERSION;
|
|
7
|
+
const STAGING_API_HOST = 'https://api.sanity.work';
|
|
8
|
+
export function resolveApiHost() {
|
|
9
|
+
return process.env[ENV.SANITY_API_HOST] ?? (isStaging() ? STAGING_API_HOST : undefined);
|
|
10
|
+
}
|
|
11
|
+
export async function resolveToken() {
|
|
12
|
+
const fromEnv = envAuthToken();
|
|
13
|
+
if (fromEnv !== undefined) {
|
|
14
|
+
return fromEnv;
|
|
15
|
+
}
|
|
16
|
+
const fromSession = await getCliToken();
|
|
17
|
+
if (fromSession) {
|
|
18
|
+
return fromSession;
|
|
19
|
+
}
|
|
20
|
+
throw new Error('No Sanity token found — run `sanity login`, or set SANITY_AUTH_TOKEN.');
|
|
21
|
+
}
|
|
22
|
+
export async function resolveTokenOrFail() {
|
|
23
|
+
return resolveToken().catch((err) => fail('Authentication required:', errorMessage(err)));
|
|
24
|
+
}
|
|
25
|
+
function baseClientConfig(token) {
|
|
26
|
+
const apiHost = resolveApiHost();
|
|
27
|
+
return {
|
|
28
|
+
token,
|
|
29
|
+
apiVersion: API_VERSION,
|
|
30
|
+
useCdn: false,
|
|
31
|
+
requestTagPrefix: 'sanity.workflows.cli',
|
|
32
|
+
...(apiHost ? { apiHost } : {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function clientFor(resource, token) {
|
|
36
|
+
return createClient({ ...baseClientConfig(token), ...clientConfigFromResource(resource) });
|
|
37
|
+
}
|
|
38
|
+
export function globalClient(token) {
|
|
39
|
+
return createClient({ ...baseClientConfig(token), useProjectHostname: false });
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ManifestRewriteResult {
|
|
2
|
+
source: string;
|
|
3
|
+
changes: string[];
|
|
4
|
+
reports: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Replaces every retired package in a `package.json`'s dependency fields with
|
|
8
|
+
* the package that replaces it, at `range`. A replacement lands once per field,
|
|
9
|
+
* in place of the first retired entry it replaces. A dependency the retired
|
|
10
|
+
* package installed and its replacement only peers on is added to the same
|
|
11
|
+
* field when absent. Mentions outside the
|
|
12
|
+
* dependency fields (scripts, overrides) are reported, not rewritten.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rewriteManifest(source: string, range: string): ManifestRewriteResult;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { DEV_ONLY_PACKAGES, isRecord, replacementPackage, retiredNamesIn } from './package-map.js';
|
|
2
|
+
const DEPENDENCY_FIELDS = [
|
|
3
|
+
'dependencies',
|
|
4
|
+
'devDependencies',
|
|
5
|
+
'peerDependencies',
|
|
6
|
+
'optionalDependencies',
|
|
7
|
+
];
|
|
8
|
+
function dependenciesIn(manifest, field) {
|
|
9
|
+
const value = manifest[field];
|
|
10
|
+
if (!isRecord(value))
|
|
11
|
+
return undefined;
|
|
12
|
+
return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === 'string'));
|
|
13
|
+
}
|
|
14
|
+
function indentOf(source) {
|
|
15
|
+
return /^[{[]\r?\n([ \t]+)/.exec(source)?.[1] ?? ' ';
|
|
16
|
+
}
|
|
17
|
+
function targetField(field, replacement) {
|
|
18
|
+
return DEV_ONLY_PACKAGES.has(replacement) && field !== 'peerDependencies'
|
|
19
|
+
? 'devDependencies'
|
|
20
|
+
: field;
|
|
21
|
+
}
|
|
22
|
+
function withReplacements(args) {
|
|
23
|
+
const entries = Object.entries(args.deps).flatMap(([name, range]) => {
|
|
24
|
+
const replacement = replacementPackage(name);
|
|
25
|
+
if (replacement === undefined)
|
|
26
|
+
return [[name, range]];
|
|
27
|
+
const addedRange = args.added.get(replacement);
|
|
28
|
+
return addedRange === undefined ? [] : [[replacement, addedRange]];
|
|
29
|
+
});
|
|
30
|
+
const present = new Set(entries.map(([name]) => name));
|
|
31
|
+
const appended = [...args.added].filter(([name]) => !present.has(name));
|
|
32
|
+
return Object.fromEntries([...entries, ...appended]);
|
|
33
|
+
}
|
|
34
|
+
function rangeFor(declared, range) {
|
|
35
|
+
return declared?.startsWith('workspace:') ? declared : range;
|
|
36
|
+
}
|
|
37
|
+
function planFields(manifest, range) {
|
|
38
|
+
const plans = new Map(DEPENDENCY_FIELDS.map((field) => [field, { removed: [], added: new Map() }]));
|
|
39
|
+
const placed = new Set();
|
|
40
|
+
const add = (field, [name, addedRange]) => {
|
|
41
|
+
const key = `${field}:${name}`;
|
|
42
|
+
if (placed.has(key) || dependenciesIn(manifest, field)?.[name] !== undefined)
|
|
43
|
+
return;
|
|
44
|
+
placed.add(key);
|
|
45
|
+
plans.get(field)?.added.set(name, addedRange);
|
|
46
|
+
};
|
|
47
|
+
DEPENDENCY_FIELDS.forEach((field) => {
|
|
48
|
+
const deps = dependenciesIn(manifest, field) ?? {};
|
|
49
|
+
Object.keys(deps).forEach((name) => {
|
|
50
|
+
const replacement = replacementPackage(name);
|
|
51
|
+
if (replacement === undefined)
|
|
52
|
+
return;
|
|
53
|
+
plans.get(field)?.removed.push(name);
|
|
54
|
+
add(targetField(field, replacement), [replacement, rangeFor(deps[name], range)]);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
return plans;
|
|
58
|
+
}
|
|
59
|
+
function renamedPeerMeta(meta) {
|
|
60
|
+
if (!isRecord(meta))
|
|
61
|
+
return meta;
|
|
62
|
+
return Object.fromEntries(Object.entries(meta).map(([name, value]) => [replacementPackage(name) ?? name, value]));
|
|
63
|
+
}
|
|
64
|
+
function retiredMentions(manifest) {
|
|
65
|
+
return Object.entries(manifest)
|
|
66
|
+
.filter(([key]) => !DEPENDENCY_FIELDS.includes(key))
|
|
67
|
+
.filter(([key]) => key !== 'peerDependenciesMeta')
|
|
68
|
+
.flatMap(([key, value]) => retiredNamesIn(JSON.stringify(value)).map((name) => `"${key}" mentions ${name}`));
|
|
69
|
+
}
|
|
70
|
+
export function rewriteManifest(source, range) {
|
|
71
|
+
const parsed = JSON.parse(source);
|
|
72
|
+
if (!isRecord(parsed))
|
|
73
|
+
return { source, changes: [], reports: [] };
|
|
74
|
+
const plans = planFields(parsed, range);
|
|
75
|
+
const changes = [...plans].flatMap(([field, plan]) => [
|
|
76
|
+
...plan.removed.map((name) => `${field}: removed ${name}`),
|
|
77
|
+
...[...plan.added].map(([name, added]) => `${field}: added ${name}@${added}`),
|
|
78
|
+
]);
|
|
79
|
+
if (changes.length === 0)
|
|
80
|
+
return { source, changes, reports: retiredMentions(parsed) };
|
|
81
|
+
const rewritten = { ...parsed };
|
|
82
|
+
plans.forEach((plan, field) => {
|
|
83
|
+
const deps = dependenciesIn(parsed, field);
|
|
84
|
+
if (deps === undefined && plan.added.size === 0)
|
|
85
|
+
return;
|
|
86
|
+
rewritten[field] = withReplacements({ deps: deps ?? {}, added: plan.added });
|
|
87
|
+
});
|
|
88
|
+
if (parsed['peerDependenciesMeta'] !== undefined) {
|
|
89
|
+
rewritten['peerDependenciesMeta'] = renamedPeerMeta(parsed['peerDependenciesMeta']);
|
|
90
|
+
}
|
|
91
|
+
const trailing = source.endsWith('\n') ? '\n' : '';
|
|
92
|
+
return {
|
|
93
|
+
source: `${JSON.stringify(rewritten, null, indentOf(source))}${trailing}`,
|
|
94
|
+
changes,
|
|
95
|
+
reports: retiredMentions(parsed),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
2
|
+
/** The package that replaces `name`, or `undefined` when `name` was not retired. */
|
|
3
|
+
export declare function replacementPackage(name: string): string | undefined;
|
|
4
|
+
/** The test bench installs as a development dependency, except where a package declares it as a peer. */
|
|
5
|
+
export declare const DEV_ONLY_PACKAGES: ReadonlySet<string>;
|
|
6
|
+
export type SpecifierMatch = {
|
|
7
|
+
kind: 'none';
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'rewrite';
|
|
10
|
+
replacement: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'unknown-entry';
|
|
13
|
+
retired: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* How the codemod treats a module specifier. Only the exact entry points the
|
|
17
|
+
* retired packages exported are rewritten; any other subpath of a retired
|
|
18
|
+
* package resolved nowhere and is reported instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare function matchSpecifier(specifier: string): SpecifierMatch;
|
|
21
|
+
/** The retired package names `text` mentions, each as a whole package-name segment. */
|
|
22
|
+
export declare function retiredNamesIn(text: string): string[];
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const PACKAGE_REPLACEMENTS = {
|
|
2
|
+
'@sanity/workflow-engine': '@sanity/workflows',
|
|
3
|
+
'@sanity/workflow-blueprint': '@sanity/workflows',
|
|
4
|
+
'@sanity/groq-condition-describe': '@sanity/workflows',
|
|
5
|
+
'@sanity/workflow-mcp': '@sanity/workflows',
|
|
6
|
+
'@sanity/workflow-studio-plugin': '@sanity/workflows-ui',
|
|
7
|
+
'@sanity/workflow-studio': '@sanity/workflows-ui',
|
|
8
|
+
'@sanity/workflow-react': '@sanity/workflows-ui',
|
|
9
|
+
'@sanity/workflow-sdk': '@sanity/workflows-ui',
|
|
10
|
+
'@sanity/workflow-components': '@sanity/workflows-ui',
|
|
11
|
+
'@sanity/workflow-diagram': '@sanity/workflows-ui',
|
|
12
|
+
'@sanity/workflow-cli': '@sanity/workflows-cli',
|
|
13
|
+
'@sanity/workflow-engine-test': '@sanity/workflows-test',
|
|
14
|
+
};
|
|
15
|
+
const ENTRY_REPLACEMENTS = {
|
|
16
|
+
'@sanity/workflow-engine': '@sanity/workflows',
|
|
17
|
+
'@sanity/workflow-engine/define': '@sanity/workflows/define',
|
|
18
|
+
'@sanity/workflow-engine/generate': '@sanity/workflows/generate',
|
|
19
|
+
'@sanity/workflow-engine/service': '@sanity/workflows/service',
|
|
20
|
+
'@sanity/workflow-blueprint': '@sanity/workflows/blueprints',
|
|
21
|
+
'@sanity/workflow-blueprint/generate': '@sanity/workflows/blueprints/generate',
|
|
22
|
+
'@sanity/workflow-blueprint/runtime': '@sanity/workflows/blueprints/runtime',
|
|
23
|
+
'@sanity/groq-condition-describe': '@sanity/workflows/describe',
|
|
24
|
+
'@sanity/workflow-mcp': '@sanity/workflows/agents',
|
|
25
|
+
'@sanity/workflow-studio-plugin': '@sanity/workflows-ui/studio-plugin',
|
|
26
|
+
'@sanity/workflow-studio': '@sanity/workflows-ui/studio',
|
|
27
|
+
'@sanity/workflow-react': '@sanity/workflows-ui/react',
|
|
28
|
+
'@sanity/workflow-react/observer': '@sanity/workflows-ui/react/observer',
|
|
29
|
+
'@sanity/workflow-sdk': '@sanity/workflows-ui/sdk',
|
|
30
|
+
'@sanity/workflow-sdk/observer': '@sanity/workflows-ui/sdk/observer',
|
|
31
|
+
'@sanity/workflow-sdk/project-users': '@sanity/workflows-ui/sdk/project-users',
|
|
32
|
+
'@sanity/workflow-components': '@sanity/workflows-ui/components',
|
|
33
|
+
'@sanity/workflow-diagram': '@sanity/workflows-ui/diagram',
|
|
34
|
+
'@sanity/workflow-cli': '@sanity/workflows-cli',
|
|
35
|
+
'@sanity/workflow-engine-test': '@sanity/workflows-test',
|
|
36
|
+
...Object.fromEntries(Object.entries(PACKAGE_REPLACEMENTS).map(([retired, replacement]) => [
|
|
37
|
+
`${retired}/package.json`,
|
|
38
|
+
`${replacement}/package.json`,
|
|
39
|
+
])),
|
|
40
|
+
};
|
|
41
|
+
export function isRecord(value) {
|
|
42
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
43
|
+
}
|
|
44
|
+
export function replacementPackage(name) {
|
|
45
|
+
return Object.hasOwn(PACKAGE_REPLACEMENTS, name)
|
|
46
|
+
? PACKAGE_REPLACEMENTS[name]
|
|
47
|
+
: undefined;
|
|
48
|
+
}
|
|
49
|
+
export const DEV_ONLY_PACKAGES = new Set(['@sanity/workflows-test']);
|
|
50
|
+
function packageNameOf(specifier) {
|
|
51
|
+
const [first = '', second] = specifier.split('/');
|
|
52
|
+
return first.startsWith('@') && second !== undefined ? `${first}/${second}` : first;
|
|
53
|
+
}
|
|
54
|
+
export function matchSpecifier(specifier) {
|
|
55
|
+
const replacement = Object.hasOwn(ENTRY_REPLACEMENTS, specifier)
|
|
56
|
+
? ENTRY_REPLACEMENTS[specifier]
|
|
57
|
+
: undefined;
|
|
58
|
+
if (replacement !== undefined)
|
|
59
|
+
return { kind: 'rewrite', replacement };
|
|
60
|
+
const name = packageNameOf(specifier);
|
|
61
|
+
return replacementPackage(name) === undefined
|
|
62
|
+
? { kind: 'none' }
|
|
63
|
+
: { kind: 'unknown-entry', retired: name };
|
|
64
|
+
}
|
|
65
|
+
const RETIRED_NAME_SOURCE = Object.keys(PACKAGE_REPLACEMENTS)
|
|
66
|
+
.sort((a, b) => b.length - a.length)
|
|
67
|
+
.map((name) => name.replaceAll('/', '\\/'))
|
|
68
|
+
.join('|');
|
|
69
|
+
export function retiredNamesIn(text) {
|
|
70
|
+
const pattern = new RegExp(`(?<![\\w@.-])(?:${RETIRED_NAME_SOURCE})(?![\\w-])`, 'g');
|
|
71
|
+
return [...new Set(text.match(pattern) ?? [])];
|
|
72
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import logSymbols from 'log-symbols';
|
|
2
|
+
const REPORT_LABELS = {
|
|
3
|
+
'unknown-entry': 'not an entry point of the retired package',
|
|
4
|
+
'computed-specifier': 'built-up module specifier',
|
|
5
|
+
string: 'package name in a string',
|
|
6
|
+
'jsx-text': 'package name in JSX text',
|
|
7
|
+
comment: 'package name in a comment',
|
|
8
|
+
'parse-error': 'could not parse the file',
|
|
9
|
+
};
|
|
10
|
+
function rewriteLines(files, verb) {
|
|
11
|
+
const changed = files.filter((file) => file.rewrites.length > 0);
|
|
12
|
+
if (changed.length === 0)
|
|
13
|
+
return [`${logSymbols.info} No imports or dependencies name a retired package.`];
|
|
14
|
+
return [
|
|
15
|
+
`${logSymbols.success} ${verb} ${changed.length} files:`,
|
|
16
|
+
...changed.map((file) => ` ${file.path}: ${file.rewrites.join(', ')}`),
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
function reportLines(files) {
|
|
20
|
+
const reports = files.flatMap((file) => file.reports.map((report) => ` ${file.path}:${report.line} ${REPORT_LABELS[report.kind]}: ${report.text}`));
|
|
21
|
+
if (reports.length === 0)
|
|
22
|
+
return [];
|
|
23
|
+
return ['', `${logSymbols.warning} Fix these by hand:`, ...reports];
|
|
24
|
+
}
|
|
25
|
+
export function codemodLines(args) {
|
|
26
|
+
const generated = args.generated.length === 0
|
|
27
|
+
? []
|
|
28
|
+
: ['', `${logSymbols.info} Skipped ${args.generated.length} generated blueprint files.`];
|
|
29
|
+
const next = args.dryRun
|
|
30
|
+
? []
|
|
31
|
+
: [
|
|
32
|
+
'',
|
|
33
|
+
'Next: install dependencies, then run',
|
|
34
|
+
` ${args.bin} blueprints generate (if the project has a generated blueprint)`,
|
|
35
|
+
'and typecheck.',
|
|
36
|
+
];
|
|
37
|
+
return [
|
|
38
|
+
...rewriteLines(args.files, args.dryRun ? 'Would rewrite' : 'Rewrote'),
|
|
39
|
+
...reportLines(args.files),
|
|
40
|
+
...generated,
|
|
41
|
+
...next,
|
|
42
|
+
];
|
|
43
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type CodemodReport } from './source-rewrite.ts';
|
|
2
|
+
/** One file the codemod changed or has something to report about, relative to the working directory. */
|
|
3
|
+
export interface FileOutcome {
|
|
4
|
+
path: string;
|
|
5
|
+
rewrites: string[];
|
|
6
|
+
reports: CodemodReport[];
|
|
7
|
+
}
|
|
8
|
+
export interface CodemodRun {
|
|
9
|
+
files: FileOutcome[];
|
|
10
|
+
/** Generated blueprint files left for `blueprints generate` to rewrite. */
|
|
11
|
+
generated: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Rewrites retired Workflows package names under `paths`. `range` is the
|
|
15
|
+
* version range written for each replacement package. With `write: false`
|
|
16
|
+
* nothing is written and the outcome describes what would change.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runCodemod(args: {
|
|
19
|
+
paths: readonly string[];
|
|
20
|
+
cwd: string;
|
|
21
|
+
range: string;
|
|
22
|
+
write: boolean;
|
|
23
|
+
}): CodemodRun;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
4
|
+
import { isGeneratedShell } from '@sanity/workflows/blueprints/generate';
|
|
5
|
+
import { rewriteManifest } from './manifest-rewrite.js';
|
|
6
|
+
import { rewriteSource } from './source-rewrite.js';
|
|
7
|
+
const SOURCE_FILE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
8
|
+
const SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist', '.git']);
|
|
9
|
+
function isCodemodTarget(path) {
|
|
10
|
+
return basename(path) === 'package.json' || SOURCE_FILE.test(path);
|
|
11
|
+
}
|
|
12
|
+
function hasGitAncestor(dir) {
|
|
13
|
+
const parent = dirname(dir);
|
|
14
|
+
return existsSync(join(dir, '.git')) || (parent !== dir && hasGitAncestor(parent));
|
|
15
|
+
}
|
|
16
|
+
function insideWorkTree(dir) {
|
|
17
|
+
try {
|
|
18
|
+
execFileSync('git', ['rev-parse', '--is-inside-work-tree'], { cwd: dir, stdio: 'ignore' });
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (!hasGitAncestor(dir))
|
|
23
|
+
return false;
|
|
24
|
+
throw new Error(`git cannot read the work tree at ${dir}, so the files it ignores are unknown.`, {
|
|
25
|
+
cause: error,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function gitFiles(dir) {
|
|
30
|
+
try {
|
|
31
|
+
const listing = execFileSync('git', ['ls-files', '-z', '--cached', '--others', '--exclude-standard', '--', '.'], { cwd: dir, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
32
|
+
return listing
|
|
33
|
+
.split('\0')
|
|
34
|
+
.filter((path) => path !== '')
|
|
35
|
+
.map((path) => join(dir, path))
|
|
36
|
+
.filter((path) => existsSync(path));
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw new Error(`git ls-files failed in ${dir}, so the files git ignores are unknown.`, {
|
|
40
|
+
cause: error,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function walk(dir) {
|
|
45
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
46
|
+
if (entry.isDirectory())
|
|
47
|
+
return SKIPPED_DIRECTORIES.has(entry.name) ? [] : walk(join(dir, entry.name));
|
|
48
|
+
return entry.isFile() ? [join(dir, entry.name)] : [];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function filesUnder(path) {
|
|
52
|
+
if (!statSync(path).isDirectory())
|
|
53
|
+
return [path];
|
|
54
|
+
return (insideWorkTree(path) ? gitFiles(path) : walk(path)).filter((file) => !file.split(/[\\/]/).some((segment) => SKIPPED_DIRECTORIES.has(segment)));
|
|
55
|
+
}
|
|
56
|
+
function isGenerated(path) {
|
|
57
|
+
return existsSync(path) && isGeneratedShell(readFileSync(path, 'utf8'));
|
|
58
|
+
}
|
|
59
|
+
function isGeneratedFile(path) {
|
|
60
|
+
if (basename(path) !== 'package.json')
|
|
61
|
+
return isGenerated(path);
|
|
62
|
+
const dir = dirname(path);
|
|
63
|
+
return isGenerated(join(dir, 'index.ts')) || isGenerated(join(dir, 'sanity.blueprint.ts'));
|
|
64
|
+
}
|
|
65
|
+
function rewriteFile(path, range) {
|
|
66
|
+
const original = readFileSync(path, 'utf8');
|
|
67
|
+
if (basename(path) === 'package.json') {
|
|
68
|
+
const result = rewriteManifest(original, range);
|
|
69
|
+
return {
|
|
70
|
+
source: result.source,
|
|
71
|
+
outcome: {
|
|
72
|
+
rewrites: result.changes,
|
|
73
|
+
reports: result.reports.map((text) => ({ line: 1, kind: 'string', text })),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const result = rewriteSource(original, path);
|
|
78
|
+
return {
|
|
79
|
+
source: result.source,
|
|
80
|
+
outcome: {
|
|
81
|
+
rewrites: result.rewrites === 0 ? [] : [`${result.rewrites} module specifiers`],
|
|
82
|
+
reports: result.reports,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function runCodemod(args) {
|
|
87
|
+
const targets = [
|
|
88
|
+
...new Set(args.paths.flatMap((path) => filesUnder(resolve(args.cwd, path)))),
|
|
89
|
+
].filter(isCodemodTarget);
|
|
90
|
+
const generated = targets.filter(isGeneratedFile);
|
|
91
|
+
const files = targets
|
|
92
|
+
.filter((path) => !generated.includes(path))
|
|
93
|
+
.toSorted()
|
|
94
|
+
.flatMap((path) => {
|
|
95
|
+
const { source, outcome } = rewriteFile(path, args.range);
|
|
96
|
+
if (args.write && outcome.rewrites.length > 0)
|
|
97
|
+
writeFileSync(path, source);
|
|
98
|
+
return outcome.rewrites.length === 0 && outcome.reports.length === 0
|
|
99
|
+
? []
|
|
100
|
+
: [{ path: relative(args.cwd, path), ...outcome }];
|
|
101
|
+
});
|
|
102
|
+
return { files, generated: generated.map((path) => relative(args.cwd, path)).toSorted() };
|
|
103
|
+
}
|