@ms-cloudpack/api-server 0.56.13 → 0.56.14
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/syncUpload.d.ts.map +1 -1
- package/lib/apis/syncUpload.js +18 -0
- package/lib/apis/syncUpload.js.map +1 -1
- package/package.json +14 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncUpload.d.ts","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"syncUpload.d.ts","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAOvD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,CACf,SAAS,EACP,SAAS,GACT,UAAU,GACV,UAAU,GACV,KAAK,GACL,YAAY,GACZ,SAAS,GACT,iBAAiB,GACjB,oBAAoB,GACpB,eAAe,CAClB,GACA,OAAO,CAAC,IAAI,CAAC,CAmEf"}
|
package/lib/apis/syncUpload.js
CHANGED
|
@@ -4,6 +4,11 @@ import { getRemoteCachePromiseResultCounts } from '../utilities/getRemoteCachePr
|
|
|
4
4
|
import { createRemoteCacheClient } from '../utilities/createRemoteCacheClient.js';
|
|
5
5
|
import { createRemoteCacheClientOperationOptions } from '../utilities/createRemoteCacheClientOperationOptions.js';
|
|
6
6
|
import { createUploadTask } from '../utilities/createUploadTask.js';
|
|
7
|
+
import { isStaticRoute } from '@ms-cloudpack/common-types';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { getBundleLocation } from '../utilities/getBundleLocation.js';
|
|
10
|
+
import { cp } from 'fs/promises';
|
|
11
|
+
import objectHash from 'object-hash';
|
|
7
12
|
export async function syncUpload(params) {
|
|
8
13
|
const { ctx, input } = params;
|
|
9
14
|
const { session, telemetryClient, taskRunner } = ctx;
|
|
@@ -37,6 +42,19 @@ export async function syncUpload(params) {
|
|
|
37
42
|
.map((p) => createRemoteCacheClientOperationOptions(
|
|
38
43
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- verified above that it's set
|
|
39
44
|
{ packagePath: p.inputPath, packageName: p.name, packageVersion: p.version }, ctx)));
|
|
45
|
+
if (config.features?.enableCloudHosted) {
|
|
46
|
+
const appOutputPath = (await getBundleLocation({ packagePath: appPath }, ctx)).path;
|
|
47
|
+
const destinationFolder = path.join(appOutputPath, '__cloudpack');
|
|
48
|
+
const routesPath = path.join(destinationFolder, 'routes');
|
|
49
|
+
for (const route of config.routes ?? []) {
|
|
50
|
+
if (isStaticRoute(route)) {
|
|
51
|
+
const staticPath = path.resolve(appPath, route.staticPath);
|
|
52
|
+
const routeHash = objectHash(route);
|
|
53
|
+
const folderPath = path.join(routesPath, routeHash);
|
|
54
|
+
await cp(staticPath, path.join(folderPath, staticPath), { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
40
58
|
const uploads = packagesToUpload.map((pkg) => taskRunner.add(createUploadTask({ client, options: { ...pkg, globMatches } })));
|
|
41
59
|
// Do not reject if there is a failure. Failed uploads will be logged in the task reporter.
|
|
42
60
|
const promiseResults = await Promise.allSettled(uploads);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncUpload.js","sourceRoot":"","sources":["../../src/apis/syncUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AACtG,OAAO,EAAE,uBA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AAI,CAAC;YACpF,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;YAClE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;YAC1D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;gBACxC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;oBAC3D,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;oBACpC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;oBACpD,MAAM,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC/E,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAC3C,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,GAAG,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,CAC/E,CAAC;QAEF,2FAA2F;QAC3F,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAEzD,IAAI,CAAC,aAAa,CAAC,iCAAiC,CAAC,cAAc,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kGAAkG","sourcesContent":["import { ensurePackageBundled } from './ensurePackageBundled.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 { createRemoteCacheClientOperationOptions } from '../utilities/createRemoteCacheClientOperationOptions.js';\nimport { createUploadTask } from '../utilities/createUploadTask.js';\nimport type { SyncInput } from '../types/SyncInput.js';\nimport { isStaticRoute } from '@ms-cloudpack/common-types';\nimport path from 'path';\nimport { getBundleLocation } from '../utilities/getBundleLocation.js';\nimport { cp } from 'fs/promises';\nimport objectHash from 'object-hash';\n\nexport async function syncUpload(\n params: ApiParams<\n SyncInput,\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, taskRunner } = ctx;\n const { config } = session;\n const { appPath } = config;\n const { loginMethod } = input;\n const syncInternalPackages = config?.features?.syncInternalPackages ?? false;\n\n // Glob pattern for the files to upload.\n const globMatches = ['**/*', '!**/*-input.json', '!**/*-output.json'];\n\n await telemetryClient.tracer.startActiveSpan(PerfMeasurementSyncUpload, async (span) => {\n const { name, version } = await ctx.packages.get(appPath);\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 packagesToUpload = await Promise.all(\n bundledPackages\n .filter((p) => p.inputPath && (p.isExternal || syncInternalPackages))\n .map((p) =>\n createRemoteCacheClientOperationOptions(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- verified above that it's set\n { packagePath: p.inputPath!, packageName: p.name, packageVersion: p.version },\n ctx,\n ),\n ),\n );\n\n if (config.features?.enableCloudHosted) {\n const appOutputPath = (await getBundleLocation({ packagePath: appPath }, ctx)).path;\n const destinationFolder = path.join(appOutputPath, '__cloudpack');\n const routesPath = path.join(destinationFolder, 'routes');\n for (const route of config.routes ?? []) {\n if (isStaticRoute(route)) {\n const staticPath = path.resolve(appPath, route.staticPath);\n const routeHash = objectHash(route);\n const folderPath = path.join(routesPath, routeHash);\n await cp(staticPath, path.join(folderPath, staticPath), { recursive: true });\n }\n }\n }\n\n const uploads = packagesToUpload.map((pkg) =>\n taskRunner.add(createUploadTask({ client, options: { ...pkg, globMatches } })),\n );\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 span.setAttributes(getRemoteCachePromiseResultCounts(promiseResults));\n });\n}\n\n// This function doesn't have an attached procedure because it's never called via the TRPC server.\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.56.
|
|
3
|
+
"version": "0.56.14",
|
|
4
4
|
"description": "An implementation of the API server that does interacts with a task scheduler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,28 +27,29 @@
|
|
|
27
27
|
"@lage-run/logger": "^1.3.0",
|
|
28
28
|
"@lage-run/scheduler": "^1.2.1",
|
|
29
29
|
"@lage-run/target-graph": "^0.9.0",
|
|
30
|
-
"@ms-cloudpack/bundler": "^0.23.
|
|
31
|
-
"@ms-cloudpack/common-types": "^0.23.
|
|
32
|
-
"@ms-cloudpack/config": "^0.33.
|
|
33
|
-
"@ms-cloudpack/create-express-app": "^1.10.
|
|
30
|
+
"@ms-cloudpack/bundler": "^0.23.23",
|
|
31
|
+
"@ms-cloudpack/common-types": "^0.23.6",
|
|
32
|
+
"@ms-cloudpack/config": "^0.33.3",
|
|
33
|
+
"@ms-cloudpack/create-express-app": "^1.10.9",
|
|
34
34
|
"@ms-cloudpack/data-bus": "^0.4.2",
|
|
35
|
-
"@ms-cloudpack/esm-stub-utilities": "^0.13.
|
|
35
|
+
"@ms-cloudpack/esm-stub-utilities": "^0.13.20",
|
|
36
36
|
"@ms-cloudpack/file-watcher": "^0.1.2",
|
|
37
|
-
"@ms-cloudpack/import-map": "^0.8.
|
|
37
|
+
"@ms-cloudpack/import-map": "^0.8.18",
|
|
38
38
|
"@ms-cloudpack/json-utilities": "^0.1.8",
|
|
39
|
-
"@ms-cloudpack/package-hashes": "^0.7.
|
|
40
|
-
"@ms-cloudpack/package-utilities": "^10.4.
|
|
39
|
+
"@ms-cloudpack/package-hashes": "^0.7.15",
|
|
40
|
+
"@ms-cloudpack/package-utilities": "^10.4.2",
|
|
41
41
|
"@ms-cloudpack/path-string-parsing": "^1.2.5",
|
|
42
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
43
|
-
"@ms-cloudpack/remote-cache": "^0.9.
|
|
42
|
+
"@ms-cloudpack/path-utilities": "^2.7.56",
|
|
43
|
+
"@ms-cloudpack/remote-cache": "^0.9.14",
|
|
44
44
|
"@ms-cloudpack/task-reporter": "^0.14.6",
|
|
45
|
-
"@ms-cloudpack/telemetry": "^0.10.
|
|
45
|
+
"@ms-cloudpack/telemetry": "^0.10.1",
|
|
46
46
|
"@trpc/client": "11.0.0-rc.648",
|
|
47
47
|
"@trpc/server": "11.0.0-rc.648",
|
|
48
48
|
"cors": "^2.8.5",
|
|
49
49
|
"es-module-lexer": "^1.4.1",
|
|
50
50
|
"filenamify": "^6.0.0",
|
|
51
51
|
"get-port": "^7.0.0",
|
|
52
|
+
"object-hash": "^3.0.0",
|
|
52
53
|
"p-queue": "^8.0.1",
|
|
53
54
|
"source-map": "^0.7.0",
|
|
54
55
|
"uuid": "^10.0.0",
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
61
62
|
"@ms-cloudpack/test-utilities": "^0.5.0",
|
|
62
63
|
"@types/cors": "^2.8.13",
|
|
64
|
+
"@types/object-hash": "^3.0.2",
|
|
63
65
|
"@types/uuid": "^10.0.0",
|
|
64
66
|
"@types/ws": "^8.5.5"
|
|
65
67
|
},
|