@ms-cloudpack/cli 0.43.1 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/bundle/bundle.d.ts.map +1 -1
- package/lib/commands/bundle/bundle.js +14 -9
- package/lib/commands/bundle/bundle.js.map +1 -1
- package/lib/commands/init/bundleAndGetImports.d.ts +2 -0
- package/lib/commands/init/bundleAndGetImports.d.ts.map +1 -1
- package/lib/commands/init/bundleAndGetImports.js +17 -19
- package/lib/commands/init/bundleAndGetImports.js.map +1 -1
- package/lib/commands/init/init.d.ts.map +1 -1
- package/lib/commands/init/init.js +80 -78
- package/lib/commands/init/init.js.map +1 -1
- package/lib/commands/start/start.js +1 -1
- package/lib/commands/start/start.js.map +1 -1
- package/lib/commands/sync/index.d.ts.map +1 -1
- package/lib/commands/sync/index.js +1 -0
- package/lib/commands/sync/index.js.map +1 -1
- package/lib/commands/sync/sync.d.ts +1 -1
- package/lib/commands/sync/sync.d.ts.map +1 -1
- package/lib/commands/sync/sync.js +18 -7
- package/lib/commands/sync/sync.js.map +1 -1
- package/lib/commands/sync/types/SyncOptions.d.ts +1 -0
- package/lib/commands/sync/types/SyncOptions.d.ts.map +1 -1
- package/lib/commands/sync/types/SyncOptions.js.map +1 -1
- package/lib/common/createPartialApiContext.d.ts +4 -0
- package/lib/common/createPartialApiContext.d.ts.map +1 -0
- package/lib/common/createPartialApiContext.js +102 -0
- package/lib/common/createPartialApiContext.js.map +1 -0
- package/lib/common/createSession.d.ts +1 -0
- package/lib/common/createSession.d.ts.map +1 -1
- package/lib/common/createSession.js +4 -4
- package/lib/common/createSession.js.map +1 -1
- package/lib/setupReporting.d.ts.map +1 -1
- package/lib/setupReporting.js +2 -1
- package/lib/setupReporting.js.map +1 -1
- package/lib/utilities/isCIBuild.d.ts +5 -0
- package/lib/utilities/isCIBuild.d.ts.map +1 -0
- package/lib/utilities/isCIBuild.js +7 -0
- package/lib/utilities/isCIBuild.js.map +1 -0
- package/package.json +8 -6
- package/lib/common/createApiServer.d.ts +0 -122
- package/lib/common/createApiServer.d.ts.map +0 -1
- package/lib/common/createApiServer.js +0 -18
- package/lib/common/createApiServer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAO9D,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,iBA0BxE"}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { setupReporting } from '../../setupReporting.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ensurePackageBundled } from '@ms-cloudpack/api-server/apis';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { stopTelemetry } from '../../initTelemetry.js';
|
|
5
|
+
import { createPartialApiContext } from '../../common/createPartialApiContext.js';
|
|
5
6
|
export async function bundle(options, context) {
|
|
6
7
|
const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options;
|
|
7
8
|
const { reporter, appPath: packagePath } = context;
|
|
8
9
|
await setupReporting(context);
|
|
9
|
-
const
|
|
10
|
-
const definition = await packages.get(packagePath);
|
|
11
|
-
const result = await
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const ctx = await createPartialApiContext(context, ['packages', 'watcher', 'session', 'taskRunner', 'bus']);
|
|
11
|
+
const definition = await ctx.packages.get(packagePath);
|
|
12
|
+
const { result } = await ensurePackageBundled({
|
|
13
|
+
input: {
|
|
14
|
+
name: definition?.name ?? '<unknown>',
|
|
15
|
+
version: definition?.version ?? '0.0.0',
|
|
16
|
+
outputPath: path.resolve(packagePath, outdir),
|
|
17
|
+
bundlerType,
|
|
18
|
+
disableSourceMaps,
|
|
19
|
+
},
|
|
20
|
+
ctx,
|
|
17
21
|
});
|
|
22
|
+
await ctx.dispose();
|
|
18
23
|
await stopTelemetry();
|
|
19
24
|
reporter.complete();
|
|
20
25
|
process.exit(result?.errors?.length === 0 ? 0 : 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/commands/bundle/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB,EAAE,OAAoB;IACvE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IACzF,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEnD,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAE9B,MAAM,GAAG,GAAG,MAAM,uBAAuB,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;IAE5G,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEvD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;QAC5C,KAAK,EAAE;YACL,IAAI,EAAE,UAAU,EAAE,IAAI,IAAI,WAAW;YACrC,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,OAAO;YACvC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;YAC7C,WAAW;YACX,iBAAiB;SAClB;QACD,GAAG;KACJ,CAAC,CAAC;IAEH,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;IACpB,MAAM,aAAa,EAAE,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAEpB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,uBAAuB","sourcesContent":["import type { BundleOptions } from './types/BundleOptions.js';\nimport type { TaskContext } from '../../types/TaskContext.js';\nimport { setupReporting } from '../../setupReporting.js';\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server/apis';\nimport path from 'path';\nimport { stopTelemetry } from '../../initTelemetry.js';\nimport { createPartialApiContext } from '../../common/createPartialApiContext.js';\n\nexport async function bundle(options: BundleOptions, context: TaskContext) {\n const { bundler: bundlerType, outdir = 'dist/browser-esm', disableSourceMaps } = options;\n const { reporter, appPath: packagePath } = context;\n\n await setupReporting(context);\n\n const ctx = await createPartialApiContext(context, ['packages', 'watcher', 'session', 'taskRunner', 'bus']);\n\n const definition = await ctx.packages.get(packagePath);\n\n const { result } = await ensurePackageBundled({\n input: {\n name: definition?.name ?? '<unknown>',\n version: definition?.version ?? '0.0.0',\n outputPath: path.resolve(packagePath, outdir),\n bundlerType,\n disableSourceMaps,\n },\n ctx,\n });\n\n await ctx.dispose();\n await stopTelemetry();\n reporter.complete();\n\n process.exit(result?.errors?.length === 0 ? 0 : 1);\n}\n\n// cspell:ignore outdir\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PackageJson, PackageDefinitionsCache, BundleMessage } from '@ms-cloudpack/bundler-types';
|
|
2
2
|
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
3
3
|
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
4
|
+
import { type EnsurePackageBundledContext } from '@ms-cloudpack/api-server/apis';
|
|
4
5
|
/**
|
|
5
6
|
* Bundle the package and return the imports it depends on.
|
|
6
7
|
*/
|
|
@@ -10,6 +11,7 @@ export declare function bundleAndGetImports(options: {
|
|
|
10
11
|
reporter: TaskReporter;
|
|
11
12
|
packagePath: string;
|
|
12
13
|
definition: PackageJson;
|
|
14
|
+
ctx: EnsurePackageBundledContext;
|
|
13
15
|
}): Promise<{
|
|
14
16
|
warnings: BundleMessage[];
|
|
15
17
|
errors: BundleMessage[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundleAndGetImports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACvG,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAwB,KAAK,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEvG;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE;IACjD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;IACxB,GAAG,EAAE,2BAA2B,CAAC;CAClC,GAAG,OAAO,CAAC;IACV,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,8DAA8D;IAC9D,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACnC,CAAC,CA6DD"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';
|
|
3
|
-
import {
|
|
4
|
-
import { prepareOutputPath } from '../../common/prepareOutputPath.js';
|
|
3
|
+
import { getBundleDetails, findImports } from '@ms-cloudpack/api-server';
|
|
5
4
|
import { formatPackageName } from '@ms-cloudpack/task-reporter';
|
|
5
|
+
import { ensurePackageBundled } from '@ms-cloudpack/api-server/apis';
|
|
6
6
|
/**
|
|
7
7
|
* Bundle the package and return the imports it depends on.
|
|
8
8
|
*/
|
|
9
9
|
export async function bundleAndGetImports(options) {
|
|
10
|
-
const { packagePath, definition, packages, reporter,
|
|
10
|
+
const { packagePath, definition, packages, reporter, ctx } = options;
|
|
11
11
|
const { outputLocation, isExternal } = await getBundleDetails({ packagePath }, { packages });
|
|
12
12
|
const outputPath = outputLocation.path;
|
|
13
13
|
if (!isExternal && !definition.exports) {
|
|
14
14
|
console.debug(`${path.join(packagePath, 'package.json')} does not have an "exports" field.`);
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const { name, version } = definition;
|
|
17
|
+
if (!name || !version) {
|
|
18
|
+
throw new Error(`Package at "${packagePath}" does not have a name or version.`);
|
|
19
|
+
}
|
|
18
20
|
// Determine entries.
|
|
19
21
|
const entriesMap = await getEntriesMapFromPackage({ inputPath: packagePath }, { packages });
|
|
20
22
|
if (!Object.keys(entriesMap).length) {
|
|
@@ -28,28 +30,24 @@ export async function bundleAndGetImports(options) {
|
|
|
28
30
|
],
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
packages,
|
|
39
|
-
config,
|
|
40
|
-
};
|
|
41
|
-
await bundleTask({ bundleRequest, reporter, options: { force: true } });
|
|
33
|
+
const { result } = await ensurePackageBundled({
|
|
34
|
+
input: {
|
|
35
|
+
name,
|
|
36
|
+
version,
|
|
37
|
+
},
|
|
38
|
+
ctx,
|
|
39
|
+
});
|
|
42
40
|
// For each outputFile, find all imports.
|
|
43
41
|
let imports;
|
|
44
42
|
await reporter.runTask(`Evaluate ${formatPackageName(definition)}`, async () => {
|
|
45
|
-
imports = new Map(Object.entries((await findImports(
|
|
43
|
+
imports = new Map(Object.entries((await findImports(result?.outputFiles?.map((file) => path.resolve(outputPath, file.outputPath)) || [])) || {}));
|
|
46
44
|
return {
|
|
47
45
|
status: 'complete',
|
|
48
46
|
};
|
|
49
47
|
});
|
|
50
48
|
return {
|
|
51
|
-
warnings:
|
|
52
|
-
errors:
|
|
49
|
+
warnings: result?.warnings || [],
|
|
50
|
+
errors: result?.errors || [],
|
|
53
51
|
imports: imports || new Map(),
|
|
54
52
|
};
|
|
55
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleAndGetImports.js","sourceRoot":"","sources":["../../../src/commands/init/bundleAndGetImports.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bundleAndGetImports.js","sourceRoot":"","sources":["../../../src/commands/init/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,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,oDAAoD,IAAI,CAAC,IAAI,CACjE,WAAW,EACX,cAAc,CACf,oFAAoF;iBACtF;aACF;SACF,CAAC;KACH;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;QAC5C,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;SACR;QACD,GAAG;KACJ,CAAC,CAAC;IAEH,yCAAyC;IACzC,IAAI,OAA6C,CAAC;IAElD,MAAM,QAAQ,CAAC,OAAO,CAAC,YAAY,iBAAiB,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;QAC7E,OAAO,GAAG,IAAI,GAAG,CACf,MAAM,CAAC,OAAO,CACZ,CAAC,MAAM,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAC/G,CACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,UAAU;SACnB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE;QAChC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;QAC5B,OAAO,EAAE,OAAO,IAAI,IAAI,GAAG,EAAuB;KACnD,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { getEntriesMapFromPackage } from '@ms-cloudpack/bundler';\nimport { getBundleDetails, findImports } from '@ms-cloudpack/api-server';\nimport type { PackageJson, PackageDefinitionsCache, BundleMessage } from '@ms-cloudpack/bundler-types';\nimport { type TaskReporter, formatPackageName } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport { ensurePackageBundled, type EnsurePackageBundledContext } from '@ms-cloudpack/api-server/apis';\n\n/**\n * Bundle the package and return the imports it depends on.\n */\nexport async function bundleAndGetImports(options: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n reporter: TaskReporter;\n packagePath: string;\n definition: PackageJson;\n ctx: EnsurePackageBundledContext;\n}): Promise<{\n warnings: BundleMessage[];\n errors: BundleMessage[];\n /** Map from package name to set of required relative paths */\n imports: Map<string, Set<string>>;\n}> {\n const { packagePath, definition, packages, reporter, ctx } = options;\n const { outputLocation, isExternal } = await getBundleDetails({ packagePath }, { packages });\n const outputPath = outputLocation.path;\n\n if (!isExternal && !definition.exports) {\n console.debug(`${path.join(packagePath, 'package.json')} does not have an \"exports\" field.`);\n }\n\n const { name, version } = definition;\n\n if (!name || !version) {\n throw new Error(`Package at \"${packagePath}\" does not have a name or version.`);\n }\n\n // Determine entries.\n const entriesMap = await getEntriesMapFromPackage({ inputPath: packagePath }, { packages });\n\n if (!Object.keys(entriesMap).length) {\n return {\n imports: new Map<string, Set<string>>(),\n errors: [],\n warnings: [\n {\n text: `No valid entry points were found when evaluating ${path.join(\n packagePath,\n 'package.json',\n )}. Check that has an exports, main, or module entry and the referenced files exist.`,\n },\n ],\n };\n }\n\n const { result } = await ensurePackageBundled({\n input: {\n name,\n version,\n },\n ctx,\n });\n\n // For each outputFile, find all imports.\n let imports: Map<string, Set<string>> | undefined;\n\n await reporter.runTask(`Evaluate ${formatPackageName(definition)}`, async () => {\n imports = new Map(\n Object.entries(\n (await findImports(result?.outputFiles?.map((file) => path.resolve(outputPath, file.outputPath)) || [])) || {},\n ),\n );\n\n return {\n status: 'complete',\n };\n });\n\n return {\n warnings: result?.warnings || [],\n errors: result?.errors || [],\n imports: imports || new Map<string, Set<string>>(),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAW1D,wFAAwF;AACxF,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBpF;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAW1D,wFAAwF;AACxF,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBpF;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CA+GnG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createPartialApiContext } from '../../common/createPartialApiContext.js';
|
|
2
|
+
import { writeGeneratedConfig } from '@ms-cloudpack/config';
|
|
2
3
|
import { rootSpan, stopTelemetry } from '../../initTelemetry.js';
|
|
3
4
|
import { setupReporting } from '../../setupReporting.js';
|
|
4
|
-
import { resolveDependenciesTask } from '../../tasks/resolveDependenciesTask.js';
|
|
5
5
|
import { bundleAndGetImports } from './bundleAndGetImports.js';
|
|
6
6
|
import { InitSummaryData } from './InitSummaryData.js';
|
|
7
7
|
import { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';
|
|
@@ -30,91 +30,93 @@ export async function init(options, context) {
|
|
|
30
30
|
export async function initInternal(options, context) {
|
|
31
31
|
const { appPath, reporter } = context;
|
|
32
32
|
const summaryData = new InitSummaryData();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
config.generated = {};
|
|
40
|
-
}
|
|
41
|
-
const packages = createPackageDefinitions({ config });
|
|
42
|
-
const generatedConfig = config.generated;
|
|
43
|
-
generatedConfig.packageSettings ??= [];
|
|
44
|
-
// Try to resolve dependencies.
|
|
45
|
-
const resolveMap = await resolveDependenciesTask({ appPath }, { packages, reporter });
|
|
46
|
-
if (!resolveMap) {
|
|
47
|
-
throw new Error("Couldn't resolve dependencies.");
|
|
48
|
-
}
|
|
49
|
-
const packagePathsToEvaluate = new Set([appPath]);
|
|
50
|
-
const evaluatedPackages = new Set();
|
|
51
|
-
let totalChangeCount = 0;
|
|
52
|
-
while (packagePathsToEvaluate.size) {
|
|
53
|
-
const packagePath = packagePathsToEvaluate.values().next().value;
|
|
54
|
-
packagePathsToEvaluate.delete(packagePath);
|
|
55
|
-
// Skip already-visited packages.
|
|
56
|
-
if (!packagePath || evaluatedPackages.has(packagePath)) {
|
|
57
|
-
continue;
|
|
33
|
+
const ctx = await createPartialApiContext(context, ['bus', 'taskRunner', 'watcher', 'packages', 'session']);
|
|
34
|
+
const { packages, session } = ctx;
|
|
35
|
+
const { resolveMap, config } = session;
|
|
36
|
+
try {
|
|
37
|
+
if (options.check && options.reset) {
|
|
38
|
+
throw Error('Cannot use --check and --reset together.');
|
|
58
39
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// This is very weird and probably won't happen.
|
|
63
|
-
console.error(`Skipping ${packagePath} evaluation because the package.json was not found or not readable.`);
|
|
64
|
-
continue;
|
|
40
|
+
// If --reset is specified we ignore generated config.
|
|
41
|
+
if (options.reset) {
|
|
42
|
+
config.generated = {};
|
|
65
43
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// Given the package imports, find the missing exports maps and update packageOverrides.
|
|
88
|
-
const { changes, errors: evalErrors } = await evaluateImportsForOverrides({
|
|
89
|
-
definition,
|
|
44
|
+
const generatedConfig = config.generated;
|
|
45
|
+
generatedConfig.packageSettings ??= [];
|
|
46
|
+
const packagePathsToEvaluate = new Set([appPath]);
|
|
47
|
+
const evaluatedPackages = new Set();
|
|
48
|
+
let totalChangeCount = 0;
|
|
49
|
+
while (packagePathsToEvaluate.size) {
|
|
50
|
+
const packagePath = packagePathsToEvaluate.values().next().value;
|
|
51
|
+
packagePathsToEvaluate.delete(packagePath);
|
|
52
|
+
// Skip already-visited packages.
|
|
53
|
+
if (!packagePath || evaluatedPackages.has(packagePath)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
evaluatedPackages.add(packagePath);
|
|
57
|
+
const definition = await packages.get(packagePath, { refresh: true });
|
|
58
|
+
if (!definition) {
|
|
59
|
+
// This is very weird and probably won't happen.
|
|
60
|
+
console.error(`Skipping ${packagePath} evaluation because the package.json was not found or not readable.`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// Bundle the package and find the imports it depends on.
|
|
64
|
+
const { errors, warnings, imports } = await bundleAndGetImports({
|
|
90
65
|
packagePath,
|
|
66
|
+
definition,
|
|
91
67
|
packages,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
generatedConfig,
|
|
96
|
-
resolveMap,
|
|
68
|
+
reporter,
|
|
69
|
+
config,
|
|
70
|
+
ctx,
|
|
97
71
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
72
|
+
// Record the results for the summary.
|
|
73
|
+
const resultIdentifier = {
|
|
74
|
+
name: definition.name || '',
|
|
75
|
+
version: definition.version || '',
|
|
76
|
+
path: packagePath,
|
|
77
|
+
};
|
|
78
|
+
summaryData.recordResult({
|
|
79
|
+
...resultIdentifier,
|
|
80
|
+
errors,
|
|
81
|
+
warnings,
|
|
82
|
+
});
|
|
83
|
+
// If no errors came from the bundle attempt, move on to evaluating the imports.
|
|
84
|
+
if (errors.length === 0) {
|
|
85
|
+
// Given the package imports, find the missing exports maps and update packageOverrides.
|
|
86
|
+
const { changes, errors: evalErrors } = await evaluateImportsForOverrides({
|
|
87
|
+
definition,
|
|
88
|
+
packagePath,
|
|
89
|
+
packages,
|
|
90
|
+
packagePathsToEvaluate,
|
|
91
|
+
evaluatedPackages,
|
|
92
|
+
imports,
|
|
93
|
+
generatedConfig,
|
|
94
|
+
resolveMap,
|
|
110
95
|
});
|
|
111
|
-
|
|
96
|
+
if (evalErrors.length) {
|
|
97
|
+
summaryData.recordResult({
|
|
98
|
+
...resultIdentifier,
|
|
99
|
+
errors: evalErrors.map((text) => ({ text })),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
summaryData.recordGeneratedChanges(changes);
|
|
104
|
+
}
|
|
105
|
+
if (options.check && (changes.length || evalErrors.length)) {
|
|
106
|
+
rootSpan?.addEvent('INIT_CHECK_FAILED', {
|
|
107
|
+
reason: changes.length ? 'Config needs to be updated.' : evalErrors,
|
|
108
|
+
});
|
|
109
|
+
return summaryData.summarize();
|
|
110
|
+
}
|
|
111
|
+
totalChangeCount += changes.length;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
}
|
|
114
|
+
if (totalChangeCount && generatedConfig.packageSettings?.length) {
|
|
115
|
+
await writeGeneratedConfig(generatedConfig, appPath);
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
|
-
|
|
117
|
-
await
|
|
118
|
+
finally {
|
|
119
|
+
await ctx.dispose?.();
|
|
118
120
|
}
|
|
119
121
|
return summaryData.summarize();
|
|
120
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAoB,EAAE,OAAoB;IACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAE9B,IAAI;QACF,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAErD,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC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AAC;oBACxE,UAAU;oBACV,WAAW;oBACX,QAAQ;oBACR,sBAAsB;oBACtB,iBAAiB;oBACjB,OAAO;oBACP,eAAe;oBACf,UAAU;iBACX,CAAC,CAAC;gBAEH,IAAI,UAAU,CAAC,MAAM,EAAE;oBACrB,WAAW,CAAC,YAAY,CAAC;wBACvB,GAAG,gBAAgB;wBACnB,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;qBAC7C,CAAC,CAAC;iBACJ;qBAAM;oBACL,WAAW,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;iBAC7C;gBAED,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;oBAC1D,QAAQ,EAAE,QAAQ,CAAC,mBAAmB,EAAE;wBACtC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,UAAU;qBACpE,CAAC,CAAC;oBAEH,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;iBAChC;gBAED,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;aACpC;SACF;QAED,IAAI,gBAAgB,IAAI,eAAe,CAAC,eAAe,EAAE,MAAM,EAAE;YAC/D,MAAM,oBAAoB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;SACtD;KACF;YAAS;QACR,MAAM,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;KACvB;IAED,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import type { TaskContext } from '../../types/TaskContext.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '../../common/createPartialApiContext.js';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport { rootSpan, stopTelemetry } from '../../initTelemetry.js';\nimport { setupReporting } from '../../setupReporting.js';\nimport { bundleAndGetImports } from './bundleAndGetImports.js';\nimport { InitSummaryData } from './InitSummaryData.js';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { formatInitSummary } from './formatInitSummary.js';\n\n/** Given the path, updates the Cloudpack config with overrides and project settings. */\nexport async function init(options: InitOptions, context: TaskContext): Promise<void> {\n const { reporter } = context;\n let hasErrors = false;\n\n await setupReporting(context);\n\n try {\n const summary = await initInternal(options, context);\n\n reporter.complete(formatInitSummary(summary, options));\n hasErrors = summary.totalErrors > 0;\n } catch (error) {\n reporter.complete(`Unexpected error: ${(error as Error).stack || error}`);\n hasErrors = true;\n }\n\n await stopTelemetry();\n\n process.exit(hasErrors ? 1 : 0);\n}\n\n/**\n * Actual init operation (minus the completion logging).\n * Exported for testing only.\n */\nexport async function initInternal(options: InitOptions, context: TaskContext): Promise<InitSummary> {\n const { appPath, reporter } = context;\n const summaryData = new InitSummaryData();\n const ctx = await createPartialApiContext(context, ['bus', 'taskRunner', 'watcher', 'packages', 'session']);\n const { packages, session } = ctx;\n const { resolveMap, config } = session;\n\n try {\n if (options.check && options.reset) {\n throw Error('Cannot use --check and --reset together.');\n }\n\n // If --reset is specified we ignore generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const generatedConfig = config.generated;\n\n generatedConfig.packageSettings ??= [];\n\n const packagePathsToEvaluate = new Set<string>([appPath]);\n const evaluatedPackages = new Set<string>();\n let totalChangeCount = 0;\n\n while (packagePathsToEvaluate.size) {\n const packagePath = packagePathsToEvaluate.values().next().value as string;\n\n packagePathsToEvaluate.delete(packagePath);\n\n // Skip already-visited packages.\n if (!packagePath || evaluatedPackages.has(packagePath)) {\n continue;\n }\n\n evaluatedPackages.add(packagePath);\n\n const definition = await packages.get(packagePath, { refresh: true });\n\n if (!definition) {\n // This is very weird and probably won't happen.\n console.error(`Skipping ${packagePath} evaluation because the package.json was not found or not readable.`);\n continue;\n }\n\n // Bundle the package and find the imports it depends on.\n const { errors, warnings, imports } = await bundleAndGetImports({\n packagePath,\n definition,\n packages,\n reporter,\n config,\n ctx,\n });\n\n // Record the results for the summary.\n const resultIdentifier = {\n name: definition.name || '',\n version: definition.version || '',\n path: packagePath,\n };\n\n summaryData.recordResult({\n ...resultIdentifier,\n errors,\n warnings,\n });\n\n // If no errors came from the bundle attempt, move on to evaluating the imports.\n if (errors.length === 0) {\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const { changes, errors: evalErrors } = await evaluateImportsForOverrides({\n definition,\n packagePath,\n packages,\n packagePathsToEvaluate,\n evaluatedPackages,\n imports,\n generatedConfig,\n resolveMap,\n });\n\n if (evalErrors.length) {\n summaryData.recordResult({\n ...resultIdentifier,\n errors: evalErrors.map((text) => ({ text })),\n });\n } else {\n summaryData.recordGeneratedChanges(changes);\n }\n\n if (options.check && (changes.length || evalErrors.length)) {\n rootSpan?.addEvent('INIT_CHECK_FAILED', {\n reason: changes.length ? 'Config needs to be updated.' : evalErrors,\n });\n\n return summaryData.summarize();\n }\n\n totalChangeCount += changes.length;\n }\n }\n\n if (totalChangeCount && generatedConfig.packageSettings?.length) {\n await writeGeneratedConfig(generatedConfig, appPath);\n }\n } finally {\n await ctx.dispose?.();\n }\n\n return summaryData.summarize();\n}\n"]}
|
|
@@ -67,7 +67,7 @@ export async function start(options, context) {
|
|
|
67
67
|
throw new Error(`The package.json at "${appPath}" did not have a name and/or version.`);
|
|
68
68
|
}
|
|
69
69
|
// Initialize session definition.
|
|
70
|
-
const session = await createSession({ appPath, config }, { reporter, packages });
|
|
70
|
+
const session = await createSession({ appPath, config, includeOverlay: true }, { reporter, packages });
|
|
71
71
|
// Set shared telemetry attributes which will be sent with all telemetry events.
|
|
72
72
|
telemetryClient.setSharedSpanAttribute('sessionId', session.id);
|
|
73
73
|
if (options.logResolveMap) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"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CAAC,CAAC;QAE/B,gDAAgD;QAChD,IAAI,WAAW,GAAG,CAAC,CAAC;QAEpB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACxB,WAAW,EAAE,CAAC;YACd,IAAI,WAAW,GAAG,CAAC,EAAE;gBACnB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;YAED,6FAA6F;YAC7F,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;gBACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,oBAAoB;QACpB,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;QAE1B,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;QACpE,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7B,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;KACJ;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AAED,wBAAwB","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport { findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport { createSession } from '../../common/createSession.js';\nimport { openBrowser } from './openBrowser.js';\nimport type { Session } from '@ms-cloudpack/api-server';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { createPackageDefinitions, readConfig } from '@ms-cloudpack/config';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { stopTelemetry, rootSpan } from '../../initTelemetry.js';\nimport { createBundleRequestForPackage, createBundleTask } from '@ms-cloudpack/api-server';\nimport { mergeFeatures } from './mergeFeatures.js';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { TaskContext } from '../../types/TaskContext.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { runPrereqs } from './runPrereqs.js';\nimport { setupReporting } from '../../setupReporting.js';\n\nlet cleanupFunctions: Array<() => Promise<void>> = [];\n\n/** Stop all started cloudpack instances, for testing */\nexport async function stopServers() {\n for (const func of cleanupFunctions) {\n await func();\n }\n cleanupFunctions = [];\n}\n\nasync function createAppBundleTask(\n options: { packageName: string },\n context: { session: Session; config: CloudpackConfig; packages: PackageDefinitionsCache },\n) {\n const { packageName } = options;\n const { session } = context;\n const packageEntry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n });\n\n if (!packageEntry) {\n throw new Error(`Could not find package ${packageName} in the resolve map.`);\n }\n const bundleRequest = await createBundleRequestForPackage({ packageEntry }, context);\n\n return createBundleTask(bundleRequest);\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport async function start(options: StartOptions, context: TaskContext) {\n const { reporter, appPath: initialCwd } = context;\n const appPath = await getStartingAppPath(initialCwd, options.app);\n const config = await readConfig(appPath);\n\n const telemetryClient = await setupReporting({ appPath, config, reporter });\n\n console.log('App path:', yellow(appPath));\n\n process.chdir(appPath);\n\n runPrereqs(config, appPath);\n\n try {\n // Merge in any additional features from the command line.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: options.features,\n });\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n // Initialize package overrides.\n const packages = createPackageDefinitions({ config });\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Initialize session definition.\n const session = await createSession({ appPath, config }, { reporter, packages });\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n const { startApiServer } = await import('@ms-cloudpack/api-server');\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer({\n session,\n rootSpan,\n reporter,\n packages,\n });\n\n // Kick off bundling app package as soon as api server is ready.\n void apiServer.addTask(await createAppBundleTask({ packageName: definition.name }, { session, config, packages }));\n\n // Then start bundle and app servers for hosting the app.\n const { startBundleServer } = await import('./startBundleServer.js');\n const bundleServer = await startBundleServer({ apiServer, session, reporter, packages });\n\n // Finally start the app server.\n const { startAppServer } = await import('./appServer/startAppServer.js');\n const appServer = await startAppServer({\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n reporter,\n packages,\n });\n\n const cleanup = async () => {\n for (const [name, server] of [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ]) {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }\n\n // Complete the reporting and list pending tasks as aborted.\n reporter.complete();\n\n // Flush and close telemetry.\n await stopTelemetry();\n };\n\n cleanupFunctions.push(cleanup);\n\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n process.on('SIGINT', () => {\n sigintCount++;\n if (sigintCount > 1) {\n console.debug('Forcing exit');\n process.exit(1);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises -- handler can't be async\n cleanup().finally(() => {\n process.exit(0);\n });\n });\n\n // Open the browser.\n const url = appServer.url;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n openBrowser(url).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', url);\n });\n } catch (err) {\n console.error(err);\n reporter.complete();\n process.exit(1);\n }\n}\n\n// cspell:ignore Prereqs\n"]}
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/commands/start/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAGrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE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AC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;KACJ;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AAED,wBAAwB","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport { findResolveMapEntry } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport { createSession } from '../../common/createSession.js';\nimport { openBrowser } from './openBrowser.js';\nimport type { Session } from '@ms-cloudpack/api-server';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { createPackageDefinitions, readConfig } from '@ms-cloudpack/config';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport { stopTelemetry, rootSpan } from '../../initTelemetry.js';\nimport { createBundleRequestForPackage, createBundleTask } from '@ms-cloudpack/api-server';\nimport { mergeFeatures } from './mergeFeatures.js';\nimport { yellow } from '@ms-cloudpack/task-reporter';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { TaskContext } from '../../types/TaskContext.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { runPrereqs } from './runPrereqs.js';\nimport { setupReporting } from '../../setupReporting.js';\n\nlet cleanupFunctions: Array<() => Promise<void>> = [];\n\n/** Stop all started cloudpack instances, for testing */\nexport async function stopServers() {\n for (const func of cleanupFunctions) {\n await func();\n }\n cleanupFunctions = [];\n}\n\nasync function createAppBundleTask(\n options: { packageName: string },\n context: { session: Session; config: CloudpackConfig; packages: PackageDefinitionsCache },\n) {\n const { packageName } = options;\n const { session } = context;\n const packageEntry = findResolveMapEntry({\n packageName,\n resolveMap: session.resolveMap,\n });\n\n if (!packageEntry) {\n throw new Error(`Could not find package ${packageName} in the resolve map.`);\n }\n const bundleRequest = await createBundleRequestForPackage({ packageEntry }, context);\n\n return createBundleTask(bundleRequest);\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport async function start(options: StartOptions, context: TaskContext) {\n const { reporter, appPath: initialCwd } = context;\n const appPath = await getStartingAppPath(initialCwd, options.app);\n const config = await readConfig(appPath);\n\n const telemetryClient = await setupReporting({ appPath, config, reporter });\n\n console.log('App path:', yellow(appPath));\n\n process.chdir(appPath);\n\n runPrereqs(config, appPath);\n\n try {\n // Merge in any additional features from the command line.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: options.features,\n });\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n // Initialize package overrides.\n const packages = createPackageDefinitions({ config });\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n if (!definition) {\n throw new Error(`There was no package.json located at \"${appPath}\".`);\n }\n\n if (!definition.name || !definition.version) {\n throw new Error(`The package.json at \"${appPath}\" did not have a name and/or version.`);\n }\n\n // Initialize session definition.\n const session = await createSession({ appPath, config, includeOverlay: true }, { reporter, packages });\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n const { startApiServer } = await import('@ms-cloudpack/api-server');\n\n // Start api server for tracking status and handling remote requests.\n const apiServer = await startApiServer({\n session,\n rootSpan,\n reporter,\n packages,\n });\n\n // Kick off bundling app package as soon as api server is ready.\n void apiServer.addTask(await createAppBundleTask({ packageName: definition.name }, { session, config, packages }));\n\n // Then start bundle and app servers for hosting the app.\n const { startBundleServer } = await import('./startBundleServer.js');\n const bundleServer = await startBundleServer({ apiServer, session, reporter, packages });\n\n // Finally start the app server.\n const { startAppServer } = await import('./appServer/startAppServer.js');\n const appServer = await startAppServer({\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n reporter,\n packages,\n });\n\n const cleanup = async () => {\n for (const [name, server] of [\n ['appServer', appServer] as const,\n ['apiServer', apiServer] as const,\n ['bundleServer', bundleServer] as const,\n ]) {\n console.info(`Closing ${name}: ${server.url}`);\n try {\n await server.close();\n } catch (err) {\n console.warn('Error closing server:', err);\n }\n }\n\n // Complete the reporting and list pending tasks as aborted.\n reporter.complete();\n\n // Flush and close telemetry.\n await stopTelemetry();\n };\n\n cleanupFunctions.push(cleanup);\n\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n process.on('SIGINT', () => {\n sigintCount++;\n if (sigintCount > 1) {\n console.debug('Forcing exit');\n process.exit(1);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises -- handler can't be async\n cleanup().finally(() => {\n process.exit(0);\n });\n });\n\n // Open the browser.\n const url = appServer.url;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n openBrowser(url).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', url);\n });\n } catch (err) {\n console.error(err);\n reporter.complete();\n process.exit(1);\n }\n}\n\n// cspell:ignore Prereqs\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,eAYlB,CAAC"}
|
|
@@ -4,6 +4,7 @@ export const init = (command, context) => {
|
|
|
4
4
|
.command('sync')
|
|
5
5
|
.description('Syncs the packages from/to the remote cache. If the package is not in the local cache, it will be downloaded.')
|
|
6
6
|
.option('--upload', 'Uploads the packages to the remote cache.')
|
|
7
|
+
.option('--non-interactive-login', 'Disables interactive login prompts for authentication.')
|
|
7
8
|
.action(async (options) => {
|
|
8
9
|
const { sync } = await import('./sync.js');
|
|
9
10
|
await sync(options, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IACxD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,+GAA+G,CAChH;SACA,MAAM,CAAC,UAAU,EAAE,2CAA2C,CAAC;SAC/D,MAAM,CAAC,KAAK,EAAE,OAAoB,EAAE,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\n\n/** Defines the \"sync\" verb. */\nexport const init: CommandFunction = (command, context) => {\n command\n .command('sync')\n .description(\n 'Syncs the packages from/to the remote cache. If the package is not in the local cache, it will be downloaded.',\n )\n .option('--upload', 'Uploads the packages to the remote cache.')\n .action(async (options: SyncOptions) => {\n const { sync } = await import('./sync.js');\n await sync(options, context);\n });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IACxD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CACV,+GAA+G,CAChH;SACA,MAAM,CAAC,UAAU,EAAE,2CAA2C,CAAC;SAC/D,MAAM,CAAC,yBAAyB,EAAE,wDAAwD,CAAC;SAC3F,MAAM,CAAC,KAAK,EAAE,OAAoB,EAAE,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\n\n/** Defines the \"sync\" verb. */\nexport const init: CommandFunction = (command, context) => {\n command\n .command('sync')\n .description(\n 'Syncs the packages from/to the remote cache. If the package is not in the local cache, it will be downloaded.',\n )\n .option('--upload', 'Uploads the packages to the remote cache.')\n .option('--non-interactive-login', 'Disables interactive login prompts for authentication.')\n .action(async (options: SyncOptions) => {\n const { sync } = await import('./sync.js');\n await sync(options, context);\n });\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { TaskContext } from '../../types/TaskContext.js';
|
|
2
2
|
import type { SyncOptions } from './types/SyncOptions.js';
|
|
3
|
-
export declare function sync({ upload }: SyncOptions, context: TaskContext): Promise<void>;
|
|
3
|
+
export declare function sync({ upload, nonInteractiveLogin }: SyncOptions, context: TaskContext): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAO1D,wBAAsB,IAAI,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,iBAwC5F"}
|
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
import { red } from '@ms-cloudpack/task-reporter';
|
|
2
2
|
import { stopTelemetry } from '../../initTelemetry.js';
|
|
3
3
|
import { setupReporting } from '../../setupReporting.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { syncDownload, syncUpload } from '@ms-cloudpack/api-server/apis';
|
|
5
|
+
import { createPartialApiContext } from '../../common/createPartialApiContext.js';
|
|
6
|
+
import { isCIBuild } from '../../utilities/isCIBuild.js';
|
|
7
|
+
export async function sync({ upload, nonInteractiveLogin }, context) {
|
|
6
8
|
let hasErrors = false;
|
|
7
9
|
let message = '';
|
|
8
10
|
try {
|
|
9
11
|
await setupReporting(context);
|
|
10
|
-
const config = context
|
|
11
|
-
|
|
12
|
+
const { config } = context;
|
|
13
|
+
const remoteCacheConfig = config.remoteCache;
|
|
14
|
+
if (!remoteCacheConfig) {
|
|
12
15
|
console.warn('Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.');
|
|
13
16
|
return;
|
|
14
17
|
}
|
|
15
|
-
const
|
|
18
|
+
const input = {
|
|
19
|
+
isInteractiveLogin: !(isCIBuild() || nonInteractiveLogin),
|
|
20
|
+
};
|
|
21
|
+
let disposeContext = undefined;
|
|
16
22
|
if (upload) {
|
|
17
|
-
await
|
|
23
|
+
const ctx = await createPartialApiContext(context, ['bus', 'taskRunner', 'watcher', 'packages', 'session']);
|
|
24
|
+
disposeContext = ctx.dispose;
|
|
25
|
+
await syncUpload({ input, ctx });
|
|
18
26
|
}
|
|
19
27
|
else {
|
|
20
|
-
await
|
|
28
|
+
const ctx = await createPartialApiContext(context, ['packages', 'session']);
|
|
29
|
+
disposeContext = ctx.dispose;
|
|
30
|
+
await syncDownload({ input, ctx });
|
|
21
31
|
}
|
|
32
|
+
await disposeContext?.();
|
|
22
33
|
hasErrors = context.reporter.hasErrors();
|
|
23
34
|
}
|
|
24
35
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAe,EAAE,OAAoB;IAC3F,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,OAAO,GAAW,EAAE,CAAC;IACzB,IAAI;QACF,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;Q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;QAC9D,MAAM,aAAa,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACjC;AACH,CAAC","sourcesContent":["import { red } from '@ms-cloudpack/task-reporter';\nimport { stopTelemetry } from '../../initTelemetry.js';\nimport type { TaskContext } from '../../types/TaskContext.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\nimport { setupReporting } from '../../setupReporting.js';\nimport { syncDownload, syncUpload } from '@ms-cloudpack/api-server/apis';\nimport { createPartialApiContext } from '../../common/createPartialApiContext.js';\nimport type { Context } from '@ms-cloudpack/api-server';\nimport { isCIBuild } from '../../utilities/isCIBuild.js';\n\nexport async function sync({ upload, nonInteractiveLogin }: SyncOptions, context: TaskContext) {\n let hasErrors = false;\n let message: string = '';\n try {\n await setupReporting(context);\n const { config } = context;\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n console.warn(\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n );\n return;\n }\n\n const input = {\n isInteractiveLogin: !(isCIBuild() || nonInteractiveLogin),\n };\n\n let disposeContext: Context['dispose'] | undefined = undefined;\n\n if (upload) {\n const ctx = await createPartialApiContext(context, ['bus', 'taskRunner', 'watcher', 'packages', 'session']);\n disposeContext = ctx.dispose;\n await syncUpload({ input, ctx });\n } else {\n const ctx = await createPartialApiContext(context, ['packages', 'session']);\n disposeContext = ctx.dispose;\n await syncDownload({ input, ctx });\n }\n\n await disposeContext?.();\n hasErrors = context.reporter.hasErrors();\n } catch (error) {\n message = error instanceof Error ? error.message : '<Unknown error>';\n hasErrors = true;\n } finally {\n context.reporter.complete(hasErrors ? red(message) : message);\n await stopTelemetry();\n process.exit(hasErrors ? 1 : 0);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/sync/types/SyncOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SyncOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/sync/types/SyncOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,mBAAmB,EAAE,OAAO,CAAC;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncOptions.js","sourceRoot":"","sources":["../../../../src/commands/sync/types/SyncOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface SyncOptions {\n upload: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SyncOptions.js","sourceRoot":"","sources":["../../../../src/commands/sync/types/SyncOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface SyncOptions {\n upload: boolean;\n nonInteractiveLogin: boolean;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Context } from '@ms-cloudpack/api-server';
|
|
2
|
+
import type { TaskContext } from '../types/TaskContext.js';
|
|
3
|
+
export declare function createPartialApiContext<TKeys extends Exclude<keyof Context, 'dispose'>, TReturn extends Pick<Context, TKeys | 'dispose' | 'reporter' | 'rootSpan'>>(context: TaskContext, items: TKeys[]): Promise<TReturn>;
|
|
4
|
+
//# sourceMappingURL=createPartialApiContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPartialApiContext.d.ts","sourceRoot":"","sources":["../../src/common/createPartialApiContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAuB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AA8F3D,wBAAsB,uBAAuB,CAC3C,KAAK,SAAS,OAAO,CAAC,MAAM,OAAO,EAAE,SAAS,CAAC,EAC/C,OAAO,SAAS,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC,EAC1E,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBxD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _LazyApiContext_bus, _LazyApiContext_watcher, _LazyApiContext_packages, _LazyApiContext_taskRunner, _LazyApiContext_session;
|
|
13
|
+
import { rootSpan } from '../initTelemetry.js';
|
|
14
|
+
class LazyApiContext {
|
|
15
|
+
constructor(context) {
|
|
16
|
+
this.context = context;
|
|
17
|
+
_LazyApiContext_bus.set(this, void 0);
|
|
18
|
+
_LazyApiContext_watcher.set(this, void 0);
|
|
19
|
+
_LazyApiContext_packages.set(this, void 0);
|
|
20
|
+
_LazyApiContext_taskRunner.set(this, void 0);
|
|
21
|
+
_LazyApiContext_session.set(this, void 0);
|
|
22
|
+
}
|
|
23
|
+
get rootSpan() {
|
|
24
|
+
return Promise.resolve(rootSpan);
|
|
25
|
+
}
|
|
26
|
+
get bus() {
|
|
27
|
+
if (!__classPrivateFieldGet(this, _LazyApiContext_bus, "f")) {
|
|
28
|
+
const createDataBusLazy = async () => {
|
|
29
|
+
const { createDataBus } = await import('@ms-cloudpack/data-bus');
|
|
30
|
+
return createDataBus();
|
|
31
|
+
};
|
|
32
|
+
__classPrivateFieldSet(this, _LazyApiContext_bus, createDataBusLazy(), "f");
|
|
33
|
+
}
|
|
34
|
+
return __classPrivateFieldGet(this, _LazyApiContext_bus, "f");
|
|
35
|
+
}
|
|
36
|
+
get watcher() {
|
|
37
|
+
if (!__classPrivateFieldGet(this, _LazyApiContext_watcher, "f")) {
|
|
38
|
+
const createWatcherLazy = async () => {
|
|
39
|
+
const { createWatcher } = await import('@ms-cloudpack/file-watcher');
|
|
40
|
+
return createWatcher();
|
|
41
|
+
};
|
|
42
|
+
__classPrivateFieldSet(this, _LazyApiContext_watcher, createWatcherLazy(), "f");
|
|
43
|
+
}
|
|
44
|
+
return __classPrivateFieldGet(this, _LazyApiContext_watcher, "f");
|
|
45
|
+
}
|
|
46
|
+
get reporter() {
|
|
47
|
+
return Promise.resolve(this.context.reporter);
|
|
48
|
+
}
|
|
49
|
+
get packages() {
|
|
50
|
+
if (!__classPrivateFieldGet(this, _LazyApiContext_packages, "f")) {
|
|
51
|
+
const createPackageDefinitionsLazy = async () => {
|
|
52
|
+
const { createPackageDefinitions } = await import('@ms-cloudpack/config');
|
|
53
|
+
return createPackageDefinitions({ config: this.context.config });
|
|
54
|
+
};
|
|
55
|
+
__classPrivateFieldSet(this, _LazyApiContext_packages, createPackageDefinitionsLazy(), "f");
|
|
56
|
+
}
|
|
57
|
+
return __classPrivateFieldGet(this, _LazyApiContext_packages, "f");
|
|
58
|
+
}
|
|
59
|
+
get taskRunner() {
|
|
60
|
+
if (!__classPrivateFieldGet(this, _LazyApiContext_taskRunner, "f")) {
|
|
61
|
+
const createTaskRunnerLazy = async () => {
|
|
62
|
+
const { TaskRunner } = await import('@ms-cloudpack/api-server');
|
|
63
|
+
return new TaskRunner();
|
|
64
|
+
};
|
|
65
|
+
__classPrivateFieldSet(this, _LazyApiContext_taskRunner, createTaskRunnerLazy(), "f");
|
|
66
|
+
}
|
|
67
|
+
return __classPrivateFieldGet(this, _LazyApiContext_taskRunner, "f");
|
|
68
|
+
}
|
|
69
|
+
get session() {
|
|
70
|
+
if (!__classPrivateFieldGet(this, _LazyApiContext_session, "f")) {
|
|
71
|
+
const createSessionLazy = async () => {
|
|
72
|
+
const { createSession } = await import('./createSession.js');
|
|
73
|
+
return createSession(this.context, { reporter: await this.reporter, packages: await this.packages });
|
|
74
|
+
};
|
|
75
|
+
__classPrivateFieldSet(this, _LazyApiContext_session, createSessionLazy(), "f");
|
|
76
|
+
}
|
|
77
|
+
return __classPrivateFieldGet(this, _LazyApiContext_session, "f");
|
|
78
|
+
}
|
|
79
|
+
async dispose() {
|
|
80
|
+
if (__classPrivateFieldGet(this, _LazyApiContext_watcher, "f")) {
|
|
81
|
+
const watcher = await __classPrivateFieldGet(this, _LazyApiContext_watcher, "f");
|
|
82
|
+
await watcher.unwatchAll();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
_LazyApiContext_bus = new WeakMap(), _LazyApiContext_watcher = new WeakMap(), _LazyApiContext_packages = new WeakMap(), _LazyApiContext_taskRunner = new WeakMap(), _LazyApiContext_session = new WeakMap();
|
|
87
|
+
export async function createPartialApiContext(context, items) {
|
|
88
|
+
const { reporter } = context;
|
|
89
|
+
const lazyContext = new LazyApiContext(context);
|
|
90
|
+
const result = {
|
|
91
|
+
reporter,
|
|
92
|
+
rootSpan,
|
|
93
|
+
dispose: () => {
|
|
94
|
+
return lazyContext.dispose();
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
for (const item of items) {
|
|
98
|
+
result[item] = (await lazyContext[item]);
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=createPartialApiContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPartialApiContext.js","sourceRoot":"","sources":["../../src/common/createPartialApiContext.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAO/C,MAAM,cAAc;IAOlB,YAA6B,OAAoB;QAApB,YAAO,GAAP,OAAO,CAAa;QANjD,sCAAmC;QACnC,0CAAuC;QACvC,2CAAwD;QACxD,6CAA6C;QAC7C,0CAAuC;IAEa,CAAC;IAErD,IAAW,QAAQ;QACjB,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,IAAW,GAAG;QACZ,IAAI,CAAC,uBAAA,IAAI,2BAAK,EAAE;YACd,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;gBACnC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;gBACjE,OAAO,aAAa,EAAE,CAAC;YACzB,CAAC,CAAC;YACF,uBAAA,IAAI,uBAAQ,iBAAiB,EAAE,MAAA,CAAC;SACjC;QAED,OAAO,uBAAA,IAAI,2BAAK,CAAC;IACnB,CAAC;IAED,IAAW,OAAO;QAChB,IAAI,CAAC,uBAAA,IAAI,+BAAS,EAAE;YAClB,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;gBACnC,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;gBACrE,OAAO,aAAa,EAAE,CAAC;YACzB,CAAC,CAAC;YACF,uBAAA,IAAI,2BAAY,iBAAiB,EAAE,MAAA,CAAC;SACrC;QAED,OAAO,uBAAA,IAAI,+BAAS,CAAC;IACvB,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;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AAC,OAAO;QAClB,IAAI,uBAAA,IAAI,+BAAS,EAAE;YACjB,MAAM,OAAO,GAAG,MAAM,uBAAA,IAAI,+BAAS,CAAC;YACpC,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;SAC5B;IACH,CAAC;CACF;;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAG3C,OAAoB,EAAE,KAAc;IACpC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,WAAW,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IAEhD,MAAM,MAAM,GAAG;QACb,QAAQ;QACR,QAAQ;QACR,OAAO,EAAE,GAAG,EAAE;YACZ,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;KACS,CAAC;IAEb,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,CAAmB,CAAC;KAC5D;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { DataBus } from '@ms-cloudpack/data-bus';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { Context, Session, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { TaskContext } from '../types/TaskContext.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { Watcher } from '@ms-cloudpack/file-watcher';\nimport { rootSpan } from '../initTelemetry.js';\nimport type { Span } from '@ms-cloudpack/telemetry';\n\ntype PromisifyProperties<T> = {\n [K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? T[K] : Promise<T[K]>;\n};\n\nclass LazyApiContext implements PromisifyProperties<Context> {\n #bus: Promise<DataBus> | undefined;\n #watcher: Promise<Watcher> | undefined;\n #packages: Promise<PackageDefinitionsCache> | undefined;\n #taskRunner: Promise<TaskRunner> | undefined;\n #session: Promise<Session> | undefined;\n\n constructor(private readonly context: TaskContext) {}\n\n public get rootSpan(): Promise<Span | undefined> {\n return Promise.resolve(rootSpan);\n }\n\n public get bus(): Promise<DataBus> {\n if (!this.#bus) {\n const createDataBusLazy = async () => {\n const { createDataBus } = await import('@ms-cloudpack/data-bus');\n return createDataBus();\n };\n this.#bus = createDataBusLazy();\n }\n\n return this.#bus;\n }\n\n public get watcher(): Promise<Watcher> {\n if (!this.#watcher) {\n const createWatcherLazy = async () => {\n const { createWatcher } = await import('@ms-cloudpack/file-watcher');\n return createWatcher();\n };\n this.#watcher = createWatcherLazy();\n }\n\n return this.#watcher;\n }\n\n public get reporter(): Promise<TaskReporter> {\n return Promise.resolve(this.context.reporter);\n }\n\n public get packages(): Promise<PackageDefinitionsCache> {\n if (!this.#packages) {\n const createPackageDefinitionsLazy = async () => {\n const { createPackageDefinitions } = await import('@ms-cloudpack/config');\n return createPackageDefinitions({ config: this.context.config });\n };\n this.#packages = createPackageDefinitionsLazy();\n }\n\n return this.#packages;\n }\n\n public get taskRunner(): Promise<TaskRunner> {\n if (!this.#taskRunner) {\n const createTaskRunnerLazy = async () => {\n const { TaskRunner } = await import('@ms-cloudpack/api-server');\n return new TaskRunner();\n };\n this.#taskRunner = createTaskRunnerLazy();\n }\n return this.#taskRunner;\n }\n\n public get session(): Promise<Session> {\n if (!this.#session) {\n const createSessionLazy = async () => {\n const { createSession } = await import('./createSession.js');\n return createSession(this.context, { reporter: await this.reporter, packages: await this.packages });\n };\n this.#session = createSessionLazy();\n }\n\n return this.#session;\n }\n\n public async dispose() {\n if (this.#watcher) {\n const watcher = await this.#watcher;\n await watcher.unwatchAll();\n }\n }\n}\n\nexport async function createPartialApiContext<\n TKeys extends Exclude<keyof Context, 'dispose'>,\n TReturn extends Pick<Context, TKeys | 'dispose' | 'reporter' | 'rootSpan'>,\n>(context: TaskContext, items: TKeys[]): Promise<TReturn> {\n const { reporter } = context;\n const lazyContext = new LazyApiContext(context);\n\n const result = {\n reporter,\n rootSpan,\n dispose: () => {\n return lazyContext.dispose();\n },\n } as TReturn;\n\n for (const item of items) {\n result[item] = (await lazyContext[item]) as TReturn[TKeys];\n }\n\n return result;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAO3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAK5D,wBAAsB,aAAa,CACjC,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAO3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAK5D,wBAAsB,aAAa,CACjC,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,EACD,OAAO,EAAE;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GACrE,OAAO,CAAC,OAAO,CAAC,CA0DlB"}
|
|
@@ -6,15 +6,15 @@ import fsExtra from 'fs-extra';
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { resolveDependenciesTask } from '../tasks/resolveDependenciesTask.js';
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const overlayPackageName = '@ms-cloudpack/overlay';
|
|
10
|
+
const overlayPackagePath = (await resolve(overlayPackageName, path.dirname(fileURLToPath(import.meta.url)))) || '';
|
|
11
11
|
export async function createSession(options, context) {
|
|
12
|
-
const { appPath, config } = options;
|
|
12
|
+
const { appPath, config, includeOverlay } = options;
|
|
13
13
|
const projectName = path.basename(appPath);
|
|
14
14
|
const id = uuid();
|
|
15
15
|
const resolveMap = await resolveDependenciesTask({
|
|
16
16
|
appPath,
|
|
17
|
-
additionalPaths: [
|
|
17
|
+
additionalPaths: includeOverlay ? [overlayPackagePath] : [],
|
|
18
18
|
}, context);
|
|
19
19
|
if (!resolveMap) {
|
|
20
20
|
throw new Error('Could not resolve dependencies.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAgB,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAkB,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAK9E,MAAM,
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../src/common/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAgB,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAkB,MAAM,iCAAiC,CAAC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AAC,kBAAkB,CAAC,CAAC;IAChE,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,OAAO,CAAC,SAAS,CAAC,kBAAkB,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;KAChE;IACD,MAAM,cAAc,GAAG,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAA2B,CAAC;IAE9F,OAAO;QACL,EAAE;QACF,OAAO;QACP,MAAM;QACN,WAAW;QACX,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,UAAU;QACV,QAAQ,EAAE,CAAC;QACX,cAAc;QACd,iBAAiB,EAAE,GAAG,EAAE,CAAC,cAAc;QACvC,uBAAuB,EAAE,CAAC,OAAgB,EAAE,EAAE;YAC5C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,GAAG,cAAc,EAAE;gBACrD,cAAc,GAAG,OAAO,IAAI,cAAc,GAAG,CAAC,CAAC;gBAC/C,SAAS,GAAG,SAAS,CAAC;aACvB;QACH,CAAC;QACD,sBAAsB,EAAE,CAAC,SAAiB,EAAE,EAAE;YAC5C,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAChC,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,SAAS,GAAG,SAAS,CAAC;YACtB,gFAAgF;YAChF,EAAE,CAAC,aAAa,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;QAC7B,YAAY,EAAE,CAAC,YAAuB,EAAE,EAAE;YACxC,SAAS,GAAG,YAAY,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { v4 as uuid } from 'uuid';\nimport { getLocalCachePath, type Session } from '@ms-cloudpack/api-server';\nimport { resolve, type ImportMap } from '@ms-cloudpack/package-utilities';\nimport fs from 'fs';\nimport fsExtra from 'fs-extra';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { resolveDependenciesTask } from '../tasks/resolveDependenciesTask.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\nconst overlayPackageName = '@ms-cloudpack/overlay';\nconst overlayPackagePath = (await resolve(overlayPackageName, path.dirname(fileURLToPath(import.meta.url)))) || '';\n\nexport async function createSession(\n options: {\n appPath: string;\n config: CloudpackConfig;\n includeOverlay?: boolean;\n },\n context: { reporter: TaskReporter; packages: PackageDefinitionsCache },\n): Promise<Session> {\n const { appPath, config, includeOverlay } = options;\n\n const projectName = path.basename(appPath);\n const id = uuid();\n const resolveMap = await resolveDependenciesTask(\n {\n appPath,\n additionalPaths: includeOverlay ? [overlayPackagePath] : [],\n },\n context,\n );\n\n if (!resolveMap) {\n throw new Error('Could not resolve dependencies.');\n }\n\n let importMap: ImportMap | undefined = undefined;\n let sessionVersion = 0;\n\n await fsExtra.ensureDir(getLocalCachePath(appPath));\n const targetVersionsPath = path.join(getLocalCachePath(appPath), 'targetVersions.json');\n const fileExists = await fsExtra.pathExists(targetVersionsPath);\n if (!fileExists) {\n await fsExtra.writeJson(targetVersionsPath, {}, { spaces: 2 });\n }\n const targetVersions = (await fsExtra.readJSON(targetVersionsPath)) as Record<string, number>;\n\n return {\n id,\n appPath,\n config,\n projectName,\n type: 'web-app',\n mode: 'library',\n resolveMap,\n sequence: 0,\n targetVersions,\n getSessionVersion: () => sessionVersion,\n incrementSessionVersion: (version?: number) => {\n if (version === undefined || version > sessionVersion) {\n sessionVersion = version ?? sessionVersion + 1;\n importMap = undefined;\n }\n },\n incrementTargetVersion: (inputPath: string) => {\n targetVersions[inputPath] ??= 0;\n targetVersions[inputPath]++;\n importMap = undefined;\n // eslint-disable-next-line no-restricted-syntax -- this function can't be async\n fs.writeFileSync(targetVersionsPath, JSON.stringify(targetVersions, null, 2));\n },\n getImportMap: () => importMap,\n setImportMap: (newImportMap: ImportMap) => {\n importMap = newImportMap;\n return importMap;\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupReporting.d.ts","sourceRoot":"","sources":["../src/setupReporting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"setupReporting.d.ts","sourceRoot":"","sources":["../src/setupReporting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAoB1D,wBAAsB,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,WAAW,8DA6B9E"}
|
package/lib/setupReporting.js
CHANGED
|
@@ -3,6 +3,7 @@ import { initTelemetry } from './initTelemetry.js';
|
|
|
3
3
|
import { bold, defaultLoggingConfig, verboseLoggingConfig, debugLoggingConfig, } from '@ms-cloudpack/task-reporter';
|
|
4
4
|
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import { isCIBuild } from './utilities/isCIBuild.js';
|
|
6
7
|
const { argv } = process;
|
|
7
8
|
const useDebugLogging = argv.includes('--debug') || argv.includes('-d');
|
|
8
9
|
const verb = argv[2];
|
|
@@ -26,7 +27,7 @@ export async function setupReporting({ reporter, config, appPath }) {
|
|
|
26
27
|
sharedSpanAttributes: {
|
|
27
28
|
verb,
|
|
28
29
|
arguments: argv.slice(3).join(' '),
|
|
29
|
-
environment:
|
|
30
|
+
environment: isCIBuild() ? 'ci' : 'local',
|
|
30
31
|
appName: definition?.name || '<unknown>',
|
|
31
32
|
},
|
|
32
33
|
}, reporter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupReporting.js","sourceRoot":"","sources":["../src/setupReporting.ts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C7E,QAAQ,CAAC,UAAU,CAAC;QAClB,WAAW,EAAE,WAAW;QACxB,OAAO;QACP,WAAW,EAAE,GAAG,EAAE,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG;QAC/D,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,GAAG,oBAAoB;QACvB,GAAG,CAAC,iBAAiB,IAAI,oBAAoB,CAAC;QAC9C,GAAG,CAAC,eAAe,IAAI,kBAAkB,CAAC;KACpB,CAAC,CAAC;IAE1B,MAAM,UAAU,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAgB,CAAC;IAEvF,MAAM,eAAe,GAAG,MAAM,aAAa,CACzC;QACE,eAAe;QACf,iBAAiB;QACjB,eAAe,EAAE,MAAM,CAAC,SAAS;QACjC,oBAAoB,EAAE;YACpB,IAAI;YACJ,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YAClC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;YACzC,OAAO,EAAE,UAAU,EAAE,IAAI,IAAI,WAAW;SACzC;KACF,EACD,QAAQ,CACT,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { getVersion } from '@ms-cloudpack/package-utilities';\nimport type { TaskContext } from './types/TaskContext.js';\nimport { initTelemetry } from './initTelemetry.js';\nimport {\n bold,\n defaultLoggingConfig,\n verboseLoggingConfig,\n type TaskReporterOptions,\n debugLoggingConfig,\n} from '@ms-cloudpack/task-reporter';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport { isCIBuild } from './utilities/isCIBuild.js';\n\nconst { argv } = process;\nconst useDebugLogging = argv.includes('--debug') || argv.includes('-d');\nconst verb = argv[2];\nconst useVerboseLogging = argv.includes('--verbose') || argv.includes('-v') || verb === 'bundle';\nconst version = getVersion(import.meta.url);\n\nexport async function setupReporting({ reporter, config, appPath }: TaskContext) {\n reporter.setOptions({\n productName: 'Cloudpack',\n version,\n description: () => `Running \"${bold(argv.slice(2).join(' '))}\"`,\n helpMessage: config.helpMessage,\n ...defaultLoggingConfig,\n ...(useVerboseLogging && verboseLoggingConfig),\n ...(useDebugLogging && debugLoggingConfig),\n } as TaskReporterOptions);\n\n const definition = (await readJson(path.join(appPath, 'package.json'))) as PackageJson;\n\n const telemetryClient = await initTelemetry(\n {\n useDebugLogging,\n useVerboseLogging,\n telemetryConfig: config.telemetry,\n sharedSpanAttributes: {\n verb,\n arguments: argv.slice(3).join(' '),\n environment: isCIBuild() ? 'ci' : 'local',\n appName: definition?.name || '<unknown>',\n },\n },\n reporter,\n );\n\n return telemetryClient;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCIBuild.d.ts","sourceRoot":"","sources":["../../src/utilities/isCIBuild.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,SAAS,uBAExB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCIBuild.js","sourceRoot":"","sources":["../../src/utilities/isCIBuild.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAChD,CAAC","sourcesContent":["/**\n * @returns true if the current process is running in a CI environment\n */\nexport function isCIBuild() {\n return process.env.CI || process.env.TF_BUILD;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@lage-run/target-graph": "^0.8.6",
|
|
14
|
-
"@ms-cloudpack/api-server": "^0.
|
|
15
|
-
"@ms-cloudpack/bundler": "^0.14.
|
|
16
|
-
"@ms-cloudpack/config": "^0.11.
|
|
14
|
+
"@ms-cloudpack/api-server": "^0.14.0",
|
|
15
|
+
"@ms-cloudpack/bundler": "^0.14.9",
|
|
16
|
+
"@ms-cloudpack/config": "^0.11.2",
|
|
17
17
|
"@ms-cloudpack/create-express-app": "^1.3.9",
|
|
18
|
+
"@ms-cloudpack/data-bus": "^0.4.0",
|
|
19
|
+
"@ms-cloudpack/file-watcher": "^0.0.3",
|
|
18
20
|
"@ms-cloudpack/json-utilities": "^0.0.7",
|
|
19
|
-
"@ms-cloudpack/overlay": "^0.14.
|
|
20
|
-
"@ms-cloudpack/package-utilities": "^5.1.
|
|
21
|
+
"@ms-cloudpack/overlay": "^0.14.9",
|
|
22
|
+
"@ms-cloudpack/package-utilities": "^5.1.2",
|
|
21
23
|
"@ms-cloudpack/path-string-parsing": "^1.0.3",
|
|
22
24
|
"@ms-cloudpack/path-utilities": "^2.3.2",
|
|
23
25
|
"@ms-cloudpack/task-reporter": "^0.7.2",
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import type { TaskContext } from '../types/TaskContext.js';
|
|
2
|
-
export declare function createApiServer(context: TaskContext): Promise<{
|
|
3
|
-
apiServer: {
|
|
4
|
-
url: string;
|
|
5
|
-
port: number;
|
|
6
|
-
ctx: {
|
|
7
|
-
session: import("@ms-cloudpack/api-server").Session;
|
|
8
|
-
bus: import("@ms-cloudpack/data-bus").DataBus;
|
|
9
|
-
rootSpan: import("@opentelemetry/api").Span | undefined;
|
|
10
|
-
reporter: import("@ms-cloudpack/task-reporter").TaskReporter;
|
|
11
|
-
watcher: {
|
|
12
|
-
watch({ path, watchPaths, }: {
|
|
13
|
-
path: string;
|
|
14
|
-
watchPaths?: string[] | undefined;
|
|
15
|
-
}, onPackageChanged: () => void): () => Promise<void>;
|
|
16
|
-
unwatchAll(): Promise<void>;
|
|
17
|
-
};
|
|
18
|
-
packages: import("@ms-cloudpack/bundler-types").PackageDefinitionsCache;
|
|
19
|
-
taskRunner: import("@ms-cloudpack/api-server").TaskRunner;
|
|
20
|
-
dispose(): Promise<void>;
|
|
21
|
-
};
|
|
22
|
-
close: () => Promise<void>;
|
|
23
|
-
addPackageOverride: (options: {
|
|
24
|
-
packageName: string;
|
|
25
|
-
importPath: string;
|
|
26
|
-
filename?: string | undefined;
|
|
27
|
-
}) => Promise<void>;
|
|
28
|
-
getData: (options: {
|
|
29
|
-
path: string[];
|
|
30
|
-
}) => any;
|
|
31
|
-
getSessionId: (options: unknown) => string | undefined;
|
|
32
|
-
onDataChanged: (options: {
|
|
33
|
-
path: string[];
|
|
34
|
-
}) => any;
|
|
35
|
-
openCodeEditor: (options: {
|
|
36
|
-
rootPath: string;
|
|
37
|
-
relativePath?: string | undefined;
|
|
38
|
-
line?: number | undefined;
|
|
39
|
-
column?: number | undefined;
|
|
40
|
-
}) => Promise<void>;
|
|
41
|
-
openConfigEditor: (options: unknown) => Promise<void>;
|
|
42
|
-
openFilePath: (options: {
|
|
43
|
-
rootPath: string;
|
|
44
|
-
relativePath?: string | undefined;
|
|
45
|
-
}) => Promise<void>;
|
|
46
|
-
reportMetric: (options: {
|
|
47
|
-
metric: string;
|
|
48
|
-
value: number;
|
|
49
|
-
}) => void;
|
|
50
|
-
validatePackageOverride: (options: {
|
|
51
|
-
packageName: string;
|
|
52
|
-
importPath: string;
|
|
53
|
-
}) => Promise<{
|
|
54
|
-
fixable: boolean;
|
|
55
|
-
}>;
|
|
56
|
-
syncDownload: (options: unknown) => Promise<void>;
|
|
57
|
-
syncUpload: (options: unknown) => Promise<void>;
|
|
58
|
-
ensurePackageBundled: (options: {
|
|
59
|
-
name: string;
|
|
60
|
-
version: string;
|
|
61
|
-
outputPath?: string | undefined;
|
|
62
|
-
bundlerType?: string | undefined;
|
|
63
|
-
disableSourceMaps?: boolean | undefined;
|
|
64
|
-
shouldRerun?: boolean | undefined;
|
|
65
|
-
shouldWatch?: boolean | undefined;
|
|
66
|
-
shouldForce?: boolean | undefined;
|
|
67
|
-
}) => Promise<{
|
|
68
|
-
bundlerName?: string | undefined;
|
|
69
|
-
inputPath?: string | undefined;
|
|
70
|
-
outputPath?: string | undefined;
|
|
71
|
-
entries?: Record<string, string> | undefined;
|
|
72
|
-
dependencies?: string[] | undefined;
|
|
73
|
-
hash?: string | undefined;
|
|
74
|
-
outputFiles?: {
|
|
75
|
-
outputPath: string;
|
|
76
|
-
entryPoint?: string | undefined;
|
|
77
|
-
exports?: string[] | undefined;
|
|
78
|
-
}[] | undefined;
|
|
79
|
-
errors?: {
|
|
80
|
-
text: string;
|
|
81
|
-
pluginName?: string | undefined;
|
|
82
|
-
type?: string | undefined;
|
|
83
|
-
location?: {
|
|
84
|
-
line: number;
|
|
85
|
-
column: number;
|
|
86
|
-
file: string;
|
|
87
|
-
} | undefined;
|
|
88
|
-
notes?: {
|
|
89
|
-
text?: string | undefined;
|
|
90
|
-
location?: {
|
|
91
|
-
line: number;
|
|
92
|
-
column: number;
|
|
93
|
-
file: string;
|
|
94
|
-
} | undefined;
|
|
95
|
-
}[] | undefined;
|
|
96
|
-
}[] | undefined;
|
|
97
|
-
warnings?: {
|
|
98
|
-
text: string;
|
|
99
|
-
pluginName?: string | undefined;
|
|
100
|
-
type?: string | undefined;
|
|
101
|
-
location?: {
|
|
102
|
-
line: number;
|
|
103
|
-
column: number;
|
|
104
|
-
file: string;
|
|
105
|
-
} | undefined;
|
|
106
|
-
notes?: {
|
|
107
|
-
text?: string | undefined;
|
|
108
|
-
location?: {
|
|
109
|
-
line: number;
|
|
110
|
-
column: number;
|
|
111
|
-
file: string;
|
|
112
|
-
} | undefined;
|
|
113
|
-
}[] | undefined;
|
|
114
|
-
}[] | undefined;
|
|
115
|
-
rawInput?: Record<string, unknown> | undefined;
|
|
116
|
-
rawOutput?: Record<string, unknown> | undefined;
|
|
117
|
-
}>;
|
|
118
|
-
};
|
|
119
|
-
packages: import("@ms-cloudpack/bundler-types").PackageDefinitionsCache;
|
|
120
|
-
session: import("@ms-cloudpack/api-server").Session;
|
|
121
|
-
}>;
|
|
122
|
-
//# sourceMappingURL=createApiServer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createApiServer.d.ts","sourceRoot":"","sources":["../../src/common/createApiServer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,wBAAsB,eAAe,CAAC,OAAO,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkBzD"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { rootSpan } from '../initTelemetry.js';
|
|
2
|
-
import { createPackageDefinitions } from '@ms-cloudpack/config';
|
|
3
|
-
import { createSession } from './createSession.js';
|
|
4
|
-
export async function createApiServer(context) {
|
|
5
|
-
const { appPath, config, reporter } = context;
|
|
6
|
-
// Initialize package overrides.
|
|
7
|
-
const packages = createPackageDefinitions({ config });
|
|
8
|
-
// Initialize session definition.
|
|
9
|
-
const session = await createSession({ appPath, config }, { reporter, packages });
|
|
10
|
-
const { createCloudpackServer } = await import('@ms-cloudpack/api-server');
|
|
11
|
-
const apiServer = await createCloudpackServer({ session, rootSpan, reporter, packages });
|
|
12
|
-
return {
|
|
13
|
-
apiServer,
|
|
14
|
-
packages,
|
|
15
|
-
session,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=createApiServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createApiServer.js","sourceRoot":"","sources":["../../src/common/createApiServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAoB;IACxD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE9C,gCAAgC;IAChC,MAAM,QAAQ,GAAG,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtD,iCAAiC;IACjC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEjF,MAAM,EAAE,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAE3E,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEzF,OAAO;QACL,SAAS;QACT,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { rootSpan } from '../initTelemetry.js';\nimport { createPackageDefinitions } from '@ms-cloudpack/config';\nimport type { TaskContext } from '../types/TaskContext.js';\nimport { createSession } from './createSession.js';\n\nexport async function createApiServer(context: TaskContext) {\n const { appPath, config, reporter } = context;\n\n // Initialize package overrides.\n const packages = createPackageDefinitions({ config });\n\n // Initialize session definition.\n const session = await createSession({ appPath, config }, { reporter, packages });\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n\n const apiServer = await createCloudpackServer({ session, rootSpan, reporter, packages });\n\n return {\n apiServer,\n packages,\n session,\n };\n}\n"]}
|