@ms-cloudpack/api-server 0.27.8 → 0.27.10
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/lib/apis/syncDownload.d.ts +5 -5
- package/lib/apis/syncDownload.d.ts.map +1 -1
- package/lib/apis/syncDownload.js +4 -4
- package/lib/apis/syncDownload.js.map +1 -1
- package/lib/apis/syncUpload.d.ts +5 -5
- package/lib/apis/syncUpload.d.ts.map +1 -1
- package/lib/apis/syncUpload.js +4 -4
- package/lib/apis/syncUpload.js.map +1 -1
- package/lib/trpc/createAppRouter.d.ts +4 -4
- package/lib/trpc/createCloudpackServer.d.ts +2 -2
- package/lib/types/ResultJson.d.ts +6 -0
- package/lib/types/ResultJson.d.ts.map +1 -0
- package/lib/types/ResultJson.js +2 -0
- package/lib/types/ResultJson.js.map +1 -0
- package/lib/types/ZodLoginMethod.d.ts +3 -0
- package/lib/types/ZodLoginMethod.d.ts.map +1 -0
- package/lib/types/ZodLoginMethod.js +3 -0
- package/lib/types/ZodLoginMethod.js.map +1 -0
- package/lib/utilities/bundleTask.d.ts.map +1 -1
- package/lib/utilities/bundleTask.js +22 -25
- package/lib/utilities/bundleTask.js.map +1 -1
- package/lib/utilities/createRemoteCacheClient.d.ts +3 -4
- package/lib/utilities/createRemoteCacheClient.d.ts.map +1 -1
- package/lib/utilities/createRemoteCacheClient.js +6 -11
- package/lib/utilities/createRemoteCacheClient.js.map +1 -1
- package/lib/utilities/ensureRemoteCacheEnabled.d.ts +0 -1
- package/lib/utilities/ensureRemoteCacheEnabled.d.ts.map +1 -1
- package/lib/utilities/findImports.d.ts.map +1 -1
- package/lib/utilities/findImports.js +1 -2
- package/lib/utilities/findImports.js.map +1 -1
- package/lib/utilities/readResultFromCache.d.ts +11 -0
- package/lib/utilities/readResultFromCache.d.ts.map +1 -0
- package/lib/utilities/readResultFromCache.js +20 -0
- package/lib/utilities/readResultFromCache.js.map +1 -0
- package/lib/utilities/saveResultToCache.d.ts +7 -0
- package/lib/utilities/saveResultToCache.d.ts.map +1 -0
- package/lib/utilities/saveResultToCache.js +19 -0
- package/lib/utilities/saveResultToCache.js.map +1 -0
- package/package.json +11 -11
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ApiParams } from '../types/ApiParams.js';
|
|
3
3
|
declare const ZodSyncDownloadInput: z.ZodObject<{
|
|
4
|
-
|
|
4
|
+
loginMethod: z.ZodUnion<[z.ZodLiteral<"interactive">, z.ZodLiteral<"azure-cli">, z.ZodLiteral<"device-code">]>;
|
|
5
5
|
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
|
|
6
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
7
7
|
}, {
|
|
8
|
-
|
|
8
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
9
9
|
}>;
|
|
10
10
|
type SyncDownloadInput = z.infer<typeof ZodSyncDownloadInput>;
|
|
11
11
|
export declare function syncDownload(params: ApiParams<SyncDownloadInput, 'session' | 'packages' | 'reporter' | 'telemetryClient' | 'packageHashes'>): Promise<void>;
|
|
@@ -20,10 +20,10 @@ export declare namespace syncDownload {
|
|
|
20
20
|
_meta: object;
|
|
21
21
|
_ctx_out: import("../index.js").Context;
|
|
22
22
|
_input_in: {
|
|
23
|
-
|
|
23
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
24
24
|
};
|
|
25
25
|
_input_out: {
|
|
26
|
-
|
|
26
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
27
27
|
};
|
|
28
28
|
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
29
29
|
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncDownload.d.ts","sourceRoot":"","sources":["../../src/apis/syncDownload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"syncDownload.d.ts","sourceRoot":"","sources":["../../src/apis/syncDownload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAMvD,QAAA,MAAM,oBAAoB;;;;;;EAExB,CAAC;AAEH,KAAK,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE9D,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,CAAC,iBAAiB,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,iBAAiB,GAAG,eAAe,CAAC,GAC9G,OAAO,CAAC,IAAI,CAAC,CAwBf;yBA1BqB,YAAY"}
|
package/lib/apis/syncDownload.js
CHANGED
|
@@ -4,20 +4,20 @@ import { getPackagesToSync } from '../utilities/getPackagesToSync.js';
|
|
|
4
4
|
import { PerfMeasurementSyncDownload } from '../performance/markers.js';
|
|
5
5
|
import { getRemoteCachePromiseResultCounts } from '../utilities/getRemoteCachePromiseResultCounts.js';
|
|
6
6
|
import { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';
|
|
7
|
+
import { ZodLoginMethod } from '../types/ZodLoginMethod.js';
|
|
7
8
|
const ZodSyncDownloadInput = z.object({
|
|
8
|
-
|
|
9
|
+
loginMethod: ZodLoginMethod,
|
|
9
10
|
});
|
|
10
11
|
export async function syncDownload(params) {
|
|
11
12
|
const { input, ctx } = params;
|
|
12
|
-
const {
|
|
13
|
+
const { loginMethod } = input;
|
|
13
14
|
const { session, packages, telemetryClient, packageHashes } = ctx;
|
|
14
15
|
const { resolveMap } = session;
|
|
15
16
|
await telemetryClient.performance.track(PerfMeasurementSyncDownload, async (tracker) => {
|
|
16
17
|
const [client, packagesToSync] = await Promise.all([
|
|
17
18
|
createRemoteCacheClient({
|
|
18
19
|
input: {
|
|
19
|
-
|
|
20
|
-
permissions: { read: true, write: false, list: true },
|
|
20
|
+
loginMethod,
|
|
21
21
|
},
|
|
22
22
|
ctx,
|
|
23
23
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncDownload.js","sourceRoot":"","sources":["../../src/apis/syncDownload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AACtG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"syncDownload.js","sourceRoot":"","sources":["../../src/apis/syncDownload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AACtG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,WAAW,EAAE,cAAc;CAC5B,CAAC,CAAC;AAIH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA+G;IAE/G,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAC9B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,GAAG,CAAC;IAClE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE/B,MAAM,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACrF,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACjD,uBAAuB,CAAC;gBACtB,KAAK,EAAE;oBACL,WAAW;iBACZ;gBACD,GAAG;aACJ,CAAC;YACF,iBAAiB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;SAC3D,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QAE1E,6FAA6F;QAC7F,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAE3D,OAAO,CAAC,aAAa,CAAC,iCAAiC,CAAC,cAAc,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,2CAA2C;AAC3C,YAAY,CAAC,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { publicProcedure } from '../trpc/common.js';\nimport { getPackagesToSync } from '../utilities/getPackagesToSync.js';\nimport type { ApiParams } from '../types/ApiParams.js';\nimport { PerfMeasurementSyncDownload } from '../performance/markers.js';\nimport { getRemoteCachePromiseResultCounts } from '../utilities/getRemoteCachePromiseResultCounts.js';\nimport { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';\nimport { ZodLoginMethod } from '../types/ZodLoginMethod.js';\n\nconst ZodSyncDownloadInput = z.object({\n loginMethod: ZodLoginMethod,\n});\n\ntype SyncDownloadInput = z.infer<typeof ZodSyncDownloadInput>;\n\nexport async function syncDownload(\n params: ApiParams<SyncDownloadInput, 'session' | 'packages' | 'reporter' | 'telemetryClient' | 'packageHashes'>,\n): Promise<void> {\n const { input, ctx } = params;\n const { loginMethod } = input;\n const { session, packages, telemetryClient, packageHashes } = ctx;\n const { resolveMap } = session;\n\n await telemetryClient.performance.track(PerfMeasurementSyncDownload, async (tracker) => {\n const [client, packagesToSync] = await Promise.all([\n createRemoteCacheClient({\n input: {\n loginMethod,\n },\n ctx,\n }),\n getPackagesToSync({ packages, resolveMap, packageHashes }),\n ]);\n\n const downloads = packagesToSync.map((pkg) => client.downloadFolder(pkg));\n\n // Do not reject if there is a failure. Failed downloads will be logged in the task reporter.\n const promiseResults = await Promise.allSettled(downloads);\n\n tracker.setProperties(getRemoteCachePromiseResultCounts(promiseResults));\n });\n}\n\n// Attach a trpc procedure to the function.\nsyncDownload.procedure = publicProcedure.input(ZodSyncDownloadInput).mutation(syncDownload);\n"]}
|
package/lib/apis/syncUpload.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { ApiParams } from '../types/ApiParams.js';
|
|
3
3
|
declare const ZodSyncUploadInput: z.ZodObject<{
|
|
4
|
-
|
|
4
|
+
loginMethod: z.ZodUnion<[z.ZodLiteral<"interactive">, z.ZodLiteral<"azure-cli">, z.ZodLiteral<"device-code">]>;
|
|
5
5
|
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
|
|
6
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
7
7
|
}, {
|
|
8
|
-
|
|
8
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
9
9
|
}>;
|
|
10
10
|
type SyncUploadInput = z.infer<typeof ZodSyncUploadInput>;
|
|
11
11
|
export declare function syncUpload(params: ApiParams<SyncUploadInput, 'session' | 'packages' | 'reporter' | 'bus' | 'taskRunner' | 'watcher' | 'telemetryClient' | 'packageImportPaths' | 'packageHashes'>): Promise<void>;
|
|
@@ -20,10 +20,10 @@ export declare namespace syncUpload {
|
|
|
20
20
|
_meta: object;
|
|
21
21
|
_ctx_out: import("../index.js").Context;
|
|
22
22
|
_input_in: {
|
|
23
|
-
|
|
23
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
24
24
|
};
|
|
25
25
|
_input_out: {
|
|
26
|
-
|
|
26
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
27
27
|
};
|
|
28
28
|
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
29
29
|
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncUpload.d.ts","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"syncUpload.d.ts","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKvD,QAAA,MAAM,kBAAkB;;;;;;EAEtB,CAAC;AAEH,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE1D,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CACf,eAAe,EACb,SAAS,GACT,UAAU,GACV,UAAU,GACV,KAAK,GACL,YAAY,GACZ,SAAS,GACT,iBAAiB,GACjB,oBAAoB,GACpB,eAAe,CAClB,GACA,OAAO,CAAC,IAAI,CAAC,CA+Cf;yBA5DqB,UAAU"}
|
package/lib/apis/syncUpload.js
CHANGED
|
@@ -6,14 +6,15 @@ import { ensureFieldsExist } from '../utilities/ensureFieldsExist.js';
|
|
|
6
6
|
import { PerfMeasurementSyncUpload } from '../performance/markers.js';
|
|
7
7
|
import { getRemoteCachePromiseResultCounts } from '../utilities/getRemoteCachePromiseResultCounts.js';
|
|
8
8
|
import { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';
|
|
9
|
+
import { ZodLoginMethod } from '../types/ZodLoginMethod.js';
|
|
9
10
|
const ZodSyncUploadInput = z.object({
|
|
10
|
-
|
|
11
|
+
loginMethod: ZodLoginMethod,
|
|
11
12
|
});
|
|
12
13
|
export async function syncUpload(params) {
|
|
13
14
|
const { ctx, input } = params;
|
|
14
15
|
const { session, telemetryClient } = ctx;
|
|
15
16
|
const { appPath } = session;
|
|
16
|
-
const {
|
|
17
|
+
const { loginMethod } = input;
|
|
17
18
|
// Glob pattern for the files to upload.
|
|
18
19
|
const globMatches = ['**/*', '!**/*-input.json', '!**/*-output.json'];
|
|
19
20
|
await telemetryClient.performance.track(PerfMeasurementSyncUpload, async (tracker) => {
|
|
@@ -22,8 +23,7 @@ export async function syncUpload(params) {
|
|
|
22
23
|
const [client, { dependencies, result }] = await Promise.all([
|
|
23
24
|
createRemoteCacheClient({
|
|
24
25
|
input: {
|
|
25
|
-
|
|
26
|
-
permissions: { read: false, write: true, list: true },
|
|
26
|
+
loginMethod,
|
|
27
27
|
},
|
|
28
28
|
ctx,
|
|
29
29
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncUpload.js","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,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AC,CAAC;QAEzD,OAAO,CAAC,aAAa,CAAC,iCAAiC,CAAC,cAAc,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,2CAA2C;AAC3C,UAAU,CAAC,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { publicProcedure } from '../trpc/common.js';\nimport { ensurePackageBundled } from './ensurePackageBundled.js';\nimport { basename } from 'path';\nimport { ensureFieldsExist } from '../utilities/ensureFieldsExist.js';\nimport { PerfMeasurementSyncUpload } from '../performance/markers.js';\nimport type { ApiParams } from '../types/ApiParams.js';\nimport { getRemoteCachePromiseResultCounts } from '../utilities/getRemoteCachePromiseResultCounts.js';\nimport { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';\nimport { ZodLoginMethod } from '../types/ZodLoginMethod.js';\n\nconst ZodSyncUploadInput = z.object({\n loginMethod: ZodLoginMethod,\n});\n\ntype SyncUploadInput = z.infer<typeof ZodSyncUploadInput>;\n\nexport async function syncUpload(\n params: ApiParams<\n SyncUploadInput,\n | 'session'\n | 'packages'\n | 'reporter'\n | 'bus'\n | 'taskRunner'\n | 'watcher'\n | 'telemetryClient'\n | 'packageImportPaths'\n | 'packageHashes'\n >,\n): Promise<void> {\n const { ctx, input } = params;\n const { session, telemetryClient } = ctx;\n const { appPath } = session;\n const { loginMethod } = input;\n\n // Glob pattern for the files to upload.\n const globMatches = ['**/*', '!**/*-input.json', '!**/*-output.json'];\n\n await telemetryClient.performance.track(PerfMeasurementSyncUpload, async (tracker) => {\n const packageDefinition = await ctx.packages.get(appPath);\n const { name, version } = ensureFieldsExist(packageDefinition, ['name', 'version']);\n\n const [client, { dependencies, result }] = await Promise.all([\n createRemoteCacheClient({\n input: {\n loginMethod,\n },\n ctx,\n }),\n ensurePackageBundled({\n input: {\n name,\n version,\n enqueueDependencies: true,\n },\n ctx,\n }),\n ]);\n\n const bundledPackages = [result, ...(await dependencies)];\n const packages = bundledPackages\n .filter((p) => p.isExternal)\n .map((p) => ({\n folderName: basename(p.outputPath),\n friendlyName: `${p.name}@${p.version}`,\n path: p.outputPath,\n globMatches,\n }));\n\n const uploads = packages.map((pkg) => client.uploadFolder(pkg));\n\n // Do not reject if there is a failure. Failed uploads will be logged in the task reporter.\n const promiseResults = await Promise.allSettled(uploads);\n\n tracker.setProperties(getRemoteCachePromiseResultCounts(promiseResults));\n });\n}\n\n// Attach a trpc procedure to the function.\nsyncUpload.procedure = publicProcedure.input(ZodSyncUploadInput).mutation(syncUpload);\n"]}
|
|
@@ -181,10 +181,10 @@ export declare function createAppRouter(): {
|
|
|
181
181
|
_meta: object;
|
|
182
182
|
_ctx_out: import("../index.js").Context;
|
|
183
183
|
_input_in: {
|
|
184
|
-
|
|
184
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
185
185
|
};
|
|
186
186
|
_input_out: {
|
|
187
|
-
|
|
187
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
188
188
|
};
|
|
189
189
|
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
190
190
|
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
@@ -199,10 +199,10 @@ export declare function createAppRouter(): {
|
|
|
199
199
|
_meta: object;
|
|
200
200
|
_ctx_out: import("../index.js").Context;
|
|
201
201
|
_input_in: {
|
|
202
|
-
|
|
202
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
203
203
|
};
|
|
204
204
|
_input_out: {
|
|
205
|
-
|
|
205
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
206
206
|
};
|
|
207
207
|
_output_in: typeof import("@trpc/server").unsetMarker;
|
|
208
208
|
_output_out: typeof import("@trpc/server").unsetMarker;
|
|
@@ -45,10 +45,10 @@ export declare function createCloudpackServer(options: {
|
|
|
45
45
|
metric: string;
|
|
46
46
|
}) => void;
|
|
47
47
|
syncDownload: (options: {
|
|
48
|
-
|
|
48
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
49
49
|
}) => Promise<void>;
|
|
50
50
|
syncUpload: (options: {
|
|
51
|
-
|
|
51
|
+
loginMethod: "interactive" | "azure-cli" | "device-code";
|
|
52
52
|
}) => Promise<void>;
|
|
53
53
|
validatePackageOverride: (options: {
|
|
54
54
|
packageName: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BundleRequest } from './BundleRequest.js';
|
|
2
|
+
/**
|
|
3
|
+
* The result object that is written to the cache. This is a subset of the BundleRequest.result object.
|
|
4
|
+
*/
|
|
5
|
+
export type ResultJson = Pick<Exclude<BundleRequest['result'], undefined>, 'bundlerName' | 'entries' | 'hash' | 'outputFiles' | 'warnings' | 'errors'>;
|
|
6
|
+
//# sourceMappingURL=ResultJson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultJson.d.ts","sourceRoot":"","sources":["../../src/types/ResultJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,EAC3C,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,aAAa,GAAG,UAAU,GAAG,QAAQ,CAC3E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultJson.js","sourceRoot":"","sources":["../../src/types/ResultJson.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleRequest } from './BundleRequest.js';\n\n/**\n * The result object that is written to the cache. This is a subset of the BundleRequest.result object.\n */\nexport type ResultJson = Pick<\n Exclude<BundleRequest['result'], undefined>,\n 'bundlerName' | 'entries' | 'hash' | 'outputFiles' | 'warnings' | 'errors'\n>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZodLoginMethod.d.ts","sourceRoot":"","sources":["../../src/types/ZodLoginMethod.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,cAAc,mGAAwF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZodLoginMethod.js","sourceRoot":"","sources":["../../src/types/ZodLoginMethod.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC","sourcesContent":["import z from 'zod';\n\nexport const ZodLoginMethod = z.union([z.literal('interactive'), z.literal('azure-cli'), z.literal('device-code')]);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,6BAA6B,CAAC;AAIrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"bundleTask.d.ts","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,6BAA6B,CAAC;AAIrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAM/D,wBAAsB,UAAU,CAAC,MAAM,EAAE;IACvC,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,GAAG,OAAO,CAAC,aAAa,CAAC,CAqEzB"}
|
|
@@ -11,6 +11,8 @@ import { getPackageSettings } from '@ms-cloudpack/config';
|
|
|
11
11
|
import { isCachedResultValid } from './isCachedResultValid.js';
|
|
12
12
|
import { diskCacheRatioMetricEventAggregator } from './diskCacheRatioMetricEventAggregator.js';
|
|
13
13
|
import { getBundleLocation } from './getBundleLocation.js';
|
|
14
|
+
import { readResultFromCache } from './readResultFromCache.js';
|
|
15
|
+
import { saveResultToCache } from './saveResultToCache.js';
|
|
14
16
|
export async function bundleTask(params) {
|
|
15
17
|
const { bundleRequest, options = {}, reporter, telemetryClient } = params;
|
|
16
18
|
const { packageName, version } = bundleRequest;
|
|
@@ -78,28 +80,10 @@ async function bundle(bundleRequest, force) {
|
|
|
78
80
|
const outputPath = bundleRequest.outputPath ?? (await getBundleLocation({ packagePath }, context)).path;
|
|
79
81
|
// Rehydrate the result if not incremental.
|
|
80
82
|
if (bundleRequest.result === undefined && (isExternal || shouldCacheInternalPackages) && !force) {
|
|
81
|
-
bundleRequest.result = await
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
bundleRequest.result.outputPath = outputPath;
|
|
85
|
-
}
|
|
83
|
+
bundleRequest.result = await readResultFromCache(outputPath, {
|
|
84
|
+
inputPath: packagePath,
|
|
85
|
+
});
|
|
86
86
|
}
|
|
87
|
-
const { userPackageSettings } = getPackageSettings({
|
|
88
|
-
name: bundleRequest.packageName,
|
|
89
|
-
version: bundleRequest.version,
|
|
90
|
-
config,
|
|
91
|
-
}) || {};
|
|
92
|
-
const { bundlerType, bundlerOptions } = userPackageSettings || {};
|
|
93
|
-
const bundleOptions = {
|
|
94
|
-
bundlerType: bundleRequest.bundlerType || bundlerType,
|
|
95
|
-
overrideOptions: bundlerOptions,
|
|
96
|
-
inputPath: packagePath,
|
|
97
|
-
outputPath,
|
|
98
|
-
incremental: !isExternal,
|
|
99
|
-
sourcemap: disableSourceMaps ? undefined : 'linked',
|
|
100
|
-
entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),
|
|
101
|
-
external: await getExternalsFromPackage({ inputPath: packagePath }, context),
|
|
102
|
-
};
|
|
103
87
|
const hash = !isExternal && shouldCacheInternalPackages
|
|
104
88
|
? await packageHashes.get({ packagePath, isSourceHashingEnabled: true, shouldRecalculate: true })
|
|
105
89
|
: undefined;
|
|
@@ -120,6 +104,22 @@ async function bundle(bundleRequest, force) {
|
|
|
120
104
|
};
|
|
121
105
|
}
|
|
122
106
|
else {
|
|
107
|
+
const { userPackageSettings } = getPackageSettings({
|
|
108
|
+
name: bundleRequest.packageName,
|
|
109
|
+
version: bundleRequest.version,
|
|
110
|
+
config,
|
|
111
|
+
}) || {};
|
|
112
|
+
const { bundlerType, bundlerOptions } = userPackageSettings || {};
|
|
113
|
+
const bundleOptions = {
|
|
114
|
+
bundlerType: bundleRequest.bundlerType || bundlerType,
|
|
115
|
+
overrideOptions: bundlerOptions,
|
|
116
|
+
inputPath: packagePath,
|
|
117
|
+
outputPath,
|
|
118
|
+
incremental: !isExternal,
|
|
119
|
+
sourcemap: disableSourceMaps ? undefined : 'linked',
|
|
120
|
+
entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),
|
|
121
|
+
external: await getExternalsFromPackage({ inputPath: packagePath }, context),
|
|
122
|
+
};
|
|
123
123
|
const bundleInternalResult = await bundleInternal(bundleOptions, { config });
|
|
124
124
|
bundleRequest.result = {
|
|
125
125
|
...bundleInternalResult,
|
|
@@ -129,10 +129,7 @@ async function bundle(bundleRequest, force) {
|
|
|
129
129
|
}
|
|
130
130
|
// Write the result to disk.
|
|
131
131
|
if (isExternal || shouldCacheInternalPackages) {
|
|
132
|
-
|
|
133
|
-
// Clear the rawInput/output properties.
|
|
134
|
-
result.rawInput = result.rawOutput = undefined;
|
|
135
|
-
await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);
|
|
132
|
+
await saveResultToCache(bundleRequest.result);
|
|
136
133
|
}
|
|
137
134
|
}
|
|
138
135
|
if (shouldFindImports && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,iBAAiB,GAGlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,mCAAmC,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAKhC;IACC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,EAAE,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age, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport { readJson, writeJson } from '@ms-cloudpack/json-utilities';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport {\n bulletedList,\n formatPackageName,\n type TaskReporter,\n type TaskReporterTaskResult,\n} from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { findImports } from './findImports.js';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleTaskOptions } from '../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { formatBundleErrors } from './formatBundleErrors.js';\nimport { getFileSizeSync } from './getFileSizeSync.js';\nimport type { BundleOptions } from '@ms-cloudpack/bundler-types';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport { isCachedResultValid } from './isCachedResultValid.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport { diskCacheRatioMetricEventAggregator } from './diskCacheRatioMetricEventAggregator.js';\nimport { getBundleLocation } from './getBundleLocation.js';\n\nexport async function bundleTask(params: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n reporter?: TaskReporter;\n telemetryClient?: TelemetryClient;\n}): Promise<BundleRequest> {\n const { bundleRequest, options = {}, reporter, telemetryClient } = params;\n const { packageName, version } = bundleRequest;\n const { force } = options || {};\n\n const taskName = `Bundle ${formatPackageName({\n name: packageName,\n version,\n })}`;\n\n telemetryClient?.performance.registerAggregator(diskCacheRatioMetricEventAggregator);\n\n const executeBundle = async (): Promise<TaskReporterTaskResult> => {\n await bundle(bundleRequest, force);\n\n diskCacheRatioMetricEventAggregator?.record({\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n });\n\n const { result } = bundleRequest;\n\n if (!result) {\n return {\n status: 'fail',\n details: `No result was found for \"${packageName}@${version}\"`,\n };\n }\n\n result.outputFiles ??= [];\n result.errors ??= [];\n result.warnings ??= [];\n\n if (!result.outputFiles.length && !result.errors?.length) {\n result.warnings.push({\n text: `No output files were found for \"${packageName}\" in \"${result.outputPath}\"`,\n });\n }\n\n return {\n status: result.errors.length ? 'fail' : 'complete',\n ...(result.errors?.length\n ? formatBundleErrors(result.errors)\n : {\n details: bulletedList([\n `Package: ${bundleRequest.packageName}@${bundleRequest.version}`,\n `Bundler: ${result.bundlerName || 'unknown'}`,\n `Input path: ${bundleRequest.packagePath}`,\n `Entries:`,\n Object.values(result.entries || {}),\n `Output path: ${result.outputPath}`,\n result.outputFiles?.map(\n (file) =>\n `${safeRelativePath(path.relative(result.outputPath, file.outputPath))} (${getFileSizeSync(\n path.resolve(result.outputPath, file.outputPath),\n )})`,\n ),\n ]),\n }),\n };\n };\n\n if (reporter) {\n await reporter.runTask(taskName, executeBundle);\n } else {\n await executeBundle();\n }\n\n return bundleRequest;\n}\n\nasync function bundle(bundleRequest: BundleRequest, force?: boolean): Promise<BundleRequest> {\n const { packages, config, packageHashes } = bundleRequest;\n const context = { packages, config, packageHashes };\n\n // If force is set, dispose the existing result.\n if (force && bundleRequest?.result?.dispose) {\n bundleRequest.result.dispose();\n bundleRequest.result = undefined;\n }\n\n const { packagePath, isExternal, disableSourceMaps, shouldFindImports, shouldCacheInternalPackages } = bundleRequest;\n\n const outputPath = bundleRequest.outputPath ?? (await getBundleLocation({ packagePath }, context)).path;\n\n // Rehydrate the result if not incremental.\n if (bundleRequest.result === undefined && (isExternal || shouldCacheInternalPackages) && !force) {\n bundleRequest.result = await readJson(path.join(outputPath, 'result.json'));\n\n // results.json's outputPath is absolute and can be generated from CI machine, so we need to replace it with a local one. This is a temporary fix until we can fix the root cause.\n if (bundleRequest.result) {\n bundleRequest.result.outputPath = outputPath;\n }\n }\n\n const { userPackageSettings } =\n getPackageSettings({\n name: bundleRequest.packageName,\n version: bundleRequest.version,\n config,\n }) || {};\n const { bundlerType, bundlerOptions } = userPackageSettings || {};\n\n const bundleOptions: BundleOptions = {\n bundlerType: bundleRequest.bundlerType || bundlerType,\n overrideOptions: bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: !isExternal,\n sourcemap: disableSourceMaps ? undefined : 'linked',\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),\n external: await getExternalsFromPackage({ inputPath: packagePath }, context),\n };\n\n const hash =\n !isExternal && shouldCacheInternalPackages\n ? await packageHashes.get({ packagePath, isSourceHashingEnabled: true, shouldRecalculate: true })\n : undefined;\n\n // if the cached result is valid, use it.\n if (!force && isCachedResultValid({ bundleRequest, hash })) {\n console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);\n bundleRequest.resultFromCache = true;\n } else {\n bundleRequest.resultFromCache = false;\n\n // Only use cached result if it's successful.\n await prepareOutputPath(outputPath);\n\n if (bundleRequest.result?.rebuild) {\n bundleRequest.result = {\n ...(await bundleRequest.result.rebuild()),\n outputPath: bundleRequest.result.outputPath,\n hash,\n };\n } else {\n const bundleInternalResult = await bundleInternal(bundleOptions, { config });\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash,\n };\n }\n\n // Write the result to disk.\n if (isExternal || shouldCacheInternalPackages) {\n const result = { ...bundleRequest.result };\n\n // Clear the rawInput/output properties.\n result.rawInput = result.rawOutput = undefined;\n\n await writeJson(path.join(outputPath, 'result.json'), bundleRequest.result);\n }\n }\n\n if (shouldFindImports && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {\n const importsPath = path.join(outputPath, 'imports.json');\n let imports = await readJson<Record<string, string[]>>(importsPath);\n\n // If we couldn't rehydrate imports from cache, compute them.\n if (!imports) {\n const scriptPaths = bundleRequest.result.outputFiles.map((f) => path.resolve(outputPath, f.outputPath));\n\n imports = await findImports(scriptPaths);\n\n // Write to cache for future use. (Ignore the promise result.)\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n writeJson(importsPath, imports);\n }\n\n bundleRequest.result.imports = imports;\n\n // Find imports that are in the output files and set dependencies.\n const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => path.resolve(outputPath, f.outputPath));\n bundleRequest.result.imports = outputFilePaths && (await findImports(outputFilePaths));\n }\n\n return bundleRequest;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bundleTask.js","sourceRoot":"","sources":["../../src/utilities/bundleTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,iBAAiB,GAGlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,mCAAmC,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAKhC;IACC,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IAC1E,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC;IAC/C,MA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,MAAM,QAAQ,CAA2B,WAAW,CAAC,CAAC;QAEpE,6DAA6D;QAC7D,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;YAExG,OAAO,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;YAEzC,8DAA8D;YAC9D,mEAAmE;YACnE,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;SACjC;QAED,aAAa,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvC,kEAAkE;QAClE,MAAM,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QAC7G,aAAa,CAAC,MAAM,CAAC,OAAO,GAAG,eAAe,IAAI,CAAC,MAAM,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC;KACxF;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { bundle as bundleInternal, getEntriesMapFromPackage, getExternalsFromPackage } from '@ms-cloudpack/bundler';\nimport { readJson, writeJson } from '@ms-cloudpack/json-utilities';\nimport { safeRelativePath } from '@ms-cloudpack/path-string-parsing';\nimport {\n bulletedList,\n formatPackageName,\n type TaskReporter,\n type TaskReporterTaskResult,\n} from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { findImports } from './findImports.js';\nimport { prepareOutputPath } from '../common/prepareOutputPath.js';\nimport type { BundleTaskOptions } from '../types/BundleTaskOptions.js';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport { formatBundleErrors } from './formatBundleErrors.js';\nimport { getFileSizeSync } from './getFileSizeSync.js';\nimport type { BundleOptions } from '@ms-cloudpack/bundler-types';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport { isCachedResultValid } from './isCachedResultValid.js';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport { diskCacheRatioMetricEventAggregator } from './diskCacheRatioMetricEventAggregator.js';\nimport { getBundleLocation } from './getBundleLocation.js';\nimport { readResultFromCache } from './readResultFromCache.js';\nimport { saveResultToCache } from './saveResultToCache.js';\n\nexport async function bundleTask(params: {\n bundleRequest: BundleRequest;\n options?: BundleTaskOptions;\n reporter?: TaskReporter;\n telemetryClient?: TelemetryClient;\n}): Promise<BundleRequest> {\n const { bundleRequest, options = {}, reporter, telemetryClient } = params;\n const { packageName, version } = bundleRequest;\n const { force } = options || {};\n\n const taskName = `Bundle ${formatPackageName({\n name: packageName,\n version,\n })}`;\n\n telemetryClient?.performance.registerAggregator(diskCacheRatioMetricEventAggregator);\n\n const executeBundle = async (): Promise<TaskReporterTaskResult> => {\n await bundle(bundleRequest, force);\n\n diskCacheRatioMetricEventAggregator?.record({\n isCacheHit: !!bundleRequest.resultFromCache,\n isExternal: bundleRequest.isExternal,\n });\n\n const { result } = bundleRequest;\n\n if (!result) {\n return {\n status: 'fail',\n details: `No result was found for \"${packageName}@${version}\"`,\n };\n }\n\n result.outputFiles ??= [];\n result.errors ??= [];\n result.warnings ??= [];\n\n if (!result.outputFiles.length && !result.errors?.length) {\n result.warnings.push({\n text: `No output files were found for \"${packageName}\" in \"${result.outputPath}\"`,\n });\n }\n\n return {\n status: result.errors.length ? 'fail' : 'complete',\n ...(result.errors?.length\n ? formatBundleErrors(result.errors)\n : {\n details: bulletedList([\n `Package: ${bundleRequest.packageName}@${bundleRequest.version}`,\n `Bundler: ${result.bundlerName || 'unknown'}`,\n `Input path: ${bundleRequest.packagePath}`,\n `Entries:`,\n Object.values(result.entries || {}),\n `Output path: ${result.outputPath}`,\n result.outputFiles?.map(\n (file) =>\n `${safeRelativePath(path.relative(result.outputPath, file.outputPath))} (${getFileSizeSync(\n path.resolve(result.outputPath, file.outputPath),\n )})`,\n ),\n ]),\n }),\n };\n };\n\n if (reporter) {\n await reporter.runTask(taskName, executeBundle);\n } else {\n await executeBundle();\n }\n\n return bundleRequest;\n}\n\nasync function bundle(bundleRequest: BundleRequest, force?: boolean): Promise<BundleRequest> {\n const { packages, config, packageHashes } = bundleRequest;\n const context = { packages, config, packageHashes };\n\n // If force is set, dispose the existing result.\n if (force && bundleRequest?.result?.dispose) {\n bundleRequest.result.dispose();\n bundleRequest.result = undefined;\n }\n\n const { packagePath, isExternal, disableSourceMaps, shouldFindImports, shouldCacheInternalPackages } = bundleRequest;\n\n const outputPath = bundleRequest.outputPath ?? (await getBundleLocation({ packagePath }, context)).path;\n\n // Rehydrate the result if not incremental.\n if (bundleRequest.result === undefined && (isExternal || shouldCacheInternalPackages) && !force) {\n bundleRequest.result = await readResultFromCache(outputPath, {\n inputPath: packagePath,\n });\n }\n\n const hash =\n !isExternal && shouldCacheInternalPackages\n ? await packageHashes.get({ packagePath, isSourceHashingEnabled: true, shouldRecalculate: true })\n : undefined;\n\n // if the cached result is valid, use it.\n if (!force && isCachedResultValid({ bundleRequest, hash })) {\n console.debug(`Using cached result for ${bundleRequest.packageName}@${bundleRequest.version}`);\n bundleRequest.resultFromCache = true;\n } else {\n bundleRequest.resultFromCache = false;\n\n // Only use cached result if it's successful.\n await prepareOutputPath(outputPath);\n\n if (bundleRequest.result?.rebuild) {\n bundleRequest.result = {\n ...(await bundleRequest.result.rebuild()),\n outputPath: bundleRequest.result.outputPath,\n hash,\n };\n } else {\n const { userPackageSettings } =\n getPackageSettings({\n name: bundleRequest.packageName,\n version: bundleRequest.version,\n config,\n }) || {};\n const { bundlerType, bundlerOptions } = userPackageSettings || {};\n\n const bundleOptions: BundleOptions = {\n bundlerType: bundleRequest.bundlerType || bundlerType,\n overrideOptions: bundlerOptions,\n inputPath: packagePath,\n outputPath,\n incremental: !isExternal,\n sourcemap: disableSourceMaps ? undefined : 'linked',\n entries: await getEntriesMapFromPackage({ inputPath: packagePath }, context),\n external: await getExternalsFromPackage({ inputPath: packagePath }, context),\n };\n\n const bundleInternalResult = await bundleInternal(bundleOptions, { config });\n bundleRequest.result = {\n ...bundleInternalResult,\n outputPath: bundleOptions.outputPath ?? outputPath,\n hash,\n };\n }\n\n // Write the result to disk.\n if (isExternal || shouldCacheInternalPackages) {\n await saveResultToCache(bundleRequest.result);\n }\n }\n\n if (shouldFindImports && !bundleRequest.result?.errors?.length && bundleRequest.result?.outputFiles?.length) {\n const importsPath = path.join(outputPath, 'imports.json');\n let imports = await readJson<Record<string, string[]>>(importsPath);\n\n // If we couldn't rehydrate imports from cache, compute them.\n if (!imports) {\n const scriptPaths = bundleRequest.result.outputFiles.map((f) => path.resolve(outputPath, f.outputPath));\n\n imports = await findImports(scriptPaths);\n\n // Write to cache for future use. (Ignore the promise result.)\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n writeJson(importsPath, imports);\n }\n\n bundleRequest.result.imports = imports;\n\n // Find imports that are in the output files and set dependencies.\n const outputFilePaths = bundleRequest.result.outputFiles?.map((f) => path.resolve(outputPath, f.outputPath));\n bundleRequest.result.imports = outputFilePaths && (await findImports(outputFilePaths));\n }\n\n return bundleRequest;\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LoginMethod } from '@ms-cloudpack/remote-cache';
|
|
2
2
|
import type { ApiParams } from '../types/ApiParams.js';
|
|
3
3
|
export declare function createRemoteCacheClient(params: ApiParams<{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}, 'session' | 'reporter'>): Promise<import("@ms-cloudpack/remote-cache").RemoteCacheClient>;
|
|
4
|
+
loginMethod: LoginMethod;
|
|
5
|
+
}, 'session' | 'reporter' | 'telemetryClient'>): Promise<import("@ms-cloudpack/remote-cache").RemoteCacheClient>;
|
|
7
6
|
//# sourceMappingURL=createRemoteCacheClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRemoteCacheClient.d.ts","sourceRoot":"","sources":["../../src/utilities/createRemoteCacheClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"createRemoteCacheClient.d.ts","sourceRoot":"","sources":["../../src/utilities/createRemoteCacheClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,SAAS,CACf;IACE,WAAW,EAAE,WAAW,CAAC;CAC1B,EACD,SAAS,GAAG,UAAU,GAAG,iBAAiB,CAC3C,mEAeF"}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { ensureRemoteCacheEnabled } from '../utilities/ensureRemoteCacheEnabled.js';
|
|
2
|
+
import { getCachePath } from './getCachePath.js';
|
|
2
3
|
export async function createRemoteCacheClient(params) {
|
|
3
4
|
const { ctx, input } = params;
|
|
4
|
-
const {
|
|
5
|
-
const { session, reporter } = ctx;
|
|
6
|
-
const { container, storageAccount
|
|
5
|
+
const { loginMethod } = input;
|
|
6
|
+
const { session, reporter, telemetryClient } = ctx;
|
|
7
|
+
const { container, storageAccount } = ensureRemoteCacheEnabled(session.config);
|
|
7
8
|
const remoteCacheModule = await import('@ms-cloudpack/remote-cache');
|
|
8
9
|
const client = await remoteCacheModule.createRemoteCacheClient({
|
|
9
|
-
reporter,
|
|
10
|
-
|
|
11
|
-
container,
|
|
12
|
-
storageAccount,
|
|
13
|
-
permissions,
|
|
14
|
-
isInteractiveLogin,
|
|
15
|
-
tokenExpiresInMs,
|
|
16
|
-
},
|
|
10
|
+
context: { reporter, telemetryClient },
|
|
11
|
+
options: { container, loginMethod, storageAccount, cachePath: getCachePath() },
|
|
17
12
|
});
|
|
18
13
|
return client;
|
|
19
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRemoteCacheClient.js","sourceRoot":"","sources":["../../src/utilities/createRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"createRemoteCacheClient.js","sourceRoot":"","sources":["../../src/utilities/createRemoteCacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AAGpF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAKC;IAED,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAC9B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC;IACnD,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/E,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAErE,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,uBAAuB,CAAC;QAC7D,OAAO,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE;QACtC,OAAO,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE;KAC/E,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { ensureRemoteCacheEnabled } from '../utilities/ensureRemoteCacheEnabled.js';\nimport type { LoginMethod } from '@ms-cloudpack/remote-cache';\nimport type { ApiParams } from '../types/ApiParams.js';\nimport { getCachePath } from './getCachePath.js';\n\nexport async function createRemoteCacheClient(\n params: ApiParams<\n {\n loginMethod: LoginMethod;\n },\n 'session' | 'reporter' | 'telemetryClient'\n >,\n) {\n const { ctx, input } = params;\n const { loginMethod } = input;\n const { session, reporter, telemetryClient } = ctx;\n const { container, storageAccount } = ensureRemoteCacheEnabled(session.config);\n\n const remoteCacheModule = await import('@ms-cloudpack/remote-cache');\n\n const client = await remoteCacheModule.createRemoteCacheClient({\n context: { reporter, telemetryClient },\n options: { container, loginMethod, storageAccount, cachePath: getCachePath() },\n });\n\n return client;\n}\n"]}
|
|
@@ -7,6 +7,5 @@ import type { CloudpackConfig } from '@ms-cloudpack/config-types';
|
|
|
7
7
|
export declare function ensureRemoteCacheEnabled({ remoteCache }: CloudpackConfig): {
|
|
8
8
|
storageAccount: string;
|
|
9
9
|
container: string;
|
|
10
|
-
tokenExpiresInMs?: number | undefined;
|
|
11
10
|
};
|
|
12
11
|
//# sourceMappingURL=ensureRemoteCacheEnabled.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureRemoteCacheEnabled.d.ts","sourceRoot":"","sources":["../../src/utilities/ensureRemoteCacheEnabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,WAAW,EAAE,EAAE,eAAe
|
|
1
|
+
{"version":3,"file":"ensureRemoteCacheEnabled.d.ts","sourceRoot":"","sources":["../../src/utilities/ensureRemoteCacheEnabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,WAAW,EAAE,EAAE,eAAe;;;EAMxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findImports.d.ts","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findImports.d.ts","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;;GAGG;AACH,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CA6E/E"}
|
|
@@ -2,7 +2,6 @@ import { parse } from 'es-module-lexer';
|
|
|
2
2
|
import fsPromises from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { parseImportString } from '@ms-cloudpack/path-string-parsing';
|
|
5
|
-
import { builtinModules } from 'module';
|
|
6
5
|
/**
|
|
7
6
|
* Returns a mapping from dependency name to list of paths that are actually imported in the
|
|
8
7
|
* searched files. e.g. `{ '@fluentui/react': [ '.', './lib/Button' ] }`
|
|
@@ -62,7 +61,7 @@ export async function findImports(filePaths) {
|
|
|
62
61
|
pathsToParse.push(localPath);
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
|
-
else if (packageName && !packageName.startsWith('node:')
|
|
64
|
+
else if (packageName && !packageName.startsWith('node:')) {
|
|
66
65
|
requiredExports[packageName] ??= new Set();
|
|
67
66
|
requiredExports[packageName].add(importPath || '.');
|
|
68
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findImports.js","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAA2B,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"findImports.js","sourceRoot":"","sources":["../../src/utilities/findImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAA2B,MA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{ parse } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { parseImportString, type ImportStringResult } from '@ms-cloudpack/path-string-parsing';\nimport type { DetectedImports } from '../types/DetectedImports.js';\n\n/**\n * Returns a mapping from dependency name to list of paths that are actually imported in the\n * searched files. e.g. `{ '@fluentui/react': [ '.', './lib/Button' ] }`\n */\nexport async function findImports(filePaths: string[]): Promise<DetectedImports> {\n const requiredExports: Record<string, Set<string>> = {};\n const visitedPaths = new Set(filePaths);\n const pathsToParse: string[] = [...filePaths];\n\n while (pathsToParse.length) {\n const filePath = pathsToParse.shift();\n // Ignore any non-JS/TS files such as SVGs and sourcemaps\n if (!filePath || path.extname(filePath) !== '.js') {\n continue;\n }\n\n const source = await fsPromises.readFile(filePath, 'utf-8');\n let rawImports: ReturnType<typeof parse>[0];\n try {\n // es-module-lexer/parse may return Promise in some conditions\n // although it is not declared in the type definition\n // https://github.com/guybedford/es-module-lexer/issues/155\n [rawImports] = await (parse(source) as unknown as Promise<ReturnType<typeof parse>>);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n // (unlikely after adding the check above to only attempt parsing JS/TS files)\n console.warn(`Failed to parse ${filePath}:`, err, '\\nSource is:\\n', source);\n continue;\n }\n const imports = Array.from(new Set(rawImports))\n .map((i) => {\n // The es-module-lexer returns entries where the \"n\" property equals the import source.\n // This includes the package name and path. For example, in this case:\n //\n // import { Button } from '@fluentui/react/lib/Button';\n //\n // The \"n\" property would be \"@fluentui/react/lib/Button\".\n // The \"s\" and \"e\" properties represent the start/end character positions of\n // the import source. The \"ss\" and \"se\" properties represent the start/end\n // character positions of the import specifier starting with \"import\". This\n // may be useful for determining if the import is sync or async.\n //\n // Currently when the import source is a backtick string, the \"n\" property\n // is undefined. This is a bug in es-module-lexer. We may need to handle this\n // at the javascript layer and expand it into multiple potential imports.\n if (!i.n) {\n console.debug(\n `Found an import that didn't parse correctly:\\nFilename:\\n${filePath}\\n\\nImport:\\n${source.slice(\n i.s,\n i.e,\n )}`,\n );\n return undefined;\n }\n\n return parseImportString(i.n);\n })\n .filter(Boolean) as ImportStringResult[];\n\n for (const { packageName, importPath } of imports) {\n if (packageName?.startsWith('.')) {\n const localPath = path.resolve(path.dirname(filePath), packageName, importPath || '');\n\n if (!visitedPaths.has(localPath)) {\n visitedPaths.add(localPath);\n pathsToParse.push(localPath);\n }\n } else if (packageName && !packageName.startsWith('node:')) {\n requiredExports[packageName] ??= new Set();\n requiredExports[packageName].add(importPath || '.');\n }\n }\n }\n\n return Object.entries(requiredExports).reduce(\n (acc, [packageName, importPaths]) => {\n acc[packageName] = Array.from(importPaths);\n return acc;\n },\n {} as Record<string, string[]>,\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BundleRequest } from '../types/BundleRequest.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the 'results.json' file from the cache, and construct a BundleRequest.result object from it.
|
|
4
|
+
* @param outputPath - The path to the cache directory.
|
|
5
|
+
* @param additionalProperties - Additional properties to add to the result object.
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function readResultFromCache(outputPath: string, additionalProperties: {
|
|
9
|
+
inputPath: string;
|
|
10
|
+
}): Promise<BundleRequest['result']>;
|
|
11
|
+
//# sourceMappingURL=readResultFromCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readResultFromCache.d.ts","sourceRoot":"","sources":["../../src/utilities/readResultFromCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,oBAAoB,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAC1C,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAYlC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the 'results.json' file from the cache, and construct a BundleRequest.result object from it.
|
|
5
|
+
* @param outputPath - The path to the cache directory.
|
|
6
|
+
* @param additionalProperties - Additional properties to add to the result object.
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export async function readResultFromCache(outputPath, additionalProperties) {
|
|
10
|
+
const resultFromFile = await readJson(path.join(outputPath, 'result.json'));
|
|
11
|
+
if (!resultFromFile) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
...resultFromFile,
|
|
16
|
+
...additionalProperties,
|
|
17
|
+
outputPath,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=readResultFromCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readResultFromCache.js","sourceRoot":"","sources":["../../src/utilities/readResultFromCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,oBAA2C;IAE3C,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAa,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAExF,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,GAAG,cAAc;QACjB,GAAG,oBAAoB;QACvB,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport type { ResultJson } from '../types/ResultJson.js';\n\n/**\n * Reads the 'results.json' file from the cache, and construct a BundleRequest.result object from it.\n * @param outputPath - The path to the cache directory.\n * @param additionalProperties - Additional properties to add to the result object.\n * @returns\n */\nexport async function readResultFromCache(\n outputPath: string,\n additionalProperties: { inputPath: string },\n): Promise<BundleRequest['result']> {\n const resultFromFile = await readJson<ResultJson>(path.join(outputPath, 'result.json'));\n\n if (!resultFromFile) {\n return undefined;\n }\n\n return {\n ...resultFromFile,\n ...additionalProperties,\n outputPath,\n };\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BundleRequest } from '../types/BundleRequest.js';
|
|
2
|
+
/**
|
|
3
|
+
* Writes the bundleRequestResults to a 'results.json' file.
|
|
4
|
+
* @param bundleRequestResult - The result object to write to the cache.
|
|
5
|
+
*/
|
|
6
|
+
export declare function saveResultToCache(bundleRequestResult: Exclude<BundleRequest['result'], undefined>): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=saveResultToCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saveResultToCache.d.ts","sourceRoot":"","sources":["../../src/utilities/saveResultToCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,mBAAmB,EAAE,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,iBAajG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { writeJson } from '@ms-cloudpack/json-utilities';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Writes the bundleRequestResults to a 'results.json' file.
|
|
5
|
+
* @param bundleRequestResult - The result object to write to the cache.
|
|
6
|
+
*/
|
|
7
|
+
export function saveResultToCache(bundleRequestResult) {
|
|
8
|
+
const { outputPath, bundlerName, entries, hash, outputFiles, warnings, errors } = bundleRequestResult;
|
|
9
|
+
const result = {
|
|
10
|
+
bundlerName,
|
|
11
|
+
entries,
|
|
12
|
+
hash,
|
|
13
|
+
outputFiles,
|
|
14
|
+
warnings,
|
|
15
|
+
errors,
|
|
16
|
+
};
|
|
17
|
+
return writeJson(path.join(outputPath, 'result.json'), result);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=saveResultToCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saveResultToCache.js","sourceRoot":"","sources":["../../src/utilities/saveResultToCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,mBAAgE;IAChG,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAAC;IAEtG,MAAM,MAAM,GAAe;QACzB,WAAW;QACX,OAAO;QACP,IAAI;QACJ,WAAW;QACX,QAAQ;QACR,MAAM;KACP,CAAC;IAEF,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport type { BundleRequest } from '../types/BundleRequest.js';\nimport type { ResultJson } from '../types/ResultJson.js';\n\n/**\n * Writes the bundleRequestResults to a 'results.json' file.\n * @param bundleRequestResult - The result object to write to the cache.\n */\nexport function saveResultToCache(bundleRequestResult: Exclude<BundleRequest['result'], undefined>) {\n const { outputPath, bundlerName, entries, hash, outputFiles, warnings, errors } = bundleRequestResult;\n\n const result: ResultJson = {\n bundlerName,\n entries,\n hash,\n outputFiles,\n warnings,\n errors,\n };\n\n return writeJson(path.join(outputPath, 'result.json'), result);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.10",
|
|
4
4
|
"description": "An implementation of the API server that does interacts with a task scheduler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,21 +28,21 @@
|
|
|
28
28
|
"@lage-run/scheduler": "^1.1.9",
|
|
29
29
|
"@lage-run/target-graph": "^0.8.7",
|
|
30
30
|
"@lage-run/hasher": "^1.0.5",
|
|
31
|
-
"@ms-cloudpack/bundler": "^0.17.
|
|
32
|
-
"@ms-cloudpack/bundler-types": "^0.23.
|
|
33
|
-
"@ms-cloudpack/config": "^0.17.
|
|
34
|
-
"@ms-cloudpack/config-types": "^0.
|
|
35
|
-
"@ms-cloudpack/create-express-app": "^1.3.
|
|
31
|
+
"@ms-cloudpack/bundler": "^0.17.4",
|
|
32
|
+
"@ms-cloudpack/bundler-types": "^0.23.3",
|
|
33
|
+
"@ms-cloudpack/config": "^0.17.5",
|
|
34
|
+
"@ms-cloudpack/config-types": "^0.2.0",
|
|
35
|
+
"@ms-cloudpack/create-express-app": "^1.3.13",
|
|
36
36
|
"@ms-cloudpack/data-bus": "^0.4.2",
|
|
37
37
|
"@ms-cloudpack/file-watcher": "^0.1.2",
|
|
38
38
|
"@ms-cloudpack/json-utilities": "^0.1.2",
|
|
39
|
-
"@ms-cloudpack/package-hashes": "^0.2.
|
|
40
|
-
"@ms-cloudpack/package-utilities": "^5.6.
|
|
41
|
-
"@ms-cloudpack/path-string-parsing": "^1.1.
|
|
42
|
-
"@ms-cloudpack/path-utilities": "^2.3.
|
|
39
|
+
"@ms-cloudpack/package-hashes": "^0.2.6",
|
|
40
|
+
"@ms-cloudpack/package-utilities": "^5.6.3",
|
|
41
|
+
"@ms-cloudpack/path-string-parsing": "^1.1.2",
|
|
42
|
+
"@ms-cloudpack/path-utilities": "^2.3.6",
|
|
43
43
|
"@ms-cloudpack/task-reporter": "^0.10.2",
|
|
44
44
|
"@ms-cloudpack/telemetry": "^0.4.4",
|
|
45
|
-
"@ms-cloudpack/remote-cache": "^0.
|
|
45
|
+
"@ms-cloudpack/remote-cache": "^0.2.0",
|
|
46
46
|
"@trpc/client": "^10.41.0",
|
|
47
47
|
"@trpc/server": "^10.41.0",
|
|
48
48
|
"cors": "^2.8.5",
|