@jskit-ai/jskit-cli 0.2.27 → 0.2.29
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 +3 -2
- package/src/server/cliRuntime/appState.js +226 -0
- package/src/server/cliRuntime/capabilitySupport.js +194 -0
- package/src/server/cliRuntime/descriptorValidation.js +150 -0
- package/src/server/cliRuntime/ioAndMigrations.js +381 -0
- package/src/server/cliRuntime/localPackageSupport.js +390 -0
- package/src/server/cliRuntime/mutationApplication.js +9 -0
- package/src/server/cliRuntime/mutationWhen.js +285 -0
- package/src/server/cliRuntime/mutations/fileMutations.js +247 -0
- package/src/server/cliRuntime/mutations/installMigrationMutation.js +213 -0
- package/src/server/cliRuntime/mutations/mutationPathUtils.js +12 -0
- package/src/server/cliRuntime/mutations/surfaceTargets.js +155 -0
- package/src/server/cliRuntime/mutations/templateContext.js +171 -0
- package/src/server/cliRuntime/mutations/textMutations.js +250 -0
- package/src/server/cliRuntime/packageInstallFlow.js +489 -0
- package/src/server/cliRuntime/packageIntrospection/exportEntries.js +259 -0
- package/src/server/cliRuntime/packageIntrospection/exportedSymbols.js +216 -0
- package/src/server/cliRuntime/packageIntrospection/placementNormalization.js +98 -0
- package/src/server/cliRuntime/packageIntrospection/providerBindingIntrospection.js +377 -0
- package/src/server/cliRuntime/packageIntrospection.js +137 -0
- package/src/server/cliRuntime/packageOptions.js +299 -0
- package/src/server/cliRuntime/packageRegistries.js +343 -0
- package/src/server/cliRuntime/packageTemplateResolution.js +131 -0
- package/src/server/cliRuntime/viteProxy.js +356 -0
- package/src/server/commandHandlers/health.js +292 -0
- package/src/server/commandHandlers/list.js +292 -0
- package/src/server/commandHandlers/package.js +23 -0
- package/src/server/commandHandlers/packageCommands/add.js +282 -0
- package/src/server/commandHandlers/packageCommands/create.js +155 -0
- package/src/server/commandHandlers/packageCommands/generate.js +116 -0
- package/src/server/commandHandlers/packageCommands/migrations.js +155 -0
- package/src/server/commandHandlers/packageCommands/position.js +103 -0
- package/src/server/commandHandlers/packageCommands/remove.js +181 -0
- package/src/server/commandHandlers/packageCommands/update.js +40 -0
- package/src/server/commandHandlers/shared.js +314 -0
- package/src/server/commandHandlers/show/payloads.js +92 -0
- package/src/server/commandHandlers/show/renderBundleText.js +16 -0
- package/src/server/commandHandlers/show/renderHelpers.js +82 -0
- package/src/server/commandHandlers/show/renderPackageCapabilities.js +124 -0
- package/src/server/commandHandlers/show/renderPackageExports.js +203 -0
- package/src/server/commandHandlers/show/renderPackageText.js +332 -0
- package/src/server/commandHandlers/show.js +114 -0
- package/src/server/core/argParser.js +144 -0
- package/src/server/{runtimeDeps.js → core/buildCommandDeps.js} +2 -1
- package/src/server/core/commandCatalog.js +47 -0
- package/src/server/core/createCliRunner.js +150 -0
- package/src/server/core/createCommandHandlers.js +43 -0
- package/src/server/{runCli.js → core/dispatchCli.js} +14 -1
- package/src/server/core/usageHelp.js +344 -0
- package/src/server/index.js +1 -1
- package/src/server/{optionInterpolation.js → shared/optionInterpolation.js} +12 -1
- package/src/server/{pathResolution.js → shared/pathResolution.js} +1 -1
- package/src/server/argParser.js +0 -206
- package/src/server/cliRuntime.js +0 -4956
- package/src/server/commandHandlers.js +0 -2109
- /package/src/server/{cliError.js → shared/cliError.js} +0 -0
- /package/src/server/{collectionUtils.js → shared/collectionUtils.js} +0 -0
- /package/src/server/{outputFormatting.js → shared/outputFormatting.js} +0 -0
- /package/src/server/{packageIdHelpers.js → shared/packageIdHelpers.js} +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureArray,
|
|
3
|
+
ensureObject
|
|
4
|
+
} from "../../shared/collectionUtils.js";
|
|
5
|
+
|
|
6
|
+
async function buildPackageShowPayload({
|
|
7
|
+
packageRegistry,
|
|
8
|
+
packageEntry,
|
|
9
|
+
options,
|
|
10
|
+
inspectPackageOfferings,
|
|
11
|
+
buildFileWriteGroups,
|
|
12
|
+
listDeclaredCapabilities,
|
|
13
|
+
buildCapabilityDetailsForPackage
|
|
14
|
+
} = {}) {
|
|
15
|
+
const descriptor = packageEntry.descriptor;
|
|
16
|
+
const fileWriteGroups = buildFileWriteGroups(
|
|
17
|
+
ensureArray(ensureObject(descriptor.mutations).files),
|
|
18
|
+
{ packageId: descriptor.packageId }
|
|
19
|
+
);
|
|
20
|
+
const fileWriteCount = fileWriteGroups.reduce((total, group) => total + ensureArray(group.files).length, 0);
|
|
21
|
+
const capabilities = ensureObject(descriptor.capabilities);
|
|
22
|
+
const runtime = ensureObject(descriptor.runtime);
|
|
23
|
+
const metadata = ensureObject(descriptor.metadata);
|
|
24
|
+
const mutations = ensureObject(descriptor.mutations);
|
|
25
|
+
const packageInsights = await inspectPackageOfferings({ packageEntry });
|
|
26
|
+
|
|
27
|
+
const payload = {
|
|
28
|
+
kind: "package",
|
|
29
|
+
packageId: descriptor.packageId,
|
|
30
|
+
version: descriptor.version,
|
|
31
|
+
description: String(descriptor.description || ""),
|
|
32
|
+
dependsOn: ensureArray(descriptor.dependsOn).map((value) => String(value)),
|
|
33
|
+
capabilities,
|
|
34
|
+
options: ensureObject(descriptor.options),
|
|
35
|
+
runtime,
|
|
36
|
+
metadata,
|
|
37
|
+
mutations,
|
|
38
|
+
fileWritePlan: {
|
|
39
|
+
groupCount: fileWriteGroups.length,
|
|
40
|
+
fileCount: fileWriteCount,
|
|
41
|
+
groups: fileWriteGroups
|
|
42
|
+
},
|
|
43
|
+
descriptorPath: packageEntry.descriptorRelativePath,
|
|
44
|
+
introspection: {
|
|
45
|
+
available: Boolean(packageInsights.available),
|
|
46
|
+
notes: ensureArray(packageInsights.notes)
|
|
47
|
+
},
|
|
48
|
+
packageExports: ensureArray(packageInsights.packageExports),
|
|
49
|
+
containerBindings: ensureObject(packageInsights.containerBindings),
|
|
50
|
+
exportedSymbols: ensureArray(packageInsights.exportedSymbols)
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const provides = listDeclaredCapabilities(payload.capabilities, "provides");
|
|
54
|
+
const requires = listDeclaredCapabilities(payload.capabilities, "requires");
|
|
55
|
+
const capabilityDetails = options.details
|
|
56
|
+
? buildCapabilityDetailsForPackage({
|
|
57
|
+
packageRegistry,
|
|
58
|
+
packageId: payload.packageId,
|
|
59
|
+
dependsOn: payload.dependsOn,
|
|
60
|
+
provides,
|
|
61
|
+
requires
|
|
62
|
+
})
|
|
63
|
+
: null;
|
|
64
|
+
|
|
65
|
+
if (capabilityDetails) {
|
|
66
|
+
payload.capabilityDetails = capabilityDetails;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
payload,
|
|
71
|
+
provides,
|
|
72
|
+
requires,
|
|
73
|
+
capabilityDetails
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function buildBundleShowPayload(bundle = {}) {
|
|
78
|
+
return {
|
|
79
|
+
kind: "bundle",
|
|
80
|
+
bundleId: bundle.bundleId,
|
|
81
|
+
version: bundle.version,
|
|
82
|
+
description: String(bundle.description || ""),
|
|
83
|
+
provider: Number(bundle.provider) === 1,
|
|
84
|
+
curated: Number(bundle.curated) === 1,
|
|
85
|
+
packages: ensureArray(bundle.packages).map((value) => String(value))
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
buildBundleShowPayload,
|
|
91
|
+
buildPackageShowPayload
|
|
92
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function renderBundlePayloadText({ payload, stdout, color, writeField } = {}) {
|
|
2
|
+
stdout.write(`${color.heading("Information")}\n`);
|
|
3
|
+
writeField("Bundle", payload.bundleId, color.item);
|
|
4
|
+
writeField("Version", payload.version, color.installed);
|
|
5
|
+
if (payload.description) {
|
|
6
|
+
writeField("Description", payload.description);
|
|
7
|
+
}
|
|
8
|
+
stdout.write(`${color.heading(`Packages (${payload.packages.length}):`)}\n`);
|
|
9
|
+
for (const packageId of payload.packages) {
|
|
10
|
+
stdout.write(`- ${color.item(packageId)}\n`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
renderBundlePayloadText
|
|
16
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureArray,
|
|
3
|
+
ensureObject
|
|
4
|
+
} from "../../shared/collectionUtils.js";
|
|
5
|
+
|
|
6
|
+
function createShowRenderHelpers({
|
|
7
|
+
stdout,
|
|
8
|
+
color,
|
|
9
|
+
options,
|
|
10
|
+
deriveProviderDisplayName
|
|
11
|
+
} = {}) {
|
|
12
|
+
const writeField = (label, value, formatValue = (raw) => raw) => {
|
|
13
|
+
stdout.write(`${color.dim(`${label}:`)} ${formatValue(String(value || ""))}\n`);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const writeBindingsSection = (side, bindings) => {
|
|
17
|
+
const sectionSide = String(side || "").trim().toLowerCase();
|
|
18
|
+
const bindingEntries = ensureArray(bindings);
|
|
19
|
+
stdout.write(`${color.heading(`Container bindings ${sectionSide} (${bindingEntries.length}):`)}\n`);
|
|
20
|
+
if (bindingEntries.length < 1) {
|
|
21
|
+
stdout.write(`- ${color.dim("none detected")}\n`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const bindingRecord of bindingEntries) {
|
|
26
|
+
const binding = ensureObject(bindingRecord);
|
|
27
|
+
const token = String(binding.token || "").trim();
|
|
28
|
+
const tokenExpression = String(binding.tokenExpression || "").trim();
|
|
29
|
+
const tokenLabel = binding.tokenResolved === true
|
|
30
|
+
? token
|
|
31
|
+
: token || tokenExpression;
|
|
32
|
+
const bindingMethod = String(binding.binding || "").trim();
|
|
33
|
+
const providerName = deriveProviderDisplayName(binding);
|
|
34
|
+
const lifecycle = String(binding.lifecycle || "").trim();
|
|
35
|
+
const lifecycleSuffix = lifecycle && lifecycle !== "unknown" ? ` ${color.dim(`(${lifecycle})`)}` : "";
|
|
36
|
+
const unresolvedSuffix = binding.tokenResolved === true ? "" : color.dim(" [unresolved token]");
|
|
37
|
+
stdout.write(
|
|
38
|
+
`- ${color.item(tokenLabel)} ${color.installed(`[${bindingMethod}]`)} ${color.dim("by")} ${color.item(providerName)}${lifecycleSuffix}${unresolvedSuffix}\n`
|
|
39
|
+
);
|
|
40
|
+
if (options.details) {
|
|
41
|
+
const location = String(binding.location || "").trim();
|
|
42
|
+
if (location) {
|
|
43
|
+
stdout.write(` ${color.dim(`source: ${location}`)}\n`);
|
|
44
|
+
}
|
|
45
|
+
const providerLabel = String(binding.provider || "").trim();
|
|
46
|
+
if (providerLabel) {
|
|
47
|
+
stdout.write(` ${color.dim(`provider: ${providerLabel}`)}\n`);
|
|
48
|
+
}
|
|
49
|
+
if (binding.tokenResolved !== true && tokenExpression) {
|
|
50
|
+
stdout.write(` ${color.dim(`token expression: ${tokenExpression}`)}\n`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const writeRuntimeProviders = (side, providers) => {
|
|
57
|
+
const sectionSide = String(side || "").trim().toLowerCase();
|
|
58
|
+
const providerEntries = ensureArray(providers);
|
|
59
|
+
if (providerEntries.length < 1) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
stdout.write(`${color.heading(`Runtime ${sectionSide} providers (${providerEntries.length}):`)}\n`);
|
|
64
|
+
for (const provider of providerEntries) {
|
|
65
|
+
const record = ensureObject(provider);
|
|
66
|
+
const entrypoint = String(record.entrypoint || "").trim();
|
|
67
|
+
const exportName = String(record.export || "").trim();
|
|
68
|
+
const label = exportName ? `${entrypoint}#${exportName}` : entrypoint;
|
|
69
|
+
stdout.write(`- ${color.item(label)}\n`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
writeBindingsSection,
|
|
75
|
+
writeField,
|
|
76
|
+
writeRuntimeProviders
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
createShowRenderHelpers
|
|
82
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ensureArray } from "../../shared/collectionUtils.js";
|
|
2
|
+
|
|
3
|
+
function writeCapabilitiesSections({
|
|
4
|
+
payload,
|
|
5
|
+
provides,
|
|
6
|
+
requires,
|
|
7
|
+
capabilityDetails,
|
|
8
|
+
stdout,
|
|
9
|
+
color,
|
|
10
|
+
wrapWidth,
|
|
11
|
+
writeWrappedItems
|
|
12
|
+
} = {}) {
|
|
13
|
+
if (provides.length > 0 || requires.length > 0) {
|
|
14
|
+
stdout.write(`${color.heading("Capabilities:")}\n`);
|
|
15
|
+
if (provides.length > 0) {
|
|
16
|
+
const providesText = provides.map((capabilityId) => color.item(capabilityId)).join(" ");
|
|
17
|
+
stdout.write(`${color.installed("Provides:")} ${providesText}\n`);
|
|
18
|
+
}
|
|
19
|
+
if (requires.length > 0) {
|
|
20
|
+
const requiresText = requires.map((capabilityId) => color.item(capabilityId)).join(" ");
|
|
21
|
+
stdout.write(`${color.installed("Requires:")} ${requiresText}\n`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!capabilityDetails || (capabilityDetails.provides.length < 1 && capabilityDetails.requires.length < 1)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
stdout.write(`${color.heading("Capability details:")}\n`);
|
|
30
|
+
writeCapabilityRecord({
|
|
31
|
+
heading: `Provides detail (${capabilityDetails.provides.length}):`,
|
|
32
|
+
records: capabilityDetails.provides,
|
|
33
|
+
includeDependsOnProviders: false,
|
|
34
|
+
stdout,
|
|
35
|
+
color,
|
|
36
|
+
wrapWidth,
|
|
37
|
+
writeWrappedItems
|
|
38
|
+
});
|
|
39
|
+
writeCapabilityRecord({
|
|
40
|
+
heading: `Requires detail (${capabilityDetails.requires.length}):`,
|
|
41
|
+
records: capabilityDetails.requires,
|
|
42
|
+
includeDependsOnProviders: true,
|
|
43
|
+
stdout,
|
|
44
|
+
color,
|
|
45
|
+
wrapWidth,
|
|
46
|
+
writeWrappedItems
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function writeCapabilityRecord({
|
|
51
|
+
heading,
|
|
52
|
+
records,
|
|
53
|
+
includeDependsOnProviders = false,
|
|
54
|
+
stdout,
|
|
55
|
+
color,
|
|
56
|
+
wrapWidth,
|
|
57
|
+
writeWrappedItems
|
|
58
|
+
} = {}) {
|
|
59
|
+
if (records.length < 1) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
stdout.write(`${color.heading(heading)}\n`);
|
|
63
|
+
for (const record of records) {
|
|
64
|
+
const capabilityId = String(record.capabilityId || "").trim();
|
|
65
|
+
stdout.write(`- ${color.item(capabilityId)}\n`);
|
|
66
|
+
|
|
67
|
+
const providerItems = ensureArray(record.providerDetails).map((detail) => ({
|
|
68
|
+
text: formatPackageSummary(detail),
|
|
69
|
+
rendered: color.item(formatPackageSummary(detail))
|
|
70
|
+
}));
|
|
71
|
+
if (providerItems.length > 0) {
|
|
72
|
+
writeWrappedItems({
|
|
73
|
+
stdout,
|
|
74
|
+
heading: ` ${color.installed(`providers (${providerItems.length}):`)}`,
|
|
75
|
+
lineIndent: " ",
|
|
76
|
+
wrapWidth,
|
|
77
|
+
items: providerItems
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (includeDependsOnProviders) {
|
|
82
|
+
const providersInDependsOn = ensureArray(record.providersInDependsOn).map((packageId) => ({
|
|
83
|
+
text: String(packageId),
|
|
84
|
+
rendered: color.item(String(packageId))
|
|
85
|
+
}));
|
|
86
|
+
if (providersInDependsOn.length > 0) {
|
|
87
|
+
writeWrappedItems({
|
|
88
|
+
stdout,
|
|
89
|
+
heading: ` ${color.installed(`providers in dependsOn (${providersInDependsOn.length}):`)}`,
|
|
90
|
+
lineIndent: " ",
|
|
91
|
+
wrapWidth,
|
|
92
|
+
items: providersInDependsOn
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const requirerItems = ensureArray(record.requirerDetails).map((detail) => ({
|
|
98
|
+
text: formatPackageSummary(detail),
|
|
99
|
+
rendered: color.item(formatPackageSummary(detail))
|
|
100
|
+
}));
|
|
101
|
+
if (requirerItems.length > 0) {
|
|
102
|
+
writeWrappedItems({
|
|
103
|
+
stdout,
|
|
104
|
+
heading: ` ${color.installed(`required by (${requirerItems.length}):`)}`,
|
|
105
|
+
lineIndent: " ",
|
|
106
|
+
wrapWidth,
|
|
107
|
+
items: requirerItems
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function formatPackageSummary(detail) {
|
|
114
|
+
const packageId = String(detail?.packageId || "").trim();
|
|
115
|
+
const version = String(detail?.version || "").trim();
|
|
116
|
+
const descriptorPath = String(detail?.descriptorPath || "").trim();
|
|
117
|
+
const versionSuffix = version ? `@${version}` : "";
|
|
118
|
+
const pathSuffix = descriptorPath ? ` [${descriptorPath}]` : "";
|
|
119
|
+
return `${packageId}${versionSuffix}${pathSuffix}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
writeCapabilitiesSections
|
|
124
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureArray,
|
|
3
|
+
ensureObject
|
|
4
|
+
} from "../../shared/collectionUtils.js";
|
|
5
|
+
|
|
6
|
+
function writePackageExportsSection({
|
|
7
|
+
payload,
|
|
8
|
+
options,
|
|
9
|
+
stdout,
|
|
10
|
+
color,
|
|
11
|
+
wrapWidth,
|
|
12
|
+
normalizeRelativePosixPath,
|
|
13
|
+
shouldShowPackageExportTarget,
|
|
14
|
+
classifyExportedSymbols,
|
|
15
|
+
writeWrappedItems
|
|
16
|
+
} = {}) {
|
|
17
|
+
const introspection = ensureObject(payload.introspection);
|
|
18
|
+
const introspectionAvailable = introspection.available === true;
|
|
19
|
+
|
|
20
|
+
if (!introspectionAvailable) {
|
|
21
|
+
stdout.write(`${color.heading("Code introspection:")}\n`);
|
|
22
|
+
stdout.write(`- ${color.dim("Source files unavailable (descriptor metadata only).")}\n`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const packageExports = ensureArray(payload.packageExports);
|
|
27
|
+
const exportedSymbols = ensureArray(payload.exportedSymbols);
|
|
28
|
+
const exportedSymbolsByFile = new Map(
|
|
29
|
+
exportedSymbols
|
|
30
|
+
.map((entry) => ensureObject(entry))
|
|
31
|
+
.map((entry) => {
|
|
32
|
+
const file = normalizeRelativePosixPath(String(entry.file || "").trim());
|
|
33
|
+
return file ? [file, entry] : null;
|
|
34
|
+
})
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
stdout.write(`${color.heading(`Package exports (${packageExports.length}):`)}\n`);
|
|
39
|
+
if (packageExports.length < 1) {
|
|
40
|
+
stdout.write(`- ${color.dim("none declared")}\n`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const symbolDetailsShown = new Set();
|
|
45
|
+
for (const packageExport of packageExports) {
|
|
46
|
+
const record = ensureObject(packageExport);
|
|
47
|
+
const subpath = String(record.subpath || ".").trim() || ".";
|
|
48
|
+
const condition = String(record.condition || "default").trim() || "default";
|
|
49
|
+
const target = String(record.target || "").trim();
|
|
50
|
+
const targetType = String(record.targetType || "").trim();
|
|
51
|
+
const conditionSuffix = condition !== "default" ? ` ${color.installed(`[${condition}]`)}` : "";
|
|
52
|
+
const status = targetType === "file"
|
|
53
|
+
? record.targetExists === true
|
|
54
|
+
? color.installed("[ok]")
|
|
55
|
+
: color.provider("[missing]")
|
|
56
|
+
: targetType === "pattern"
|
|
57
|
+
? color.dim("[pattern]")
|
|
58
|
+
: color.dim("[external]");
|
|
59
|
+
const showTarget = shouldShowPackageExportTarget({ subpath, target, targetType });
|
|
60
|
+
const targetSuffix = showTarget ? ` -> ${color.item(target)}` : "";
|
|
61
|
+
const subpathLabel = options.details ? color.white(subpath) : color.item(subpath);
|
|
62
|
+
stdout.write(`- ${subpathLabel}${conditionSuffix}${targetSuffix} ${status}\n`);
|
|
63
|
+
|
|
64
|
+
if (!options.details) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (targetType !== "file" || !target.startsWith("./")) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const normalizedTarget = normalizeRelativePosixPath(target.slice(2));
|
|
72
|
+
const summary = ensureObject(exportedSymbolsByFile.get(normalizedTarget));
|
|
73
|
+
if (!summary || Object.keys(summary).length < 1) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const detailKey = `${subpath}::${normalizedTarget}`;
|
|
78
|
+
if (symbolDetailsShown.has(detailKey)) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
symbolDetailsShown.add(detailKey);
|
|
82
|
+
|
|
83
|
+
const symbols = ensureArray(summary.symbols).map((value) => String(value)).filter(Boolean);
|
|
84
|
+
const classifiedSymbols = classifyExportedSymbols(symbols);
|
|
85
|
+
writeClassifiedSymbols({
|
|
86
|
+
label: "providers",
|
|
87
|
+
entries: classifiedSymbols.providers,
|
|
88
|
+
stdout,
|
|
89
|
+
color,
|
|
90
|
+
wrapWidth,
|
|
91
|
+
writeWrappedItems
|
|
92
|
+
});
|
|
93
|
+
writeClassifiedSymbols({
|
|
94
|
+
label: "functions/helpers",
|
|
95
|
+
entries: classifiedSymbols.functions,
|
|
96
|
+
stdout,
|
|
97
|
+
color,
|
|
98
|
+
wrapWidth,
|
|
99
|
+
writeWrappedItems
|
|
100
|
+
});
|
|
101
|
+
writeClassifiedSymbols({
|
|
102
|
+
label: "constants",
|
|
103
|
+
entries: classifiedSymbols.constants,
|
|
104
|
+
stdout,
|
|
105
|
+
color,
|
|
106
|
+
wrapWidth,
|
|
107
|
+
writeWrappedItems
|
|
108
|
+
});
|
|
109
|
+
writeClassifiedSymbols({
|
|
110
|
+
label: "classes/types",
|
|
111
|
+
entries: classifiedSymbols.classesOrTypes,
|
|
112
|
+
stdout,
|
|
113
|
+
color,
|
|
114
|
+
wrapWidth,
|
|
115
|
+
writeWrappedItems
|
|
116
|
+
});
|
|
117
|
+
writeClassifiedSymbols({
|
|
118
|
+
label: "internal/test hooks",
|
|
119
|
+
entries: classifiedSymbols.internals,
|
|
120
|
+
stdout,
|
|
121
|
+
color,
|
|
122
|
+
wrapWidth,
|
|
123
|
+
writeWrappedItems
|
|
124
|
+
});
|
|
125
|
+
writeClassifiedSymbols({
|
|
126
|
+
label: "other symbols",
|
|
127
|
+
entries: classifiedSymbols.others,
|
|
128
|
+
stdout,
|
|
129
|
+
color,
|
|
130
|
+
wrapWidth,
|
|
131
|
+
writeWrappedItems
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (summary.hasDefaultExport === true) {
|
|
135
|
+
stdout.write(` ${color.installed("default export: yes")}\n`);
|
|
136
|
+
}
|
|
137
|
+
const starReExports = ensureArray(summary.starReExports).map((value) => String(value)).filter(Boolean);
|
|
138
|
+
const namedReExports = ensureArray(summary.namedReExports).map((value) => String(value)).filter(Boolean);
|
|
139
|
+
const reExportSummary = [];
|
|
140
|
+
if (namedReExports.length > 0) {
|
|
141
|
+
reExportSummary.push(`named from ${namedReExports.length} files`);
|
|
142
|
+
}
|
|
143
|
+
if (starReExports.length > 0) {
|
|
144
|
+
reExportSummary.push(`star from ${starReExports.length} files`);
|
|
145
|
+
}
|
|
146
|
+
if (options.debugExports && reExportSummary.length > 0) {
|
|
147
|
+
stdout.write(` ${color.dim(`re-export sources: ${reExportSummary.join(", ")}`)}\n`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (options.debugExports && starReExports.length > 0) {
|
|
151
|
+
writeWrappedItems({
|
|
152
|
+
stdout,
|
|
153
|
+
heading: ` ${color.installed(`star re-exports (${starReExports.length}):`)}`,
|
|
154
|
+
lineIndent: " ",
|
|
155
|
+
wrapWidth,
|
|
156
|
+
items: starReExports.map((specifier) => ({
|
|
157
|
+
text: specifier,
|
|
158
|
+
rendered: color.item(specifier)
|
|
159
|
+
}))
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (options.debugExports && namedReExports.length > 0) {
|
|
163
|
+
writeWrappedItems({
|
|
164
|
+
stdout,
|
|
165
|
+
heading: ` ${color.installed(`named re-exports (${namedReExports.length}):`)}`,
|
|
166
|
+
lineIndent: " ",
|
|
167
|
+
wrapWidth,
|
|
168
|
+
items: namedReExports.map((specifier) => ({
|
|
169
|
+
text: specifier,
|
|
170
|
+
rendered: color.item(specifier)
|
|
171
|
+
}))
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function writeClassifiedSymbols({
|
|
178
|
+
label,
|
|
179
|
+
entries,
|
|
180
|
+
stdout,
|
|
181
|
+
color,
|
|
182
|
+
wrapWidth,
|
|
183
|
+
writeWrappedItems
|
|
184
|
+
} = {}) {
|
|
185
|
+
const items = ensureArray(entries).map((entry) => String(entry || "").trim()).filter(Boolean);
|
|
186
|
+
if (items.length < 1) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
writeWrappedItems({
|
|
190
|
+
stdout,
|
|
191
|
+
heading: ` ${color.installed(`${label} (${items.length}):`)}`,
|
|
192
|
+
lineIndent: " ",
|
|
193
|
+
wrapWidth,
|
|
194
|
+
items: items.map((symbol) => ({
|
|
195
|
+
text: symbol,
|
|
196
|
+
rendered: color.item(symbol)
|
|
197
|
+
}))
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export {
|
|
202
|
+
writePackageExportsSection
|
|
203
|
+
};
|