MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / publish

Function publish

packages/plugins/apps/src/pipeline/publish.ts:140–282  ·  view source on GitHub ↗
(
  deps: PublishDeps,
  input: PublishInput,
)

Source from the content-addressed store, hash-verified

138});
139
140export const publish = (
141 deps: PublishDeps,
142 input: PublishInput,
143): Effect.Effect<PublishResult, PublishError> =>
144 Effect.gen(function* () {
145 const owner = input.owner ?? "org";
146 const bundler =
147 deps.bundler ??
148 (yield* defaultBundleBackend().pipe(
149 Effect.mapError((error) => toPublishError("bundle", "", error)),
150 ));
151 const limitError = enforcePublishLimits(input.files);
152 if (limitError) return yield* limitError;
153 const files = fileMap(input.files);
154 const discovered = discover(files);
155 if (isPublishError(discovered)) return yield* discovered;
156
157 const existing = yield* deps.store.getDescriptorRecord(input.app).pipe(
158 Effect.mapError(
159 (cause) =>
160 new PublishError({
161 stage: "project",
162 message: "failed to read existing app descriptor",
163 diagnostics: [],
164 cause,
165 } as never),
166 ),
167 );
168 if (existing?.sourceRef === input.sourceRef) {
169 const descriptorBody = yield* deps.store.getBlob(existing.descriptorKey).pipe(
170 Effect.mapError(
171 () =>
172 new PublishError({
173 stage: "project",
174 message: "failed to read existing descriptor blob",
175 diagnostics: [],
176 }),
177 ),
178 );
179 if (descriptorBody) {
180 return {
181 descriptor: decodeJson(descriptorBody) as AppDescriptor,
182 publishedTools: [],
183 skipped: discovered.skipped,
184 noop: true,
185 };
186 }
187 }
188
189 const staged: {
190 readonly entry: string;
191 readonly bundle: string;
192 readonly collected: readonly CollectedTool[];
193 readonly source: ModuleSourceRef;
194 }[] = [];
195 for (const artifact of discovered.tools) {
196 const bundled = yield* bundleEntry({ files, entry: artifact.entry }, bundler).pipe(
197 Effect.mapError((cause) => toPublishError("bundle", artifact.entry, cause)),

Callers 2

makeAppsExtensionFunction · 0.90
publish.test.tsFile · 0.90

Calls 11

defaultBundleBackendFunction · 0.90
discoverFunction · 0.90
bundleEntryFunction · 0.90
stableStringifyFunction · 0.90
toPublishErrorFunction · 0.85
enforcePublishLimitsFunction · 0.85
fileMapFunction · 0.85
sourceRefFunction · 0.85
toolDescriptorFunction · 0.85
pushMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected