@ms-cloudpack/cli 0.72.18 → 0.72.20
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/execute.d.ts.map +1 -1
- package/lib/commands/bundle/execute.js +3 -6
- package/lib/commands/bundle/execute.js.map +1 -1
- package/lib/commands/bundle/index.d.ts.map +1 -1
- package/lib/commands/bundle/index.js +1 -2
- package/lib/commands/bundle/index.js.map +1 -1
- package/lib/commands/bundle/types/BundleOptions.d.ts +1 -1
- package/lib/commands/bundle/types/BundleOptions.js.map +1 -1
- package/lib/commands/init/InitSummaryData.d.ts.map +1 -1
- package/lib/commands/init/InitSummaryData.js +2 -4
- package/lib/commands/init/InitSummaryData.js.map +1 -1
- package/lib/commands/init/evaluateImportsForOverrides.d.ts.map +1 -1
- package/lib/commands/init/evaluateImportsForOverrides.js +9 -12
- package/lib/commands/init/evaluateImportsForOverrides.js.map +1 -1
- package/lib/commands/init/formatInitSummary.d.ts.map +1 -1
- package/lib/commands/init/formatInitSummary.js +20 -12
- package/lib/commands/init/formatInitSummary.js.map +1 -1
- package/lib/commands/init/index.d.ts.map +1 -1
- package/lib/commands/init/index.js +1 -4
- package/lib/commands/init/index.js.map +1 -1
- package/lib/commands/init/types/GeneratedChange.d.ts +3 -1
- package/lib/commands/init/types/GeneratedChange.d.ts.map +1 -1
- package/lib/commands/init/types/GeneratedChange.js +6 -1
- package/lib/commands/init/types/GeneratedChange.js.map +1 -1
- package/lib/commands/init/verifyExports.d.ts.map +1 -1
- package/lib/commands/init/verifyExports.js +6 -6
- package/lib/commands/init/verifyExports.js.map +1 -1
- package/lib/commands/start/execute.d.ts.map +1 -1
- package/lib/commands/start/execute.js +2 -1
- package/lib/commands/start/execute.js.map +1 -1
- package/lib/utilities/findCloudpackAppPaths.js +2 -2
- package/lib/utilities/findCloudpackAppPaths.js.map +1 -1
- package/lib/utilities/getConfigOptionsFromCliOptions.d.ts +8 -0
- package/lib/utilities/getConfigOptionsFromCliOptions.d.ts.map +1 -0
- package/lib/utilities/getConfigOptionsFromCliOptions.js +13 -0
- package/lib/utilities/getConfigOptionsFromCliOptions.js.map +1 -0
- package/lib/utilities/reusedOptions.d.ts +6 -1
- package/lib/utilities/reusedOptions.d.ts.map +1 -1
- package/lib/utilities/reusedOptions.js +7 -1
- package/lib/utilities/reusedOptions.js.map +1 -1
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,CA4EhD,CAAC"}
|
|
@@ -2,16 +2,13 @@ import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api
|
|
|
2
2
|
import { plural, red, yellow } from '@ms-cloudpack/task-reporter';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { getFilteredPackages } from '../../utilities/getFilteredPackages.js';
|
|
5
|
+
import { getConfigOptionsFromCliOptions } from '../../utilities/getConfigOptionsFromCliOptions.js';
|
|
5
6
|
export const execute = async (params) => {
|
|
6
7
|
const { cwd: appPath, options, reporter, initialize, autoDispose } = params;
|
|
7
8
|
const apiContextOptions = await initialize({
|
|
8
9
|
appPath,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// Handle --bundler by passing it as a universal package override, which will be appended
|
|
12
|
-
// to any user-provided packageSettings so that it takes precedence.
|
|
13
|
-
extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,
|
|
14
|
-
},
|
|
10
|
+
// This handles --bundler as a universal package override
|
|
11
|
+
configOptions: getConfigOptionsFromCliOptions(options),
|
|
15
12
|
});
|
|
16
13
|
console.log('Bundle mode:', yellow(options.mode));
|
|
17
14
|
const [ctx] = autoDispose(await createPartialApiContext({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAC;AAEnG,MAAM,CAAC,MAAM,OAAO,GAAiC,KAAK,EAAE,MAAM,EAAE,EAAE;IACpE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAC5E,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC;QACzC,OAAO;QACP,yDAAyD;QACzD,aAAa,EAAE,8BAA8B,CAAC,OAAO,CAAC;KACvD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,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;YAC5C,KAAK,EAAE;gBACL,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,OAAO,EAAE,UAAU,CAAC,OAAO;gBAC3B,UAAU;gBACV,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;gBAC5C,WAAW,EAAE,IAAI;gBACjB,aAAa,EAAE,KAAK;aACrB;YACD,GAAG;SACJ,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YAC1B,kBAAkB,EAAE,CAAC;QACvB,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;YACnC,iBAAiB,EAAE,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,oBAAoB,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG;QACb,kBAAkB,IAAI,GAAG,CAAC,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;QACzE,iBAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,mCAAmC,CAAC,CAAC;QAC3F,oBAAoB,IAAI,MAAM,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;KAC5E;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;QACL,OAAO,EAAE,YAAY,MAAM,IAAI;QAC/B,SAAS,EAAE,CAAC,CAAC,kBAAkB;KAChC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { plural, red, yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\nimport { getConfigOptionsFromCliOptions } from '../../utilities/getConfigOptionsFromCliOptions.js';\n\nexport const execute: CommandAction<BundleOptions> = async (params) => {\n const { cwd: appPath, options, reporter, initialize, autoDispose } = params;\n const apiContextOptions = await initialize({\n appPath,\n // This handles --bundler as a universal package override\n configOptions: getConfigOptionsFromCliOptions(options),\n });\n\n console.log('Bundle mode:', yellow(options.mode));\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'watcher', 'session', 'taskRunner', 'bus', 'packageImportPaths', 'packageHashes'],\n }),\n );\n\n const pathsToBundle = options.match ? getFilteredPackages(ctx.session.resolveMap, options.match) : [appPath];\n\n if (!pathsToBundle.length) {\n return {\n message: 'No matching packages found to bundle.',\n hasErrors: true,\n };\n }\n\n // Show completed bundle tasks so the user knows what's happening.\n reporter.setOptions({ ...reporter.getOptions(), showCompleted: true });\n\n let warnPackagesCount = 0;\n let errorPackagesCount = 0;\n let successPackagesCount = 0;\n\n for (const packagePath of pathsToBundle) {\n // If outdir is set, resolve relative to the package/app path.\n // Otherwise, use the default path under the cloudpack cache to stay consistent with init and start,\n // and to avoid potentially messing with the package's original output.\n const outputPath = options.outdir ? path.resolve(packagePath, options.outdir) : undefined;\n\n const definition = await ctx.packages.get(packagePath);\n\n const { result } = await ensurePackageBundled({\n input: {\n name: definition.name,\n version: definition.version,\n outputPath,\n disableSourceMaps: options.disableSourceMaps,\n shouldForce: true,\n isIncremental: false,\n },\n ctx,\n });\n\n console.log('Output:', result.outputPath, '\\n');\n\n if (result.errors?.length) {\n errorPackagesCount++;\n } else if (result.warnings?.length) {\n warnPackagesCount++;\n } else {\n successPackagesCount++;\n }\n }\n\n const status = [\n errorPackagesCount && red(plural(errorPackagesCount, 'package$s failed')),\n warnPackagesCount && yellow(plural(warnPackagesCount, 'package$s succeeded with warnings')),\n successPackagesCount && plural(successPackagesCount, 'package$s succeeded'),\n ]\n .filter(Boolean)\n .join(', ');\n\n return {\n message: `Bundling ${status}\\n`,\n hasErrors: !!errorPackagesCount,\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAI9E,iCAAiC;AACjC,eAAO,MAAM,IAAI,EAAE,mBAoBlB,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { bundlerNames } from '@ms-cloudpack/bundler';
|
|
2
2
|
import { InvalidArgumentError, Option } from 'commander';
|
|
3
|
-
import { parseMatch } from '../../utilities/parseMatch.js';
|
|
4
3
|
import { reusedOptions } from '../../utilities/reusedOptions.js';
|
|
5
4
|
/** Defines the "bundle" verb. */
|
|
6
5
|
export const init = (program) => {
|
|
@@ -10,7 +9,7 @@ export const init = (program) => {
|
|
|
10
9
|
options: {
|
|
11
10
|
mode: reusedOptions.mode({ action: 'bundle' }),
|
|
12
11
|
bundler: new Option('--bundler <name>', 'Force using a specific bundler.').choices(bundlerNames),
|
|
13
|
-
match:
|
|
12
|
+
match: reusedOptions.match('Bundle specific package(s)'),
|
|
14
13
|
package: new Option('--package <package>').hideHelp().argParser(() => {
|
|
15
14
|
throw new InvalidArgumentError('Use --match instead of --package');
|
|
16
15
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/bundle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,iCAAiC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAgB;QACnC,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE;YACP,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;YAC9C,OAAO,EAAE,IAAI,MAAM,CAAC,kBAAkB,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;YAChG,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,4BAA4B,CAAC;YACxD,OAAO,EAAE,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE;gBACnE,MAAM,IAAI,oBAAoB,CAAC,kCAAkC,CAAC,CAAC;YACrE,CAAC,CAAC;YACF,MAAM,EAAE,IAAI,MAAM,CAChB,iBAAiB,EACjB,yGAAyG;gBACvG,8CAA8C,CACjD;YACD,iBAAiB,EAAE,IAAI,MAAM,CAAC,uBAAuB,EAAE,sBAAsB,CAAC;SAC/E;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { bundlerNames } from '@ms-cloudpack/bundler';\nimport { InvalidArgumentError, Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"bundle\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<BundleOptions>({\n name: 'bundle',\n description: 'Bundles a package.',\n options: {\n mode: reusedOptions.mode({ action: 'bundle' }),\n bundler: new Option('--bundler <name>', 'Force using a specific bundler.').choices(bundlerNames),\n match: reusedOptions.match('Bundle specific package(s)'),\n package: new Option('--package <package>').hideHelp().argParser(() => {\n throw new InvalidArgumentError('Use --match instead of --package');\n }),\n outdir: new Option(\n '--outdir <path>',\n 'Path for the bundle output, relative to current path (or the resolved path to --package if specified). ' +\n 'Default is a path under the cloudpack cache.',\n ),\n disableSourceMaps: new Option('--disable-source-maps', 'Disable source maps.'),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BundleMode, PackageSettingsMatch } from '@ms-cloudpack/common-types';
|
|
2
2
|
export interface BundleOptions {
|
|
3
3
|
/**
|
|
4
|
-
* Force using a specific bundler (ori/rollup/webpack).
|
|
4
|
+
* Force using a specific bundler (ori/rollup/rspack/webpack).
|
|
5
5
|
*
|
|
6
6
|
* Default is automatically choosing the bundler based on package contents, unless there any
|
|
7
7
|
* relevant package settings specify a bundler.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleOptions.js","sourceRoot":"","sources":["../../../../src/commands/bundle/types/BundleOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMode, PackageSettingsMatch } from '@ms-cloudpack/common-types';\n\nexport interface BundleOptions {\n /**\n * Force using a specific bundler (ori/rollup/webpack).\n *\n * Default is automatically choosing the bundler based on package contents, unless there any\n * relevant package settings specify a bundler.\n */\n bundler?: string;\n\n /**\n * Disables source maps.\n */\n disableSourceMaps?: boolean;\n\n /**\n * Path for the bundle output. This is usually relative to the app path.\n * If `package` is set, it's relative to the package path.\n *\n * If not set, the bundle output is dropped in the default path under the cloudpack cache.\n */\n outdir?: string;\n\n /**\n * @deprecated Removed in favor of `match`.\n */\n package?: string;\n\n /**\n * If set, only evaluate matching packages.\n */\n match?: PackageSettingsMatch[];\n\n /** The mode to bundle in. */\n mode: BundleMode;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BundleOptions.js","sourceRoot":"","sources":["../../../../src/commands/bundle/types/BundleOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMode, PackageSettingsMatch } from '@ms-cloudpack/common-types';\n\nexport interface BundleOptions {\n /**\n * Force using a specific bundler (ori/rollup/rspack/webpack).\n *\n * Default is automatically choosing the bundler based on package contents, unless there any\n * relevant package settings specify a bundler.\n */\n bundler?: string;\n\n /**\n * Disables source maps.\n */\n disableSourceMaps?: boolean;\n\n /**\n * Path for the bundle output. This is usually relative to the app path.\n * If `package` is set, it's relative to the package path.\n *\n * If not set, the bundle output is dropped in the default path under the cloudpack cache.\n */\n outdir?: string;\n\n /**\n * @deprecated Removed in favor of `match`.\n */\n package?: string;\n\n /**\n * If set, only evaluate matching packages.\n */\n match?: PackageSettingsMatch[];\n\n /** The mode to bundle in. */\n mode: BundleMode;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitSummaryData.d.ts","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAGlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"InitSummaryData.d.ts","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAGlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAGhE;;;;;;;GAOG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,iBAAiB,CAA0C;IACnE,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAS;gBAEb,OAAO,EAAE,MAAM;IAO3B;;OAEG;IACI,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAIpD;;OAEG;IACI,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IASpE;;;OAGG;IACI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAItD;;;;OAIG;IACI,sBAAsB,CAAC,UAAU,EAAE,uBAAuB,EAAE;IASnE;;;OAGG;IACI,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,WAAW;CA+CnE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requiredChangeTypes } from './types/GeneratedChange.js';
|
|
1
2
|
/**
|
|
2
3
|
* Creates a summary tracking helper for the `init` verb to use to record statistics about results and needed
|
|
3
4
|
* changes. The `record*` methods of the returned object will be used within init to add the stats, and the
|
|
@@ -77,10 +78,7 @@ export class InitSummaryData {
|
|
|
77
78
|
const sortedUpdates = Object.values(this._generatedUpdates).sort((a, b) => a.path.localeCompare(b.path));
|
|
78
79
|
for (const updates of sortedUpdates) {
|
|
79
80
|
totalChanges += updates.changes.length;
|
|
80
|
-
totalRequiredChanges += updates.changes.filter((u) => u.type
|
|
81
|
-
u.type === 'added-export' ||
|
|
82
|
-
u.type === 'added-dynamic-import' ||
|
|
83
|
-
u.type === 'included-dependency-required').length;
|
|
81
|
+
totalRequiredChanges += updates.changes.filter((u) => requiredChangeTypes.includes(u.type)).length;
|
|
84
82
|
updates.changes = updates.changes.sort((a, b) => a.change.localeCompare(b.change));
|
|
85
83
|
}
|
|
86
84
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitSummaryData.js","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InitSummaryData.js","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAM1B,YAAY,OAAe;QACzB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,MAAyB;QAC3C,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,WAAmB,EAAE,MAAuB;QAC3D,MAAM,aAAa,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QACxD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,WAAW,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,aAAa,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;IACtE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types/InitSummary.js';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport type { InitPackageResultWarnings } from './types/InitPackageResultWarnings.js';\nimport type { InitPackageResultErrors } from './types/InitPackageResultErrors.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { BundleMessage } from '@ms-cloudpack/common-types';\nimport { requiredChangeTypes } from './types/GeneratedChange.js';\n\n/**\n * Creates a summary tracking helper for the `init` verb to use to record statistics about results and needed\n * changes. The `record*` methods of the returned object will be used within init to add the stats, and the\n * `get` method will return the final tally. The resulting `InitSummary` object can be used in the `formatInitSummary`\n * helper to convert it to a string for the user.\n *\n * The `getMissingExportsMessage` method can be used to check that the imports/exports of packages match.\n */\nexport class InitSummaryData {\n private _packageResults: Record<string, InitPackageResult>;\n private _generatedUpdates: Record<string, GeneratedPackageChanges>;\n private _startTime: number;\n private _appPath: string;\n\n constructor(appPath: string) {\n this._packageResults = {};\n this._generatedUpdates = {};\n this._startTime = Date.now();\n this._appPath = appPath;\n }\n\n /**\n * Saves a package result.\n */\n public recordResult(result: InitPackageResult): void {\n this._packageResults[result.path] = result;\n }\n\n /**\n * Record more errors for a given package path.\n */\n public addErrors(packagePath: string, errors: BundleMessage[]): void {\n const packageResult = this._packageResults[packagePath];\n if (!packageResult) {\n throw new Error(`Package result not found for path ${packagePath}`);\n }\n\n packageResult.errors = [...(packageResult.errors || []), ...errors];\n }\n\n /**\n * Returns the package results.\n * @returns The package results.\n */\n public getResults(): Record<string, InitPackageResult> {\n return this._packageResults;\n }\n\n /**\n * Saves a generated file update.\n * @param allChanges - The generated file update to save.\n * @returns void.\n */\n public recordGeneratedChanges(allChanges: GeneratedPackageChanges[]) {\n for (const update of allChanges) {\n const { name, version, path, changes } = update;\n const updatesForPackage = (this._generatedUpdates[path] ??= { name, version, path, changes: [] });\n\n updatesForPackage.changes.push(...changes);\n }\n }\n\n /**\n * Returns the summary of the results.\n * @returns The summary of the results.\n */\n public summarize(options: Pick<InitOptions, 'check'>): InitSummary {\n const duration = Date.now() - this._startTime;\n let totalSuccess = 0;\n let totalErrors = 0;\n let totalWarnings = 0;\n let totalChanges = 0;\n let totalRequiredChanges = 0;\n const packagesWithErrors: InitPackageResultErrors[] = [];\n const packagesWithWarnings: InitPackageResultWarnings[] = [];\n\n for (const packageResult of Object.values(this._packageResults)) {\n if (packageResult.errors?.length) {\n packagesWithErrors.push(packageResult as InitPackageResultErrors);\n totalErrors += packageResult.errors.length;\n } else {\n totalSuccess++;\n }\n\n if (packageResult.warnings?.length) {\n packagesWithWarnings.push(packageResult as InitPackageResultWarnings);\n totalWarnings += packageResult.warnings.length;\n }\n }\n\n const sortedUpdates = Object.values(this._generatedUpdates).sort((a, b) => a.path.localeCompare(b.path));\n\n for (const updates of sortedUpdates) {\n totalChanges += updates.changes.length;\n totalRequiredChanges += updates.changes.filter((u) => requiredChangeTypes.includes(u.type)).length;\n updates.changes = updates.changes.sort((a, b) => a.change.localeCompare(b.change));\n }\n\n return {\n appPath: this._appPath,\n duration,\n totalPackages: Object.keys(this._packageResults).length,\n totalSuccess,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n failed: totalErrors > 0 || (!!options.check && totalRequiredChanges > 0),\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates: sortedUpdates,\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateImportsForOverrides.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,
|
|
1
|
+
{"version":3,"file":"evaluateImportsForOverrides.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,WAAW,EAEZ,MAAM,4BAA4B,CAAC;AAMpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAUlE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAMlF;;;GAGG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,sBAAsB,GAAG,SAAS,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC;IACV,kDAAkD;IAClD,cAAc,EAAE,uBAAuB,EAAE,CAAC;IAC1C,iEAAiE;IACjE,2BAA2B,EAAE,uBAAuB,EAAE,CAAC;IACvD,6BAA6B;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,6BAA6B;IAC7B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC;IACjE,6FAA6F;IAC7F,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC,CA0QD"}
|
|
@@ -23,6 +23,7 @@ export async function evaluateImportsForOverrides(options) {
|
|
|
23
23
|
const pathsToEvaluate = new Map();
|
|
24
24
|
const pathsToRefresh = new Set();
|
|
25
25
|
const dependencies = getDependencies(definition);
|
|
26
|
+
// TODO: this line will return nothing due to https://github.com/microsoft/cloudpack/issues/2389, https://github.com/microsoft/cloudpack/issues/2391
|
|
26
27
|
const unusedDependencies = getUnusedDependencies(definition);
|
|
27
28
|
const consumedPaths = getConsumedPaths(info);
|
|
28
29
|
const userExcludedDependencies = getPackageSettings({
|
|
@@ -40,6 +41,7 @@ export async function evaluateImportsForOverrides(options) {
|
|
|
40
41
|
}
|
|
41
42
|
// Check if we can resolve the dependency.
|
|
42
43
|
// If we included or removed an excluded dependency, we need to ensure it is in the resolve map.
|
|
44
|
+
// TODO: this is somewhat broken https://github.com/microsoft/cloudpack/issues/2390
|
|
43
45
|
const { dependencyPath, updatedResolution } = await ensureResolveMapEntry({
|
|
44
46
|
definition,
|
|
45
47
|
packagePath,
|
|
@@ -58,6 +60,7 @@ export async function evaluateImportsForOverrides(options) {
|
|
|
58
60
|
if (!dependencies[dependencyName] && dependencyName !== definition.name && !neverExclude(dependencyName, config)) {
|
|
59
61
|
// Survive from the case where it is not a dependency in the package.json
|
|
60
62
|
// and it is resolvable, but warn the user.
|
|
63
|
+
// TODO: this won't work as expected due to https://github.com/microsoft/cloudpack/issues/2391
|
|
61
64
|
if (!unusedDependencies[dependencyName]) {
|
|
62
65
|
warnings.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'undeclared', packagePath }));
|
|
63
66
|
}
|
|
@@ -164,10 +167,12 @@ export async function evaluateImportsForOverrides(options) {
|
|
|
164
167
|
// Since dependencyImportPath is used (and presently set to null),
|
|
165
168
|
// and since we now know it has a corresponding export,
|
|
166
169
|
// delete it from generatePackageSettings.exports so it doesn't get dropped from the bundle
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
let deleteSucceeded = false;
|
|
171
|
+
if (dependencyGeneratedPackageSettings.exports &&
|
|
172
|
+
dependencyImportPath in dependencyGeneratedPackageSettings.exports) {
|
|
173
|
+
deleteSucceeded = true;
|
|
174
|
+
delete dependencyGeneratedPackageSettings.exports[dependencyImportPath];
|
|
175
|
+
}
|
|
171
176
|
if (deleteSucceeded) {
|
|
172
177
|
// If there was actually an export to delete, mark this path for re-evaluation.
|
|
173
178
|
pathsToRefresh.add(dependencyPath);
|
|
@@ -221,14 +226,6 @@ export async function evaluateImportsForOverrides(options) {
|
|
|
221
226
|
}
|
|
222
227
|
return { exportsChanges, includedDependenciesChanges, errors, warnings, pathsToEvaluate, pathsToRefresh };
|
|
223
228
|
}
|
|
224
|
-
function deleteExport(exports, key) {
|
|
225
|
-
let deleteSucceeded = false;
|
|
226
|
-
if (exports) {
|
|
227
|
-
deleteSucceeded = key in exports;
|
|
228
|
-
delete exports[key];
|
|
229
|
-
}
|
|
230
|
-
return deleteSucceeded;
|
|
231
|
-
}
|
|
232
229
|
function getMissingDepMessage(params) {
|
|
233
230
|
const { dependencyName, displayName, issueType, packagePath } = params;
|
|
234
231
|
let text;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateImportsForOverrides.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,iCAAiC,EACjC,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,OAUjD;IAcC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAA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AAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAC5G,CAAC;AAED,SAAS,YAAY,CAAC,OAA6C,EAAE,GAAW;IAC9E,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI,OAAO,EAAE,CAAC;QACZ,eAAe,GAAG,GAAG,IAAI,OAAO,CAAC;QACjC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,SAAS,oBAAoB,CAAC,MAK7B;IACC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEvE,IAAI,IAAY,CAAC;IACjB,IAAI,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;QAC9B,IAAI;YACF,sBAAsB,cAAc,2BAA2B,WAAW,KAAK;gBAC/E,2EAA2E;gBAC3E,iCAAiC,WAAW,oDAAoD;gBAChG,sDAAsD,CAAC;IAC3D,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,gBAAgB,cAAc,qBAAqB,WAAW,UACnE,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,iDACvD,yBAAyB,cAAc,uCAAuC,WAAW,IACvF,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,6CAA6C,WAAW,wBAAwB,CAAC,CAAC,CAAC,EAClH,GAAG,CAAC;IACN,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,kBAAkB;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE;KAC3D,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleInfo } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\n CloudpackConfig,\n PackageDefinitionsCache,\n PackageImporterContext,\n PackageJson,\n PackageJsonExportsObject,\n GeneratedPackageSettings,\n} from '@ms-cloudpack/common-types';\nimport {\n ensureGeneratedSettingsForPackage,\n getGeneratedPackageSettings,\n getPackageSettings,\n} from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport {\n addExportsMapEntry,\n ensureResolveMapEntry,\n flattenExportsMap,\n getDependencies,\n getUnusedDependencies,\n getExportsMap,\n} from '@ms-cloudpack/package-utilities';\nimport { bulletedList, cyan } from '@ms-cloudpack/task-reporter';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { isBuiltin } from 'module';\nimport { getConsumedPaths } from '@ms-cloudpack/api-server';\nimport { neverExclude } from './neverExclude.js';\nimport path from 'path';\n\n/**\n * Evaluate the imports depended on by a package to determine if missing exports map paths need to be added.\n * If so, updates package overrides in the config.\n */\nexport async function evaluateImportsForOverrides(options: {\n packages: PackageDefinitionsCache;\n info: BundleInfo;\n definition: PackageJson;\n packagePath: string;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n importerContext: PackageImporterContext | undefined;\n appPath: string;\n}): Promise<{\n /** Export changes made to the generated config */\n exportsChanges: GeneratedPackageChanges[];\n /** Included dependencies changes made to the generated config */\n includedDependenciesChanges: GeneratedPackageChanges[];\n /** Any errors encountered */\n errors: BundleMessage[];\n /** Any warnings generated */\n warnings: BundleMessage[];\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh: Set<string>;\n}> {\n const { packages, info, definition, packagePath, config, resolveMap, importerContext, appPath } = options;\n\n const { name: packageName, version: packageVersion } = definition;\n const displayName = `${packageName}@${packageVersion}`;\n if (!packageName || !packageVersion) {\n throw new Error(`Package \"${displayName}\" is missing a name or version.`);\n }\n\n const exportsChanges: GeneratedPackageChanges[] = [];\n const includedDependenciesChanges: GeneratedPackageChanges[] = [];\n const errors: BundleMessage[] = [];\n const warnings: BundleMessage[] = [];\n const pathsToEvaluate = new Map<string, PackageImporterContext | undefined>();\n const pathsToRefresh = new Set<string>();\n const dependencies = getDependencies(definition);\n const unusedDependencies = getUnusedDependencies(definition);\n const consumedPaths = getConsumedPaths(info);\n const userExcludedDependencies = getPackageSettings({\n name: packageName,\n version: packageVersion,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: undefined,\n }).userPackageSettings?.excludedDependencies;\n\n let generatedPackageSettings: GeneratedPackageSettings | undefined;\n\n // Iterate through imports and find their path from the resolve map.\n for (const [dependencyName, dependencyImportPaths] of Object.entries(consumedPaths)) {\n // If the dependency is excluded in the user settings, entirely ignore it.\n if (userExcludedDependencies?.includes(dependencyName)) {\n continue;\n }\n\n // Check if we can resolve the dependency.\n // If we included or removed an excluded dependency, we need to ensure it is in the resolve map.\n const { dependencyPath, updatedResolution } = await ensureResolveMapEntry(\n {\n definition,\n packagePath,\n dependencyName,\n resolveMap,\n appPath,\n },\n { packages },\n );\n\n // If the dependency is not resolved, add an error.\n if (!dependencyPath) {\n errors.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'not-found', packagePath }));\n // If the dependency is not resolved, we can't continue to evaluate it.\n continue;\n }\n\n const dependencyDefinition = await packages.get(dependencyPath);\n\n // If the dependency is not listed, add to includedDependencies.\n if (!dependencies[dependencyName] && dependencyName !== definition.name && !neverExclude(dependencyName, config)) {\n // Survive from the case where it is not a dependency in the package.json\n // and it is resolvable, but warn the user.\n if (!unusedDependencies[dependencyName]) {\n warnings.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'undeclared', packagePath }));\n }\n // Make sure to add the package to the list of packages to evaluate.\n pathsToEvaluate.set(packagePath, importerContext);\n\n // Add to includedDependencies if appropriate.\n generatedPackageSettings ??= await ensureGeneratedSettingsForPackage({ packagePath }, { config, packages });\n\n // We can skip including the dependency if it is already excluded.\n // This will be handled later during optimize dependencies.\n const handledByOptimize = generatedPackageSettings.excludedDependencies?.includes(dependencyName);\n\n // Add to includedDependencies if it is not already included.\n if (!handledByOptimize && !generatedPackageSettings.includedDependencies?.includes(dependencyName)) {\n generatedPackageSettings.includedDependencies ??= [];\n generatedPackageSettings.includedDependencies.push(dependencyName);\n\n includedDependenciesChanges.push({\n name: packageName,\n version: packageVersion,\n path: packagePath,\n changes: [\n {\n type: `included-dependency${updatedResolution ? '-required' : '-optional'}`,\n change: dependencyName,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n }\n }\n\n const { version } = dependencyDefinition;\n\n // Ensure we use the correct context when evaluating this dependency.\n let dependencyImporterContext: PackageImporterContext | undefined;\n if (dependencyName === packageName) {\n // Self-import (we may still need to evaluate the paths). Use the importer context from options.\n dependencyImporterContext = importerContext;\n } else if (dependencies[dependencyName]) {\n dependencyImporterContext = {\n parentName: packageName,\n parentVersion: packageVersion,\n importedName: dependencyName,\n versionRequirement: dependencies[dependencyName],\n };\n }\n\n // Add the dependency to the list of packages to evaluate.\n pathsToEvaluate.set(dependencyPath, dependencyImporterContext);\n\n // A flattened, bundle-able exports map for this dependency, which is \"built up\" over the course of bundling.\n const workingDependencyExportsList = flattenExportsMap(\n await getExportsMap({ packagePath: dependencyPath }, { packages, config }),\n );\n // The official list of exports claimed by this dependency -- used to determine which exports are never used, so we can drop them.\n const canonicalDependencyExports = flattenExportsMap(\n await getExportsMap({ packagePath: dependencyPath, disableTransforms: true }, { packages, config }),\n );\n\n const initiallyNullExports = getGeneratedPackageSettings({\n name: dependencyName,\n version,\n // Use the generated snapshot to get the previous package settings.\n generatedPackageSettings: config.generatedSnapshot?.packageSettings,\n })?.exports as Record<string, unknown>;\n\n let dependencyGeneratedPackageSettings: GeneratedPackageSettings | undefined;\n // iterate through all the import paths.\n for (const dependencyImportPath of dependencyImportPaths) {\n // Imports from paths with trailing slashes are not supported in the exports map.\n if (dependencyImportPath.endsWith('/')) {\n errors.push({\n text: `The import path \"${dependencyImportPath}\" from \"${dependencyName}\" has a trailing slash, which is not supported.`,\n source: 'evaluate imports',\n location: { file: packagePath },\n });\n continue;\n }\n\n if (!config.features?.removeUnusedExports) {\n const dependencyAlreadyBundled = workingDependencyExportsList[dependencyImportPath];\n if (dependencyAlreadyBundled) {\n continue;\n }\n }\n\n if (!dependencyGeneratedPackageSettings) {\n // Start with the package's exports all set to null (indicating they are never imported)\n // If this changes, we'll update the generatedPackageSetting accordingly later.\n const nullifiedExports = config.features?.removeUnusedExports\n ? Object.fromEntries(Object.keys(canonicalDependencyExports).map((k) => [k, null]))\n : {};\n\n dependencyGeneratedPackageSettings = await ensureGeneratedSettingsForPackage(\n {\n packagePath: dependencyPath,\n defaultExportsMap: Object.keys(nullifiedExports).length > 0 ? nullifiedExports : undefined,\n },\n { config, packages },\n );\n }\n\n if (config.features?.removeUnusedExports) {\n const importHasCorrespondingExport = !!canonicalDependencyExports[dependencyImportPath];\n if (importHasCorrespondingExport) {\n // We're about to remove a null export. Before we do, check if it was initially null in\n // the generated config; if so, we need to track the change so that --check exits correctly\n if (dependencyImportPath in (initiallyNullExports || {})) {\n exportsChanges.push({\n name: dependencyName,\n version: dependencyDefinition.version,\n path: dependencyPath,\n changes: [\n {\n type: 'changed-export',\n change: dependencyImportPath,\n reason: `\"${dependencyImportPath}\" was previously an unused export; is now used.`,\n },\n ],\n });\n }\n\n // Since dependencyImportPath is used (and presently set to null),\n // and since we now know it has a corresponding export,\n // delete it from generatePackageSettings.exports so it doesn't get dropped from the bundle\n const deleteSucceeded = deleteExport(\n // Even though PackageJsonExports can \"technically\" be an object or an array, we never expect\n // it to be an array when it comes from generatedPackageSettings\n dependencyGeneratedPackageSettings.exports as PackageJsonExportsObject,\n dependencyImportPath,\n );\n\n if (deleteSucceeded) {\n // If there was actually an export to delete, mark this path for re-evaluation.\n pathsToRefresh.add(dependencyPath);\n\n // Delete the entire exports key if it now has zero entries\n if (Object.keys(dependencyGeneratedPackageSettings.exports ?? {}).length === 0) {\n delete dependencyGeneratedPackageSettings.exports;\n }\n }\n continue;\n }\n }\n\n const dependencyAlreadyBundled = workingDependencyExportsList[dependencyImportPath];\n if (dependencyAlreadyBundled) {\n continue;\n }\n\n dependencyGeneratedPackageSettings.exports ??= {};\n\n const addedEntry = await addExportsMapEntry(\n {\n exports: dependencyGeneratedPackageSettings.exports,\n packagePath: dependencyPath,\n importPath: dependencyImportPath,\n },\n { packages, config },\n );\n\n if (addedEntry) {\n exportsChanges.push({\n name: dependencyName,\n version: dependencyDefinition.version,\n path: dependencyPath,\n changes: [\n {\n type: 'added-export',\n change: dependencyImportPath,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n\n // Since we've found a missing export, we need to re-enqueue the dependency for evaluation.\n pathsToRefresh.add(dependencyPath);\n } else {\n const text =\n `An import couldn't be resolved to a physical file. ` +\n `Check that the import refers to a file that's exported by the package or adjust the \"${cyan(\n dependencyName,\n )}\" package version to one that supports this import path.\\n${bulletedList(\n [\n `Import: ${cyan(dependencyImportPath.replace('.', dependencyName))}`,\n `Resolved to: ${dependencyName}@${version} (${dependencyImportPath})`,\n ],\n 2,\n )}`;\n errors.push({\n text,\n source: 'evaluate imports',\n location: { file: packagePath },\n });\n }\n }\n }\n\n return { exportsChanges, includedDependenciesChanges, errors, warnings, pathsToEvaluate, pathsToRefresh };\n}\n\nfunction deleteExport(exports: PackageJsonExportsObject | undefined, key: string): boolean {\n let deleteSucceeded = false;\n if (exports) {\n deleteSucceeded = key in exports;\n delete exports[key];\n }\n return deleteSucceeded;\n}\n\nfunction getMissingDepMessage(params: {\n dependencyName: string;\n displayName: string;\n issueType: 'not-found' | 'undeclared';\n packagePath: string;\n}): BundleMessage {\n const { dependencyName, displayName, issueType, packagePath } = params;\n\n let text: string;\n if (isBuiltin(dependencyName)) {\n text =\n `The node built-in \"${dependencyName}\" is being imported by \"${displayName}\", ` +\n `but no browser-friendly version was found in the package's dependencies. ` +\n `This can be fixed by forcing \"${displayName}\" to use \"bundler\": \"rollup\" in package settings, ` +\n `or by adding a polyfill browser-friendly dependency.`;\n } else {\n text = `The package \"${dependencyName}\" is imported by \"${displayName}\", but ${\n issueType === 'not-found' ? \"it couldn't be found\" : \"it's not included in the package's dependencies\"\n }. Please ensure that \"${dependencyName}\" is listed in the dependencies of \"${displayName}\"${\n issueType === 'undeclared' ? ` or add it to \"includedDependencies\" for \"${displayName}\" in package settings.` : ''\n }.`;\n }\n\n return {\n text,\n source: 'evaluate imports',\n location: { file: path.join(packagePath, 'package.json') },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"evaluateImportsForOverrides.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AASA,OAAO,EACL,iCAAiC,EACjC,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,OAUjD;IAcC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE1G,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;IAClE,MAAM,WAAW,GAAG,GAAG,WAAW,IAAI,cAAc,EAAE,CAAC;IACvD,IAAI,CAAC,WAAW,IAAI,CAAC,cAAc,EAAE,CAA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,EAAE,CAAC;AAC5G,CAAC;AAED,SAAS,oBAAoB,CAAC,MAK7B;IACC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEvE,IAAI,IAAY,CAAC;IACjB,IAAI,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC;QAC9B,IAAI;YACF,sBAAsB,cAAc,2BAA2B,WAAW,KAAK;gBAC/E,2EAA2E;gBAC3E,iCAAiC,WAAW,oDAAoD;gBAChG,sDAAsD,CAAC;IAC3D,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,gBAAgB,cAAc,qBAAqB,WAAW,UACnE,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,iDACvD,yBAAyB,cAAc,uCAAuC,WAAW,IACvF,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,6CAA6C,WAAW,wBAAwB,CAAC,CAAC,CAAC,EAClH,GAAG,CAAC;IACN,CAAC;IAED,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,kBAAkB;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE;KAC3D,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleInfo } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\n CloudpackConfig,\n PackageDefinitionsCache,\n PackageImporterContext,\n PackageJson,\n GeneratedPackageSettings,\n} from '@ms-cloudpack/common-types';\nimport {\n ensureGeneratedSettingsForPackage,\n getGeneratedPackageSettings,\n getPackageSettings,\n} from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport {\n addExportsMapEntry,\n ensureResolveMapEntry,\n flattenExportsMap,\n getDependencies,\n getUnusedDependencies,\n getExportsMap,\n} from '@ms-cloudpack/package-utilities';\nimport { bulletedList, cyan } from '@ms-cloudpack/task-reporter';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { isBuiltin } from 'module';\nimport { getConsumedPaths } from '@ms-cloudpack/api-server';\nimport { neverExclude } from './neverExclude.js';\nimport path from 'path';\n\n/**\n * Evaluate the imports depended on by a package to determine if missing exports map paths need to be added.\n * If so, updates package overrides in the config.\n */\nexport async function evaluateImportsForOverrides(options: {\n packages: PackageDefinitionsCache;\n info: BundleInfo;\n definition: PackageJson;\n packagePath: string;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n importerContext: PackageImporterContext | undefined;\n appPath: string;\n}): Promise<{\n /** Export changes made to the generated config */\n exportsChanges: GeneratedPackageChanges[];\n /** Included dependencies changes made to the generated config */\n includedDependenciesChanges: GeneratedPackageChanges[];\n /** Any errors encountered */\n errors: BundleMessage[];\n /** Any warnings generated */\n warnings: BundleMessage[];\n /** Map from new package path (to be evaluated) to info about the parent. */\n pathsToEvaluate: Map<string, PackageImporterContext | undefined>;\n /** Package paths for which new exports were added, so the package should be re-processed. */\n pathsToRefresh: Set<string>;\n}> {\n const { packages, info, definition, packagePath, config, resolveMap, importerContext, appPath } = options;\n\n const { name: packageName, version: packageVersion } = definition;\n const displayName = `${packageName}@${packageVersion}`;\n if (!packageName || !packageVersion) {\n throw new Error(`Package \"${displayName}\" is missing a name or version.`);\n }\n\n const exportsChanges: GeneratedPackageChanges[] = [];\n const includedDependenciesChanges: GeneratedPackageChanges[] = [];\n const errors: BundleMessage[] = [];\n const warnings: BundleMessage[] = [];\n const pathsToEvaluate = new Map<string, PackageImporterContext | undefined>();\n const pathsToRefresh = new Set<string>();\n const dependencies = getDependencies(definition);\n // TODO: this line will return nothing due to https://github.com/microsoft/cloudpack/issues/2389, https://github.com/microsoft/cloudpack/issues/2391\n const unusedDependencies = getUnusedDependencies(definition);\n const consumedPaths = getConsumedPaths(info);\n const userExcludedDependencies = getPackageSettings({\n name: packageName,\n version: packageVersion,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: undefined,\n }).userPackageSettings?.excludedDependencies;\n\n let generatedPackageSettings: GeneratedPackageSettings | undefined;\n\n // Iterate through imports and find their path from the resolve map.\n for (const [dependencyName, dependencyImportPaths] of Object.entries(consumedPaths)) {\n // If the dependency is excluded in the user settings, entirely ignore it.\n if (userExcludedDependencies?.includes(dependencyName)) {\n continue;\n }\n\n // Check if we can resolve the dependency.\n // If we included or removed an excluded dependency, we need to ensure it is in the resolve map.\n // TODO: this is somewhat broken https://github.com/microsoft/cloudpack/issues/2390\n const { dependencyPath, updatedResolution } = await ensureResolveMapEntry(\n {\n definition,\n packagePath,\n dependencyName,\n resolveMap,\n appPath,\n },\n { packages },\n );\n\n // If the dependency is not resolved, add an error.\n if (!dependencyPath) {\n errors.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'not-found', packagePath }));\n // If the dependency is not resolved, we can't continue to evaluate it.\n continue;\n }\n\n const dependencyDefinition = await packages.get(dependencyPath);\n\n // If the dependency is not listed, add to includedDependencies.\n if (!dependencies[dependencyName] && dependencyName !== definition.name && !neverExclude(dependencyName, config)) {\n // Survive from the case where it is not a dependency in the package.json\n // and it is resolvable, but warn the user.\n // TODO: this won't work as expected due to https://github.com/microsoft/cloudpack/issues/2391\n if (!unusedDependencies[dependencyName]) {\n warnings.push(getMissingDepMessage({ dependencyName, displayName, issueType: 'undeclared', packagePath }));\n }\n // Make sure to add the package to the list of packages to evaluate.\n pathsToEvaluate.set(packagePath, importerContext);\n\n // Add to includedDependencies if appropriate.\n generatedPackageSettings ??= await ensureGeneratedSettingsForPackage({ packagePath }, { config, packages });\n\n // We can skip including the dependency if it is already excluded.\n // This will be handled later during optimize dependencies.\n const handledByOptimize = generatedPackageSettings.excludedDependencies?.includes(dependencyName);\n\n // Add to includedDependencies if it is not already included.\n if (!handledByOptimize && !generatedPackageSettings.includedDependencies?.includes(dependencyName)) {\n generatedPackageSettings.includedDependencies ??= [];\n generatedPackageSettings.includedDependencies.push(dependencyName);\n\n includedDependenciesChanges.push({\n name: packageName,\n version: packageVersion,\n path: packagePath,\n changes: [\n {\n type: `included-dependency${updatedResolution ? '-required' : '-optional'}`,\n change: dependencyName,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n }\n }\n\n const { version } = dependencyDefinition;\n\n // Ensure we use the correct context when evaluating this dependency.\n let dependencyImporterContext: PackageImporterContext | undefined;\n if (dependencyName === packageName) {\n // Self-import (we may still need to evaluate the paths). Use the importer context from options.\n dependencyImporterContext = importerContext;\n } else if (dependencies[dependencyName]) {\n dependencyImporterContext = {\n parentName: packageName,\n parentVersion: packageVersion,\n importedName: dependencyName,\n versionRequirement: dependencies[dependencyName],\n };\n }\n\n // Add the dependency to the list of packages to evaluate.\n pathsToEvaluate.set(dependencyPath, dependencyImporterContext);\n\n // A flattened, bundle-able exports map for this dependency, which is \"built up\" over the course of bundling.\n const workingDependencyExportsList = flattenExportsMap(\n await getExportsMap({ packagePath: dependencyPath }, { packages, config }),\n );\n // The official list of exports claimed by this dependency -- used to determine which exports are never used, so we can drop them.\n const canonicalDependencyExports = flattenExportsMap(\n await getExportsMap({ packagePath: dependencyPath, disableTransforms: true }, { packages, config }),\n );\n\n const initiallyNullExports = getGeneratedPackageSettings({\n name: dependencyName,\n version,\n // Use the generated snapshot to get the previous package settings.\n generatedPackageSettings: config.generatedSnapshot?.packageSettings,\n })?.exports;\n\n let dependencyGeneratedPackageSettings: GeneratedPackageSettings | undefined;\n // iterate through all the import paths.\n for (const dependencyImportPath of dependencyImportPaths) {\n // Imports from paths with trailing slashes are not supported in the exports map.\n if (dependencyImportPath.endsWith('/')) {\n errors.push({\n text: `The import path \"${dependencyImportPath}\" from \"${dependencyName}\" has a trailing slash, which is not supported.`,\n source: 'evaluate imports',\n location: { file: packagePath },\n });\n continue;\n }\n\n if (!config.features?.removeUnusedExports) {\n const dependencyAlreadyBundled = workingDependencyExportsList[dependencyImportPath];\n if (dependencyAlreadyBundled) {\n continue;\n }\n }\n\n if (!dependencyGeneratedPackageSettings) {\n // Start with the package's exports all set to null (indicating they are never imported)\n // If this changes, we'll update the generatedPackageSetting accordingly later.\n const nullifiedExports = config.features?.removeUnusedExports\n ? Object.fromEntries(Object.keys(canonicalDependencyExports).map((k) => [k, null]))\n : {};\n\n dependencyGeneratedPackageSettings = await ensureGeneratedSettingsForPackage(\n {\n packagePath: dependencyPath,\n defaultExportsMap: Object.keys(nullifiedExports).length > 0 ? nullifiedExports : undefined,\n },\n { config, packages },\n );\n }\n\n if (config.features?.removeUnusedExports) {\n const importHasCorrespondingExport = !!canonicalDependencyExports[dependencyImportPath];\n if (importHasCorrespondingExport) {\n // We're about to remove a null export. Before we do, check if it was initially null in\n // the generated config; if so, we need to track the change so that --check exits correctly\n if (dependencyImportPath in (initiallyNullExports || {})) {\n exportsChanges.push({\n name: dependencyName,\n version: dependencyDefinition.version,\n path: dependencyPath,\n changes: [\n {\n type: 'changed-export',\n change: dependencyImportPath,\n reason: `\"${dependencyImportPath}\" was previously an unused export; is now used.`,\n },\n ],\n });\n }\n\n // Since dependencyImportPath is used (and presently set to null),\n // and since we now know it has a corresponding export,\n // delete it from generatePackageSettings.exports so it doesn't get dropped from the bundle\n let deleteSucceeded = false;\n if (\n dependencyGeneratedPackageSettings.exports &&\n dependencyImportPath in dependencyGeneratedPackageSettings.exports\n ) {\n deleteSucceeded = true;\n delete dependencyGeneratedPackageSettings.exports[dependencyImportPath];\n }\n\n if (deleteSucceeded) {\n // If there was actually an export to delete, mark this path for re-evaluation.\n pathsToRefresh.add(dependencyPath);\n\n // Delete the entire exports key if it now has zero entries\n if (Object.keys(dependencyGeneratedPackageSettings.exports ?? {}).length === 0) {\n delete dependencyGeneratedPackageSettings.exports;\n }\n }\n continue;\n }\n }\n\n const dependencyAlreadyBundled = workingDependencyExportsList[dependencyImportPath];\n if (dependencyAlreadyBundled) {\n continue;\n }\n\n dependencyGeneratedPackageSettings.exports ??= {};\n\n const addedEntry = await addExportsMapEntry(\n {\n exports: dependencyGeneratedPackageSettings.exports,\n packagePath: dependencyPath,\n importPath: dependencyImportPath,\n },\n { packages, config },\n );\n\n if (addedEntry) {\n exportsChanges.push({\n name: dependencyName,\n version: dependencyDefinition.version,\n path: dependencyPath,\n changes: [\n {\n type: 'added-export',\n change: dependencyImportPath,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n\n // Since we've found a missing export, we need to re-enqueue the dependency for evaluation.\n pathsToRefresh.add(dependencyPath);\n } else {\n const text =\n `An import couldn't be resolved to a physical file. ` +\n `Check that the import refers to a file that's exported by the package or adjust the \"${cyan(\n dependencyName,\n )}\" package version to one that supports this import path.\\n${bulletedList(\n [\n `Import: ${cyan(dependencyImportPath.replace('.', dependencyName))}`,\n `Resolved to: ${dependencyName}@${version} (${dependencyImportPath})`,\n ],\n 2,\n )}`;\n errors.push({\n text,\n source: 'evaluate imports',\n location: { file: packagePath },\n });\n }\n }\n }\n\n return { exportsChanges, includedDependenciesChanges, errors, warnings, pathsToEvaluate, pathsToRefresh };\n}\n\nfunction getMissingDepMessage(params: {\n dependencyName: string;\n displayName: string;\n issueType: 'not-found' | 'undeclared';\n packagePath: string;\n}): BundleMessage {\n const { dependencyName, displayName, issueType, packagePath } = params;\n\n let text: string;\n if (isBuiltin(dependencyName)) {\n text =\n `The node built-in \"${dependencyName}\" is being imported by \"${displayName}\", ` +\n `but no browser-friendly version was found in the package's dependencies. ` +\n `This can be fixed by forcing \"${displayName}\" to use \"bundler\": \"rollup\" in package settings, ` +\n `or by adding a polyfill browser-friendly dependency.`;\n } else {\n text = `The package \"${dependencyName}\" is imported by \"${displayName}\", but ${\n issueType === 'not-found' ? \"it couldn't be found\" : \"it's not included in the package's dependencies\"\n }. Please ensure that \"${dependencyName}\" is listed in the dependencies of \"${displayName}\"${\n issueType === 'undeclared' ? ` or add it to \"includedDependencies\" for \"${displayName}\" in package settings.` : ''\n }.`;\n }\n\n return {\n text,\n source: 'evaluate imports',\n location: { file: path.join(packagePath, 'package.json') },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatInitSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"formatInitSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK1D,UAAU,uBAAuB;IAC/B,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,UAUhE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bold, bulletedList, cyan, formatTime, green, indent, lightCyan, plural, red, statusCharacter, yellow, } from '@ms-cloudpack/task-reporter';
|
|
2
2
|
import { formatLocation } from '@ms-cloudpack/path-utilities';
|
|
3
|
+
import { requiredChangeTypes } from './types/GeneratedChange.js';
|
|
3
4
|
/**
|
|
4
5
|
* Given init summaries and init options, returns a formatted string message to display to the user via console.
|
|
5
6
|
*/
|
|
@@ -23,14 +24,14 @@ function formatSummary(params) {
|
|
|
23
24
|
if ((!packagesWithErrors.length && !packagesWithWarnings.length) || isMultiApp) {
|
|
24
25
|
summaryString.push(bold(`==== Summary for ${summary.appPath}${incompleteText} ====`));
|
|
25
26
|
}
|
|
27
|
+
// If there are required changes, updates will be "made" or "needed" with check,
|
|
28
|
+
// else if the changes are not required, only report work done when updates are "made" (check is disabled).
|
|
29
|
+
const updatesRequired = totalRequiredChanges || (totalChanges && !check);
|
|
30
|
+
// Report updates that were or should be added to the generated config.
|
|
31
|
+
if (!packagesWithErrors.length && updatesRequired) {
|
|
32
|
+
summaryString.push(formatPackageUpdates({ generatedFileUpdates, check, isMultiApp }));
|
|
33
|
+
}
|
|
26
34
|
if (!isMultiApp) {
|
|
27
|
-
// If there are required changes, updates will be "made" or "needed" with check,
|
|
28
|
-
// else if the changes are not required, only report work done when updates are "made" (check is disabled).
|
|
29
|
-
const updatesRequired = totalRequiredChanges || (totalChanges && !check);
|
|
30
|
-
// Report updates that were or should be added to the generated config.
|
|
31
|
-
if (!packagesWithErrors.length && updatesRequired) {
|
|
32
|
-
summaryString.push(formatPackageUpdates({ generatedFileUpdates, check }));
|
|
33
|
-
}
|
|
34
35
|
// Report packages with warnings.
|
|
35
36
|
if (packagesWithWarnings.length) {
|
|
36
37
|
summaryString.push(formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' }), '');
|
|
@@ -64,27 +65,27 @@ function formatSummary(params) {
|
|
|
64
65
|
return summaryString.join('\n');
|
|
65
66
|
}
|
|
66
67
|
function formatPackageUpdates(params) {
|
|
67
|
-
const { generatedFileUpdates, check, isInterrupted } = params;
|
|
68
|
+
const { generatedFileUpdates, check, isInterrupted, isMultiApp } = params;
|
|
68
69
|
// If we already made the updates, don't make them look like warnings.
|
|
69
70
|
const type = check ? 'warn' : 'add';
|
|
70
71
|
const summaryString = [];
|
|
71
72
|
for (const packageUpdates of generatedFileUpdates) {
|
|
72
|
-
const exportsUpdates =
|
|
73
|
+
const exportsUpdates = getChangesToShow({ type: 'added-export', packageUpdates, isMultiApp });
|
|
73
74
|
if (exportsUpdates.length) {
|
|
74
75
|
const description = plural(exportsUpdates.length, `path$s ${check ? 'missing from' : 'added to'} exports map`);
|
|
75
76
|
summaryString.push(formatPackageHeader({ ...packageUpdates, issueType: type, description }), bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)), '');
|
|
76
77
|
}
|
|
77
|
-
const includedDependencies =
|
|
78
|
+
const includedDependencies = getChangesToShow({ type: 'included-dependency-required', packageUpdates, isMultiApp });
|
|
78
79
|
if (includedDependencies.length) {
|
|
79
80
|
const description = plural(includedDependencies.length, 'dependency$s required to be included');
|
|
80
81
|
summaryString.push(formatPackageHeader({ ...packageUpdates, issueType: type, description }), bulletedList(includedDependencies.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)), '');
|
|
81
82
|
}
|
|
82
|
-
const changedExports =
|
|
83
|
+
const changedExports = getChangesToShow({ type: 'changed-export', packageUpdates, isMultiApp });
|
|
83
84
|
if (changedExports.length) {
|
|
84
85
|
const description = plural(changedExports.length, 'previously unused export path$s are now used');
|
|
85
86
|
summaryString.push(formatPackageHeader({ ...packageUpdates, issueType: type, description }), bulletedList(changedExports.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)), '');
|
|
86
87
|
}
|
|
87
|
-
const dynamicImportsUpdates =
|
|
88
|
+
const dynamicImportsUpdates = getChangesToShow({ type: 'added-dynamic-import', packageUpdates, isMultiApp });
|
|
88
89
|
if (dynamicImportsUpdates.length) {
|
|
89
90
|
const description = plural(dynamicImportsUpdates.length, 'dynamic import$s added');
|
|
90
91
|
summaryString.push(formatPackageHeader({ ...packageUpdates, issueType: type, description }), bulletedList(dynamicImportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ``}`)), '');
|
|
@@ -95,6 +96,13 @@ function formatPackageUpdates(params) {
|
|
|
95
96
|
}
|
|
96
97
|
return summaryString.join('\n');
|
|
97
98
|
}
|
|
99
|
+
function getChangesToShow(params) {
|
|
100
|
+
const { packageUpdates, type, isMultiApp } = params;
|
|
101
|
+
if (isMultiApp && !requiredChangeTypes.includes(type)) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
return packageUpdates.changes.filter((u) => u.type === type);
|
|
105
|
+
}
|
|
98
106
|
/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */
|
|
99
107
|
function formatPackageResults(params) {
|
|
100
108
|
const { results, issueType } = params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,SAAS,EACT,MAAM,EACN,GAAG,EACH,eAAe,EACf,MAAM,GACP,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQ9D;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA+B;IAC/D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;IACrD,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACxC,OAAO,CACL,SAAS;SACN,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAC;SAChF,IAAI,CAAC,IAAI,CAAC;QACX,wCAAwC;SACvC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,0CAA0C;AAC1C,SAAS,aAAa,CACpB,MAGC;IAED,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC/D,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,MAAM,EACJ,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GACvB,GAAG,OAAO,CAAC;IACZ,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC1B,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,eA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AAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG;CAC1B,CAAC;AACF,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,eAAe,CAAC,KAAK;IAC5B,IAAI,EAAE,eAAe,CAAC,IAAI;IAC1B,GAAG,EAAE,GAAG;CACT,CAAC;AAEF;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,MAGC;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAC5E,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC;IAEzE,OAAO,GAAG,WAAW,MAAM,WAAW,KAAK,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;AACtF,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n formatTime,\n green,\n indent,\n lightCyan,\n plural,\n red,\n statusCharacter,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitPackageIdentifier } from './types/InitPackageIdentifier.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitSummary } from './types/InitSummary.js';\nimport { formatLocation } from '@ms-cloudpack/path-utilities';\n\ninterface FormatInitSummaryParams {\n summaries: InitSummary[];\n options: InitOptions;\n isInterrupted?: boolean;\n}\n\n/**\n * Given init summaries and init options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: FormatInitSummaryParams) {\n const { summaries, options, isInterrupted } = params;\n const isMultiApp = summaries.length > 1;\n return (\n summaries\n .map((summary) => formatSummary({ summary, options, isInterrupted, isMultiApp }))\n .join('\\n')\n // replace >= 3 newlines with 2 newlines\n .replace(/\\n{3,}/g, '\\n\\n')\n );\n}\n\n/** Format a single app's init summary. */\nfunction formatSummary(\n params: Pick<FormatInitSummaryParams, 'options' | 'isInterrupted'> & {\n summary: InitSummary;\n isMultiApp: boolean;\n },\n): string {\n const { summary, options, isInterrupted, isMultiApp } = params;\n const summaryString: string[] = [];\n\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\n deletedGeneratedConfig,\n } = summary;\n const { check } = options;\n const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;\n\n // Report the \"Summary\" title if no errors or warnings are listed (seems redundant otherwise.\n if ((!packagesWithErrors.length && !packagesWithWarnings.length) || isMultiApp) {\n summaryString.push(bold(`==== Summary for ${summary.appPath}${incompleteText} ====`));\n }\n\n if (!isMultiApp) {\n // If there are required changes, updates will be \"made\" or \"needed\" with check,\n // else if the changes are not required, only report work done when updates are \"made\" (check is disabled).\n const updatesRequired = totalRequiredChanges || (totalChanges && !check);\n\n // Report updates that were or should be added to the generated config.\n if (!packagesWithErrors.length && updatesRequired) {\n summaryString.push(formatPackageUpdates({ generatedFileUpdates, check }));\n }\n\n // Report packages with warnings.\n if (packagesWithWarnings.length) {\n summaryString.push(formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' }), '');\n }\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summaryString.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }), '');\n }\n\n if (deletedGeneratedConfig) {\n summaryString.push(`Deleted the ${cyan('cloudpack.generated.json')} file because it is no longer needed.`, '');\n }\n\n const blockingIssueCount = packagesWithErrors.length || 0;\n const requiresChanges = (check && totalRequiredChanges) || 0;\n\n // Add summary.\n summaryString.push(\n `${cyan(plural(totalPackages, 'total package'))} evaluated in ${formatTime(summary.duration)}${incompleteText}:`,\n bulletedList(\n [\n requiresChanges ? `${red(plural(totalRequiredChanges, 'change'))} required` : undefined,\n `${green(plural(totalPackages - blockingIssueCount, 'package'))} built successfully${\n packagesWithWarnings.length\n ? ` (${yellow(plural(packagesWithWarnings.length, 'package'))} with warnings)`\n : ''\n }`,\n blockingIssueCount ? `${red(plural(blockingIssueCount, 'package'))} failed to build` : undefined,\n `Totals: ${totalErrors ? red(plural(totalErrors, 'error')) : '0 errors'}, ${totalWarnings ? yellow(plural(totalWarnings, 'warning')) : '0 warnings'}`,\n ].filter(Boolean),\n ),\n );\n\n if (isInterrupted) {\n summaryString.push('', yellow(bold('Process was interrupted before all tasks could complete.')));\n } else if (requiresChanges) {\n summaryString.push(\n `Run \"${yellow('cloudpack init')}\" in your application folder to apply changes to the ${cyan(\n 'cloudpack.generated.json',\n )} file.`,\n );\n }\n\n summaryString.push('\\n');\n\n return summaryString.join('\\n');\n}\n\nfunction formatPackageUpdates(\n params: Pick<InitSummary, 'generatedFileUpdates'> &\n Pick<InitOptions, 'check'> &\n Pick<FormatInitSummaryParams, 'isInterrupted'>,\n) {\n const { generatedFileUpdates, check, isInterrupted } = params;\n // If we already made the updates, don't make them look like warnings.\n const type = check ? 'warn' : 'add';\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n const exportsUpdates = packageUpdates.changes.filter((u) => u.type === 'added-export');\n\n if (exportsUpdates.length) {\n const description = plural(exportsUpdates.length, `path$s ${check ? 'missing from' : 'added to'} exports map`);\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const includedDependencies = packageUpdates.changes.filter((u) => u.type === 'included-dependency-required');\n\n if (includedDependencies.length) {\n const description = plural(includedDependencies.length, 'dependency$s required to be included');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(includedDependencies.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const changedExports = packageUpdates.changes.filter((u) => u.type === 'changed-export');\n\n if (changedExports.length) {\n const description = plural(changedExports.length, 'previously unused export path$s are now used');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(changedExports.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const dynamicImportsUpdates = packageUpdates.changes.filter((u) => u.type === 'added-dynamic-import');\n\n if (dynamicImportsUpdates.length) {\n const description = plural(dynamicImportsUpdates.length, 'dynamic import$s added');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(dynamicImportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ``}`)),\n '',\n );\n }\n }\n\n if (summaryString.length) {\n summaryString.unshift(\n bold(`Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\\n`),\n );\n }\n return summaryString.join('\\n');\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'error' | 'warn' }) {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const color = colorsByType[issueType];\n const messageType = issueType === 'error' ? 'errors' : 'warnings';\n const statusChar = bold(color(statusCharacter[issueType]));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${messageType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[messageType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader({ ...result, issueType, description }));\n\n const messages = unformattedMessages.map(({ location, text, source }) => {\n // Show the whole path so it can be easily opened with ctrl+click.\n // NOTE: location.file should be relative to the package path, not the app path.\n const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';\n // Indent the message for readability.\n return `[${source}]${filePath}\\n${color(indent(text, 1))}`;\n });\n\n summaryString.push(bulletedList(messages, undefined, statusChar), '');\n }\n\n return summaryString.join('\\n');\n}\n\nconst colorsByType = {\n error: red,\n warn: yellow,\n add: (str: string) => str,\n};\nconst statusByType = {\n error: statusCharacter.error,\n warn: statusCharacter.warn,\n add: '+',\n};\n\n/**\n * Helper to format the header for a list of issues in a package:\n * status character, `name@version`, issue description, package path.\n */\nfunction formatPackageHeader(\n params: InitPackageIdentifier & {\n description: string;\n issueType: 'error' | 'warn' | 'add';\n },\n) {\n const { name, version, path: packagePath, description, issueType } = params;\n const color = colorsByType[issueType];\n const statusChar = bold(color(statusByType[issueType]));\n const packageName = bold(lightCyan(`${name}@${version || `<unknown>`}`));\n\n return `${packageName} - ${packagePath}\\n${statusChar} ${bold(color(description))}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,SAAS,EACT,MAAM,EACN,GAAG,EACH,eAAe,EACf,MAAM,GACP,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAkD,MAAM,4BAA4B,CAAC;AAQjH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA+B;IAC/D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EA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,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG;CAC1B,CAAC;AACF,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,eAAe,CAAC,KAAK;IAC5B,IAAI,EAAE,eAAe,CAAC,IAAI;IAC1B,GAAG,EAAE,GAAG;CACT,CAAC;AAEF;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,MAGC;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAC5E,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC;IAEzE,OAAO,GAAG,WAAW,MAAM,WAAW,KAAK,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;AACtF,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n formatTime,\n green,\n indent,\n lightCyan,\n plural,\n red,\n statusCharacter,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitPackageIdentifier } from './types/InitPackageIdentifier.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitSummary } from './types/InitSummary.js';\nimport { formatLocation } from '@ms-cloudpack/path-utilities';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport { requiredChangeTypes, type GeneratedChange, type GeneratedChangeType } from './types/GeneratedChange.js';\n\ninterface FormatInitSummaryParams {\n summaries: InitSummary[];\n options: InitOptions;\n isInterrupted?: boolean;\n}\n\n/**\n * Given init summaries and init options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: FormatInitSummaryParams) {\n const { summaries, options, isInterrupted } = params;\n const isMultiApp = summaries.length > 1;\n return (\n summaries\n .map((summary) => formatSummary({ summary, options, isInterrupted, isMultiApp }))\n .join('\\n')\n // replace >= 3 newlines with 2 newlines\n .replace(/\\n{3,}/g, '\\n\\n')\n );\n}\n\n/** Format a single app's init summary. */\nfunction formatSummary(\n params: Pick<FormatInitSummaryParams, 'options' | 'isInterrupted'> & {\n summary: InitSummary;\n isMultiApp: boolean;\n },\n): string {\n const { summary, options, isInterrupted, isMultiApp } = params;\n const summaryString: string[] = [];\n\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\n deletedGeneratedConfig,\n } = summary;\n const { check } = options;\n const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;\n\n // Report the \"Summary\" title if no errors or warnings are listed (seems redundant otherwise.\n if ((!packagesWithErrors.length && !packagesWithWarnings.length) || isMultiApp) {\n summaryString.push(bold(`==== Summary for ${summary.appPath}${incompleteText} ====`));\n }\n\n // If there are required changes, updates will be \"made\" or \"needed\" with check,\n // else if the changes are not required, only report work done when updates are \"made\" (check is disabled).\n const updatesRequired = totalRequiredChanges || (totalChanges && !check);\n\n // Report updates that were or should be added to the generated config.\n if (!packagesWithErrors.length && updatesRequired) {\n summaryString.push(formatPackageUpdates({ generatedFileUpdates, check, isMultiApp }));\n }\n\n if (!isMultiApp) {\n // Report packages with warnings.\n if (packagesWithWarnings.length) {\n summaryString.push(formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' }), '');\n }\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summaryString.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }), '');\n }\n\n if (deletedGeneratedConfig) {\n summaryString.push(`Deleted the ${cyan('cloudpack.generated.json')} file because it is no longer needed.`, '');\n }\n\n const blockingIssueCount = packagesWithErrors.length || 0;\n const requiresChanges = (check && totalRequiredChanges) || 0;\n\n // Add summary.\n summaryString.push(\n `${cyan(plural(totalPackages, 'total package'))} evaluated in ${formatTime(summary.duration)}${incompleteText}:`,\n bulletedList(\n [\n requiresChanges ? `${red(plural(totalRequiredChanges, 'change'))} required` : undefined,\n `${green(plural(totalPackages - blockingIssueCount, 'package'))} built successfully${\n packagesWithWarnings.length\n ? ` (${yellow(plural(packagesWithWarnings.length, 'package'))} with warnings)`\n : ''\n }`,\n blockingIssueCount ? `${red(plural(blockingIssueCount, 'package'))} failed to build` : undefined,\n `Totals: ${totalErrors ? red(plural(totalErrors, 'error')) : '0 errors'}, ${totalWarnings ? yellow(plural(totalWarnings, 'warning')) : '0 warnings'}`,\n ].filter(Boolean),\n ),\n );\n\n if (isInterrupted) {\n summaryString.push('', yellow(bold('Process was interrupted before all tasks could complete.')));\n } else if (requiresChanges) {\n summaryString.push(\n `Run \"${yellow('cloudpack init')}\" in your application folder to apply changes to the ${cyan(\n 'cloudpack.generated.json',\n )} file.`,\n );\n }\n\n summaryString.push('\\n');\n\n return summaryString.join('\\n');\n}\n\nfunction formatPackageUpdates(\n params: Pick<InitSummary, 'generatedFileUpdates'> &\n Pick<InitOptions, 'check'> &\n Pick<FormatInitSummaryParams, 'isInterrupted'> & { isMultiApp: boolean },\n) {\n const { generatedFileUpdates, check, isInterrupted, isMultiApp } = params;\n // If we already made the updates, don't make them look like warnings.\n const type = check ? 'warn' : 'add';\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n const exportsUpdates = getChangesToShow({ type: 'added-export', packageUpdates, isMultiApp });\n\n if (exportsUpdates.length) {\n const description = plural(exportsUpdates.length, `path$s ${check ? 'missing from' : 'added to'} exports map`);\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(exportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const includedDependencies = getChangesToShow({ type: 'included-dependency-required', packageUpdates, isMultiApp });\n\n if (includedDependencies.length) {\n const description = plural(includedDependencies.length, 'dependency$s required to be included');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(includedDependencies.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const changedExports = getChangesToShow({ type: 'changed-export', packageUpdates, isMultiApp });\n\n if (changedExports.length) {\n const description = plural(changedExports.length, 'previously unused export path$s are now used');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(changedExports.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n\n const dynamicImportsUpdates = getChangesToShow({ type: 'added-dynamic-import', packageUpdates, isMultiApp });\n\n if (dynamicImportsUpdates.length) {\n const description = plural(dynamicImportsUpdates.length, 'dynamic import$s added');\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType: type, description }),\n bulletedList(dynamicImportsUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ``}`)),\n '',\n );\n }\n }\n\n if (summaryString.length) {\n summaryString.unshift(\n bold(`Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\\n`),\n );\n }\n return summaryString.join('\\n');\n}\n\nfunction getChangesToShow(params: {\n packageUpdates: GeneratedPackageChanges;\n type: GeneratedChangeType;\n isMultiApp: boolean;\n}): GeneratedChange[] {\n const { packageUpdates, type, isMultiApp } = params;\n if (isMultiApp && !requiredChangeTypes.includes(type)) {\n return [];\n }\n return packageUpdates.changes.filter((u) => u.type === type);\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'error' | 'warn' }) {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const color = colorsByType[issueType];\n const messageType = issueType === 'error' ? 'errors' : 'warnings';\n const statusChar = bold(color(statusCharacter[issueType]));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${messageType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[messageType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader({ ...result, issueType, description }));\n\n const messages = unformattedMessages.map(({ location, text, source }) => {\n // Show the whole path so it can be easily opened with ctrl+click.\n // NOTE: location.file should be relative to the package path, not the app path.\n const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';\n // Indent the message for readability.\n return `[${source}]${filePath}\\n${color(indent(text, 1))}`;\n });\n\n summaryString.push(bulletedList(messages, undefined, statusChar), '');\n }\n\n return summaryString.join('\\n');\n}\n\nconst colorsByType = {\n error: red,\n warn: yellow,\n add: (str: string) => str,\n};\nconst statusByType = {\n error: statusCharacter.error,\n warn: statusCharacter.warn,\n add: '+',\n};\n\n/**\n * Helper to format the header for a list of issues in a package:\n * status character, `name@version`, issue description, package path.\n */\nfunction formatPackageHeader(\n params: InitPackageIdentifier & {\n description: string;\n issueType: 'error' | 'warn' | 'add';\n },\n) {\n const { name, version, path: packagePath, description, issueType } = params;\n const color = colorsByType[issueType];\n const statusChar = bold(color(statusByType[issueType]));\n const packageName = bold(lightCyan(`${name}@${version || `<unknown>`}`));\n\n return `${packageName} - ${packagePath}\\n${statusChar} ${bold(color(description))}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAI9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,mBAelB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Option } from 'commander';
|
|
2
|
-
import { parseMatch } from '../../utilities/parseMatch.js';
|
|
3
2
|
import { reusedOptions } from '../../utilities/reusedOptions.js';
|
|
4
3
|
/** Defines the "init" verb. */
|
|
5
4
|
export const init = (program) => {
|
|
@@ -11,9 +10,7 @@ export const init = (program) => {
|
|
|
11
10
|
logResolveMap: reusedOptions.logResolveMap(),
|
|
12
11
|
reset: new Option('--reset', 'Ignore the previous generated config.').conflicts('check'),
|
|
13
12
|
check: new Option('--check', 'Fail if updates to the generated config are required.').conflicts('reset'),
|
|
14
|
-
match:
|
|
15
|
-
.conflicts('reset')
|
|
16
|
-
.argParser(parseMatch),
|
|
13
|
+
match: reusedOptions.match('Only evaluate specific package(s)').conflicts('reset'),
|
|
17
14
|
cache: reusedOptions.noCache(),
|
|
18
15
|
},
|
|
19
16
|
getExecutor: () => import('./execute.js'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAc;QACjC,IAAI,EAAE,MAAM;QACZ,WAAW,EACT,6EAA6E;YAC7E,qDAAqD;QACvD,OAAO,EAAE;YACP,aAAa,EAAE,aAAa,CAAC,aAAa,EAAE;YAC5C,KAAK,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,uCAAuC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;YACxF,KAAK,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,uDAAuD,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;YACxG,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;YAClF,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE;SAC/B;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"init\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<InitOptions>({\n name: 'init',\n description:\n \"Validate an app's compatibility with Cloudpack, and generate any necessary \" +\n 'configuration overrides (cloudpack.generated.json).',\n options: {\n logResolveMap: reusedOptions.logResolveMap(),\n reset: new Option('--reset', 'Ignore the previous generated config.').conflicts('check'),\n check: new Option('--check', 'Fail if updates to the generated config are required.').conflicts('reset'),\n match: reusedOptions.match('Only evaluate specific package(s)').conflicts('reset'),\n cache: reusedOptions.noCache(),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
export type GeneratedChangeType = 'added-export' | 'changed-export' | 'included-dependency-required' | 'included-dependency-optional' | 'excluded-dependency' | 'removed-excluded-dependency' | 'added-dynamic-import';
|
|
1
2
|
export interface GeneratedChange {
|
|
2
|
-
type:
|
|
3
|
+
type: GeneratedChangeType;
|
|
3
4
|
/** Item that changed, such as the dependency name, export path, or bundler type */
|
|
4
5
|
change: string;
|
|
5
6
|
/** Additional explanation */
|
|
6
7
|
reason?: string;
|
|
7
8
|
}
|
|
9
|
+
export declare const requiredChangeTypes: GeneratedChangeType[];
|
|
8
10
|
//# sourceMappingURL=GeneratedChange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratedChange.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/GeneratedChange.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"GeneratedChange.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/GeneratedChange.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAC3B,cAAc,GACd,gBAAgB,GAChB,8BAA8B,GAC9B,8BAA8B,GAC9B,qBAAqB,GACrB,6BAA6B,GAC7B,sBAAsB,CAAC;AAE3B,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,EAKpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratedChange.js","sourceRoot":"","sources":["../../../../src/commands/init/types/GeneratedChange.ts"],"names":[],"mappings":"","sourcesContent":["export
|
|
1
|
+
{"version":3,"file":"GeneratedChange.js","sourceRoot":"","sources":["../../../../src/commands/init/types/GeneratedChange.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,mBAAmB,GAA0B;IACxD,gBAAgB;IAChB,cAAc;IACd,sBAAsB;IACtB,8BAA8B;CAC/B,CAAC","sourcesContent":["export type GeneratedChangeType =\n | 'added-export'\n | 'changed-export'\n | 'included-dependency-required'\n | 'included-dependency-optional'\n | 'excluded-dependency'\n | 'removed-excluded-dependency'\n | 'added-dynamic-import';\n\nexport interface GeneratedChange {\n type: GeneratedChangeType;\n /** Item that changed, such as the dependency name, export path, or bundler type */\n change: string;\n /** Additional explanation */\n reason?: string;\n}\n\nexport const requiredChangeTypes: GeneratedChangeType[] = [\n 'changed-export',\n 'added-export',\n 'added-dynamic-import',\n 'included-dependency-required',\n];\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EAIxB,MAAM,4BAA4B,CAAC;AAQpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMtE;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACjD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"verifyExports.d.ts","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EAIxB,MAAM,4BAA4B,CAAC;AAQpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMtE;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACjD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC,CA+K1C"}
|
|
@@ -25,16 +25,16 @@ export async function verifyExports(packageResults, context) {
|
|
|
25
25
|
}
|
|
26
26
|
// Skip packages with `ignoreMissingExports` set to true.
|
|
27
27
|
const { name, version, path: parentPath } = parentResult;
|
|
28
|
-
const
|
|
28
|
+
const ignoreMissingExports = getPackageSettings({
|
|
29
29
|
name,
|
|
30
30
|
version,
|
|
31
31
|
userPackageSettings: config.packageSettings,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
includeBuiltIn: true,
|
|
33
|
+
generatedPackageSettings: undefined,
|
|
34
|
+
}).userPackageSettings?.ignoreMissingExports || {};
|
|
35
|
+
if (ignoreMissingExports === true) {
|
|
35
36
|
continue;
|
|
36
37
|
}
|
|
37
|
-
const ignoredExports = userPackageSettings?.ignoreMissingExports || {};
|
|
38
38
|
const parentDefinition = await packages.get(parentPath);
|
|
39
39
|
/**
|
|
40
40
|
* Mapping from imported dependency package ID (`name@version`) to import path
|
|
@@ -83,7 +83,7 @@ export async function verifyExports(packageResults, context) {
|
|
|
83
83
|
// Find any missing names.
|
|
84
84
|
const missing = consumedNames.filter((namedImport) => namedImport !== '*' &&
|
|
85
85
|
!importProducesStarResult.includes(namedImport) &&
|
|
86
|
-
!
|
|
86
|
+
!ignoreMissingExports[depImportPath]?.includes(namedImport));
|
|
87
87
|
if (!missing.length) {
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyExports.js","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,cAAc,GACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAmB,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,iB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AAChB,CAAC;AAID,SAAS,iBAAiB,CAAC,OAK1B;IAMC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IAE7E,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IACxF,MAAM,SAAS,GACb,kBAAkB;QAClB,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,KAAK,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAElH,MAAM,UAAU,GAAG,SAAS,EAAE,IAAI,CAAC;IAEnC,0FAA0F;IAC1F,uBAAuB;IACvB,IAAI,CAAC,kBAAkB,IAAI,CAAC,UAAU,EAAE,CAAC;QACvC,OAAO;IACT,CAAC;IAED,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAoD,EAAE,CAAC;AACjG,CAAC","sourcesContent":["import type { BundleInfo, Session } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\n PackageDefinitionsCache,\n PackageJson,\n ResolveMap,\n ResolveMapEntry,\n} from '@ms-cloudpack/common-types';\nimport {\n findResolveMapEntry,\n getDependencies,\n getUnusedDependencies,\n getSourceEntry,\n} from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport { bulletedList, formatPackageName, type BulletList } from '@ms-cloudpack/task-reporter';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport semver from 'semver';\nimport { parseImportString } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * Checks that the imports/exports of packages match.\n * To be called before `summarize`.\n * @param packageResults - The package results to check.\n * @param context - The context to use.\n * @returns Mapping from absolute package path to errors.\n */\nexport async function verifyExports(\n packageResults: Record<string, InitPackageResult>,\n context: {\n packages: PackageDefinitionsCache;\n session: Session;\n },\n): Promise<Record<string, BundleMessage[]>> {\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const allErrors: Record<string, BundleMessage[]> = {};\n const packageResultsArray = Object.values(packageResults);\n const importsCache: Record<string, string[]> = {};\n\n // Iterate through each package\n for (const parentResult of packageResultsArray) {\n // Skip packages with build errors or no info\n if (!parentResult?.info || !parentResult.outputPath || parentResult.errors?.length) {\n continue;\n }\n\n // Skip packages with `ignoreMissingExports` set to true.\n const { name, version, path: parentPath } = parentResult;\n const { userPackageSettings } = getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: config.generated.packageSettings,\n });\n if (userPackageSettings?.ignoreMissingExports === true) {\n continue;\n }\n const ignoredExports = userPackageSettings?.ignoreMissingExports || {};\n\n const parentDefinition = await packages.get(parentPath);\n\n /**\n * Mapping from imported dependency package ID (`name@version`) to import path\n * to an object with export names missing from that file, the importString, and bundledFile.\n */\n const depsMissingExports: Record<\n string,\n Record<\n string,\n {\n missingNames: Set<string>;\n importName: string;\n importPath: string;\n importVersion: string;\n bundledFile: string;\n }\n >\n > = {};\n const invalidSemver: Record<string, string> = {};\n\n // Find the main entry point for the parent package to list as the importing bundle.\n const importingBundle = path.join(parentResult.outputPath, parentResult.info?.['.']?.bundlePath || '');\n\n // Find the main entry point for the parent package to list as the importing source.\n const sourceMainEntry = await getSourceEntry({ entry: '.', inputPath: parentPath }, { packages, config });\n const importingSource = path.join(parentPath, sourceMainEntry || '.');\n\n // Iterate through each entry path from the parent package\n for (const { consumes } of Object.values(parentResult.info)) {\n // Skip entries with no imports\n if (!consumes?.length) {\n continue;\n }\n\n // Iterate through each imported package\n for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of consumes) {\n const dependencyInfo = getDependencyInfo({\n packageName: depName,\n definition: parentDefinition,\n resolveMap,\n packageResultsArray,\n });\n // We don't have enough info to check this dependency, so skip it.\n if (!dependencyInfo) {\n continue;\n }\n\n const { depResolveMapEntry, depResult } = dependencyInfo;\n const { outputPath: depOutputPath, info: depEntries } = depResult;\n\n const importProduces = depEntries[depImportPath]?.produces;\n if (!importProduces) {\n // Skip if the imported package has no entry for the import path. (If the path is missing,\n // evaluateImportsForOverrides has already run and tried to fix it or reported an error.)\n continue;\n }\n\n const importProducesStarResult = await importProducesStar({\n packagePath: depResolveMapEntry.path,\n importPath: depImportPath,\n info: depEntries,\n context: { packages, resolveMap, packageResultsArray },\n cache: importsCache,\n });\n\n // Find any missing names.\n const missing = consumedNames.filter(\n (namedImport) =>\n namedImport !== '*' &&\n !importProducesStarResult.includes(namedImport) &&\n !ignoredExports[depImportPath]?.includes(namedImport),\n );\n if (!missing.length) {\n continue;\n }\n\n // Figure out which actual file the exports appear to be missing from.\n const relativePath =\n (await getSourceEntry({ entry: depImportPath, inputPath: depResolveMapEntry.path }, { packages, config })) ||\n // If the package is missing an exports map, assume the import path is the real path.\n depImportPath;\n const filePath = path.join(depResolveMapEntry.path, relativePath);\n\n // Save the missing names for this path within the package.\n const depKey = `${depResolveMapEntry.name}@${depResolveMapEntry.version}`;\n depsMissingExports[depKey] ??= {};\n depsMissingExports[depKey][filePath] ??= {\n missingNames: new Set(),\n importName: depName,\n importPath: depImportPath,\n importVersion: depResolveMapEntry.version,\n bundledFile: path.join(depOutputPath ?? '', depEntries[depImportPath]?.bundlePath),\n };\n missing.forEach((m) => depsMissingExports[depKey][filePath].missingNames.add(m));\n\n // Check if the package satisfies the parent semver requirement.\n const requiredVersion =\n !invalidSemver[depKey] &&\n (getDependencies(parentDefinition)[depName] || getUnusedDependencies(parentDefinition)[depName]);\n if (requiredVersion && !semver.satisfies(depResolveMapEntry.version, requiredVersion)) {\n invalidSemver[depKey] = requiredVersion;\n }\n }\n }\n\n const errors: BundleMessage[] = [];\n\n for (const [packageId, missing] of Object.entries(depsMissingExports)) {\n // We want a single error for each package, with a bulleted list of files with missing exports.\n for (const [sourceFile, errorInfo] of Object.entries(missing)) {\n const { missingNames, importName, importPath, importVersion, bundledFile } = errorInfo;\n const error: BulletList = [\n `Importing bundle: ${importingBundle}`,\n `Importing source: ${importingSource}`,\n `Exporting package: ${formatPackageName({ name: importName, version: importVersion })}${importPath === '.' ? '' : ` (imported path: \"${importPath}\")`}`,\n `Exporting bundle: ${bundledFile}`,\n `Exporting source: ${sourceFile}`,\n `Missing export(s): { ${Array.from(missingNames).join(', ')} }`,\n ];\n\n if (invalidSemver[packageId]) {\n // If we have an invalid semver, add a note about that after exporting package.\n error.splice(\n 3,\n 0,\n `Incompatible version: ${formatPackageName({ name: importName, version: importVersion })} does not satisfy importer requirement \"${invalidSemver[packageId]}\"`,\n ['If this was unexpected, make sure you installed dependencies after pulling the latest changes.'],\n );\n }\n\n errors.push({\n text: `A bundle imported names from another bundle which were not exported:\\n${bulletedList(error)}\\n`,\n source: 'verify exports',\n // Don't include a whole-message location here because that doesn't make sense for this error type,\n // and we already put full paths to individual problem files within the message.\n });\n }\n }\n\n if (errors.length) {\n allErrors[parentPath] = errors;\n }\n }\n\n return allErrors;\n}\n\nasync function importProducesStar({\n packagePath,\n info,\n importPath,\n context,\n visited = new Set(),\n cache = {},\n}: {\n packagePath: string;\n info: BundleInfo;\n importPath: string;\n context: {\n packages: PackageDefinitionsCache;\n resolveMap: ResolveMap;\n packageResultsArray: InitPackageResult[];\n };\n visited?: Set<string>;\n cache?: Record<string, string[]>;\n}): Promise<string[]> {\n const key = `${packagePath}${importPath}`;\n // Check if the entry has already been visited to avoid cycles\n if (visited.has(key)) {\n return [];\n }\n\n // Mark the current entry as visited\n visited.add(key);\n\n const cachedResult = cache[key];\n if (cachedResult) {\n return cachedResult;\n }\n\n const { packages, resolveMap, packageResultsArray } = context;\n let result: string[] = [];\n\n // Iterate over the produced names\n for (const name of info[importPath].produces) {\n if (name.startsWith('*')) {\n // Extract the name and path from the format \"*ImportString\"\n const { packageName: depName, importPath: depImportPath } = parseImportString(name.slice(1));\n\n const dependencyInfo = getDependencyInfo({\n packageName: depName,\n definition: await packages.get(packagePath),\n resolveMap,\n packageResultsArray,\n });\n\n if (dependencyInfo) {\n const { depResolveMapEntry, depResult } = dependencyInfo;\n // Recursively aggregate the produced names from the other package\n result = result.concat(\n await importProducesStar({\n packagePath: depResolveMapEntry.path,\n info: depResult.info,\n importPath: depImportPath,\n context,\n visited,\n }),\n );\n }\n } else {\n // Add the name to the result if it doesn't start with '*'\n result.push(name);\n }\n }\n\n cache[key] = result;\n return result;\n}\n\ntype WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };\n\nfunction getDependencyInfo(options: {\n packageName: string;\n definition: PackageJson;\n resolveMap: ResolveMap;\n packageResultsArray: InitPackageResult[];\n}):\n | {\n depResult: WithRequired<InitPackageResult, 'info'>;\n depResolveMapEntry: ResolveMapEntry;\n }\n | undefined {\n const { packageName, definition, resolveMap, packageResultsArray } = options;\n\n const depResolveMapEntry = findResolveMapEntry({ packageName, definition, resolveMap });\n const depResult =\n depResolveMapEntry &&\n packageResultsArray.find((r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version);\n\n const depEntries = depResult?.info;\n\n // Skip if we can't find the imported package in the resolve map, or there's no info about\n // its entries/exports.\n if (!depResolveMapEntry || !depEntries) {\n return;\n }\n\n return { depResolveMapEntry, depResult: depResult as WithRequired<InitPackageResult, 'info'> };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"verifyExports.js","sourceRoot":"","sources":["../../../src/commands/init/verifyExports.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,cAAc,GACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAmB,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;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AU,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IAE7E,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC;IACxF,MAAM,SAAS,GACb,kBAAkB;QAClB,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,KAAK,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAElH,MAAM,UAAU,GAAG,SAAS,EAAE,IAAI,CAAC;IAEnC,0FAA0F;IAC1F,uBAAuB;IACvB,IAAI,CAAC,kBAAkB,IAAI,CAAC,UAAU,EAAE,CAAC;QACvC,OAAO;IACT,CAAC;IAED,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAoD,EAAE,CAAC;AACjG,CAAC","sourcesContent":["import type { BundleInfo, Session } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\n PackageDefinitionsCache,\n PackageJson,\n ResolveMap,\n ResolveMapEntry,\n} from '@ms-cloudpack/common-types';\nimport {\n findResolveMapEntry,\n getDependencies,\n getUnusedDependencies,\n getSourceEntry,\n} from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport { bulletedList, formatPackageName, type BulletList } from '@ms-cloudpack/task-reporter';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport semver from 'semver';\nimport { parseImportString } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * Checks that the imports/exports of packages match.\n * To be called before `summarize`.\n * @param packageResults - The package results to check.\n * @param context - The context to use.\n * @returns Mapping from absolute package path to errors.\n */\nexport async function verifyExports(\n packageResults: Record<string, InitPackageResult>,\n context: {\n packages: PackageDefinitionsCache;\n session: Session;\n },\n): Promise<Record<string, BundleMessage[]>> {\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const allErrors: Record<string, BundleMessage[]> = {};\n const packageResultsArray = Object.values(packageResults);\n const importsCache: Record<string, string[]> = {};\n\n // Iterate through each package\n for (const parentResult of packageResultsArray) {\n // Skip packages with build errors or no info\n if (!parentResult?.info || !parentResult.outputPath || parentResult.errors?.length) {\n continue;\n }\n\n // Skip packages with `ignoreMissingExports` set to true.\n const { name, version, path: parentPath } = parentResult;\n const ignoreMissingExports =\n getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n includeBuiltIn: true,\n generatedPackageSettings: undefined,\n }).userPackageSettings?.ignoreMissingExports || {};\n\n if (ignoreMissingExports === true) {\n continue;\n }\n\n const parentDefinition = await packages.get(parentPath);\n\n /**\n * Mapping from imported dependency package ID (`name@version`) to import path\n * to an object with export names missing from that file, the importString, and bundledFile.\n */\n const depsMissingExports: Record<\n string,\n Record<\n string,\n {\n missingNames: Set<string>;\n importName: string;\n importPath: string;\n importVersion: string;\n bundledFile: string;\n }\n >\n > = {};\n const invalidSemver: Record<string, string> = {};\n\n // Find the main entry point for the parent package to list as the importing bundle.\n const importingBundle = path.join(parentResult.outputPath, parentResult.info?.['.']?.bundlePath || '');\n\n // Find the main entry point for the parent package to list as the importing source.\n const sourceMainEntry = await getSourceEntry({ entry: '.', inputPath: parentPath }, { packages, config });\n const importingSource = path.join(parentPath, sourceMainEntry || '.');\n\n // Iterate through each entry path from the parent package\n for (const { consumes } of Object.values(parentResult.info)) {\n // Skip entries with no imports\n if (!consumes?.length) {\n continue;\n }\n\n // Iterate through each imported package\n for (const { packageName: depName, importPath: depImportPath, names: consumedNames } of consumes) {\n const dependencyInfo = getDependencyInfo({\n packageName: depName,\n definition: parentDefinition,\n resolveMap,\n packageResultsArray,\n });\n // We don't have enough info to check this dependency, so skip it.\n if (!dependencyInfo) {\n continue;\n }\n\n const { depResolveMapEntry, depResult } = dependencyInfo;\n const { outputPath: depOutputPath, info: depEntries } = depResult;\n\n const importProduces = depEntries[depImportPath]?.produces;\n if (!importProduces) {\n // Skip if the imported package has no entry for the import path. (If the path is missing,\n // evaluateImportsForOverrides has already run and tried to fix it or reported an error.)\n continue;\n }\n\n const importProducesStarResult = await importProducesStar({\n packagePath: depResolveMapEntry.path,\n importPath: depImportPath,\n info: depEntries,\n context: { packages, resolveMap, packageResultsArray },\n cache: importsCache,\n });\n\n // Find any missing names.\n const missing = consumedNames.filter(\n (namedImport) =>\n namedImport !== '*' &&\n !importProducesStarResult.includes(namedImport) &&\n !ignoreMissingExports[depImportPath]?.includes(namedImport),\n );\n if (!missing.length) {\n continue;\n }\n\n // Figure out which actual file the exports appear to be missing from.\n const relativePath =\n (await getSourceEntry({ entry: depImportPath, inputPath: depResolveMapEntry.path }, { packages, config })) ||\n // If the package is missing an exports map, assume the import path is the real path.\n depImportPath;\n const filePath = path.join(depResolveMapEntry.path, relativePath);\n\n // Save the missing names for this path within the package.\n const depKey = `${depResolveMapEntry.name}@${depResolveMapEntry.version}`;\n depsMissingExports[depKey] ??= {};\n depsMissingExports[depKey][filePath] ??= {\n missingNames: new Set(),\n importName: depName,\n importPath: depImportPath,\n importVersion: depResolveMapEntry.version,\n bundledFile: path.join(depOutputPath ?? '', depEntries[depImportPath]?.bundlePath),\n };\n missing.forEach((m) => depsMissingExports[depKey][filePath].missingNames.add(m));\n\n // Check if the package satisfies the parent semver requirement.\n const requiredVersion =\n !invalidSemver[depKey] &&\n (getDependencies(parentDefinition)[depName] || getUnusedDependencies(parentDefinition)[depName]);\n if (requiredVersion && !semver.satisfies(depResolveMapEntry.version, requiredVersion)) {\n invalidSemver[depKey] = requiredVersion;\n }\n }\n }\n\n const errors: BundleMessage[] = [];\n\n for (const [packageId, missing] of Object.entries(depsMissingExports)) {\n // We want a single error for each package, with a bulleted list of files with missing exports.\n for (const [sourceFile, errorInfo] of Object.entries(missing)) {\n const { missingNames, importName, importPath, importVersion, bundledFile } = errorInfo;\n const error: BulletList = [\n `Importing bundle: ${importingBundle}`,\n `Importing source: ${importingSource}`,\n `Exporting package: ${formatPackageName({ name: importName, version: importVersion })}${importPath === '.' ? '' : ` (imported path: \"${importPath}\")`}`,\n `Exporting bundle: ${bundledFile}`,\n `Exporting source: ${sourceFile}`,\n `Missing export(s): { ${Array.from(missingNames).join(', ')} }`,\n ];\n\n if (invalidSemver[packageId]) {\n // If we have an invalid semver, add a note about that after exporting package.\n error.splice(\n 3,\n 0,\n `Incompatible version: ${formatPackageName({ name: importName, version: importVersion })} does not satisfy importer requirement \"${invalidSemver[packageId]}\"`,\n ['If this was unexpected, make sure you installed dependencies after pulling the latest changes.'],\n );\n }\n\n errors.push({\n text: `A bundle imported names from another bundle which were not exported:\\n${bulletedList(error)}\\n`,\n source: 'verify exports',\n // Don't include a whole-message location here because that doesn't make sense for this error type,\n // and we already put full paths to individual problem files within the message.\n });\n }\n }\n\n if (errors.length) {\n allErrors[parentPath] = errors;\n }\n }\n\n return allErrors;\n}\n\nasync function importProducesStar({\n packagePath,\n info,\n importPath,\n context,\n visited = new Set(),\n cache = {},\n}: {\n packagePath: string;\n info: BundleInfo;\n importPath: string;\n context: {\n packages: PackageDefinitionsCache;\n resolveMap: ResolveMap;\n packageResultsArray: InitPackageResult[];\n };\n visited?: Set<string>;\n cache?: Record<string, string[]>;\n}): Promise<string[]> {\n const key = `${packagePath}${importPath}`;\n // Check if the entry has already been visited to avoid cycles\n if (visited.has(key)) {\n return [];\n }\n\n // Mark the current entry as visited\n visited.add(key);\n\n const cachedResult = cache[key];\n if (cachedResult) {\n return cachedResult;\n }\n\n const { packages, resolveMap, packageResultsArray } = context;\n let result: string[] = [];\n\n // Iterate over the produced names\n for (const name of info[importPath].produces) {\n if (name.startsWith('*')) {\n // Extract the name and path from the format \"*ImportString\"\n const { packageName: depName, importPath: depImportPath } = parseImportString(name.slice(1));\n\n const dependencyInfo = getDependencyInfo({\n packageName: depName,\n definition: await packages.get(packagePath),\n resolveMap,\n packageResultsArray,\n });\n\n if (dependencyInfo) {\n const { depResolveMapEntry, depResult } = dependencyInfo;\n // Recursively aggregate the produced names from the other package\n result = result.concat(\n await importProducesStar({\n packagePath: depResolveMapEntry.path,\n info: depResult.info,\n importPath: depImportPath,\n context,\n visited,\n }),\n );\n }\n } else {\n // Add the name to the result if it doesn't start with '*'\n result.push(name);\n }\n }\n\n cache[key] = result;\n return result;\n}\n\ntype WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };\n\nfunction getDependencyInfo(options: {\n packageName: string;\n definition: PackageJson;\n resolveMap: ResolveMap;\n packageResultsArray: InitPackageResult[];\n}):\n | {\n depResult: WithRequired<InitPackageResult, 'info'>;\n depResolveMapEntry: ResolveMapEntry;\n }\n | undefined {\n const { packageName, definition, resolveMap, packageResultsArray } = options;\n\n const depResolveMapEntry = findResolveMapEntry({ packageName, definition, resolveMap });\n const depResult =\n depResolveMapEntry &&\n packageResultsArray.find((r) => r.name === depResolveMapEntry.name && r.version === depResolveMapEntry.version);\n\n const depEntries = depResult?.info;\n\n // Skip if we can't find the imported package in the resolve map, or there's no info about\n // its entries/exports.\n if (!depResolveMapEntry || !depEntries) {\n return;\n }\n\n return { depResolveMapEntry, depResult: depResult as WithRequired<InitPackageResult, 'info'> };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CAsH/C,CAAC"}
|
|
@@ -11,6 +11,7 @@ import { getStartingAppPath } from './getStartingAppPath.js';
|
|
|
11
11
|
import { openBrowser } from './openBrowser.js';
|
|
12
12
|
import { trackSession } from './trackSession.js';
|
|
13
13
|
import { getCertificate } from '@ms-cloudpack/setup-utilities';
|
|
14
|
+
import { getConfigOptionsFromCliOptions } from '../../utilities/getConfigOptionsFromCliOptions.js';
|
|
14
15
|
/**
|
|
15
16
|
* Defines the "start" verb entry point.
|
|
16
17
|
*/
|
|
@@ -21,7 +22,7 @@ export const execute = async (params) => {
|
|
|
21
22
|
return appPathResult;
|
|
22
23
|
}
|
|
23
24
|
const appPath = appPathResult;
|
|
24
|
-
const apiContextOptions = await initialize({ appPath, configOptions:
|
|
25
|
+
const apiContextOptions = await initialize({ appPath, configOptions: getConfigOptionsFromCliOptions(options) });
|
|
25
26
|
const { config, telemetryClient } = apiContextOptions;
|
|
26
27
|
console.log('App path:', yellow(appPath));
|
|
27
28
|
console.log('Bundle mode:', yellow(options.mode));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GAGrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB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AAE,OAAO,EAAE,CAAC;IACtC,CAAC;AACH,CAAC;AAED,wBAAwB","sourcesContent":["import {\n createPartialApiContext,\n ensurePackageBundled,\n type CloudpackServer,\n type Context,\n} from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { isExternalPackage, resolve } from '@ms-cloudpack/package-utilities';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { cyan, yellow, bold } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry } from '../../performance/markers.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { trackSession } from './trackSession.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { getCertificate } from '@ms-cloudpack/setup-utilities';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose } = params;\n\n const appPathResult = await getStartingAppPath(cwd, options.app);\n if (typeof appPathResult !== 'string') {\n return appPathResult;\n }\n const appPath = appPathResult;\n const apiContextOptions = await initialize({ appPath, configOptions: { mode: options.mode } });\n const { config, telemetryClient } = apiContextOptions;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n runPrerequisites(apiContextOptions);\n\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n let overlayPath = await resolve('@ms-cloudpack/overlay', currentDir);\n\n // If overlay is an internal package, resolve the overlay from the current package's linked node modules\n // to \"externalize\" it, so that we always use the bundled version of the overlay instead of the source.\n if (overlayPath && !isExternalPackage(overlayPath)) {\n const cliPath = await resolve('@ms-cloudpack/cli', currentDir);\n overlayPath = cliPath ? path.join(cliPath, 'node_modules', '@ms-cloudpack/overlay') : undefined;\n }\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath,\n }),\n );\n const { packages, session } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\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 // Start api server for tracking status and handling remote requests.\n const apiServerResult = await createApiServer(options, apiContext);\n if (apiServerResult.hasErrors) {\n return apiServerResult;\n }\n const { apiServer } = apiServerResult;\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startServers } = await import('@ms-cloudpack/app-server');\n const servers = await startServers(\n {\n definition,\n bundleServerOptions: { disableCache: !options.cache, port: options.bundleServerPort },\n port: options.appServerPort,\n },\n apiContext,\n );\n\n // Save the session to active sessions.\n const sessionTracker = await trackSession(session);\n\n const cleanup = async () => {\n // Stop tracking the session.\n await sessionTracker.close();\n\n await Promise.all(\n Object.entries({ apiServer, ...servers }).map(async ([name, server]) => {\n if (!server) return;\n\n const desc = `${name} (${server.url})`;\n console.info(`Closing ${desc}`);\n try {\n await server.close();\n console.info(`Closed ${desc}`);\n } catch (err) {\n console.warn(`Error closing ${desc}:`, err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n\n const defaultUrl = makeUrl(config.server?.defaultPath || '', session.urls.appServer).href;\n\n const cliEntryMarker = performance.getEntriesByName(PerfMarkerCliEntry, 'mark')[0];\n if (cliEntryMarker) {\n telemetryClient.tracer.startSpan('TIME_TO_OPEN_BROWSER', { startTime: cliEntryMarker.startTime }).end();\n } else {\n throw new Error('TIME_TO_OPEN_BROWSER marker not found');\n }\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).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:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n\n return null; // the command should keep running\n};\n\n/**\n * Create the API server, or return an error message if the server could not be created.\n */\nasync function createApiServer(\n options: StartOptions,\n apiContext: Context,\n): Promise<{ hasErrors: false; apiServer: CloudpackServer } | { hasErrors: true; message: string }> {\n const { session } = apiContext;\n const { config } = session;\n const { server, appPath } = config;\n\n // If a cert is needed, check that it exists.\n if (server?.https === true && !(await getCertificate({ domain: server?.domain, cwd: appPath }))) {\n return {\n hasErrors: true,\n message:\n `The local site is configured to use https in cloudpack.config.json, but is missing a cert.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to create the required certificate and try start again.\\n`,\n };\n }\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n\n try {\n const apiServer = await createCloudpackServer({ port: options.apiServerPort }, apiContext);\n return { hasErrors: false, apiServer };\n } catch (err) {\n let message: string;\n if ((err as { code: string }).code === 'EADDRNOTAVAIL' && server?.domain) {\n const primaryDomain = (Array.isArray(server.domain) ? server.domain : [server.domain])[0];\n message =\n `The domain \"${cyan(bold(primaryDomain))}\" in cloudpack.config.json is not resolvable.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to add the appropriate entries to your hosts file and ` +\n `try start again.\\n`;\n } else {\n message = `Error creating API server: ${(err as Error).stack || err}`;\n }\n return { hasErrors: true, message };\n }\n}\n\n// cspell:ignore Prereqs\n"]}
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GAGrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MA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AC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1F,OAAO;gBACL,eAAe,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,mDAAmD;oBAC3F,QAAQ,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,0DAA0D;oBAC/F,oBAAoB,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,8BAA+B,GAAa,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;QACxE,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACtC,CAAC;AACH,CAAC;AAED,wBAAwB","sourcesContent":["import {\n createPartialApiContext,\n ensurePackageBundled,\n type CloudpackServer,\n type Context,\n} from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { isExternalPackage, resolve } from '@ms-cloudpack/package-utilities';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { cyan, yellow, bold } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry } from '../../performance/markers.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { trackSession } from './trackSession.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { getCertificate } from '@ms-cloudpack/setup-utilities';\nimport { getConfigOptionsFromCliOptions } from '../../utilities/getConfigOptionsFromCliOptions.js';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose } = params;\n\n const appPathResult = await getStartingAppPath(cwd, options.app);\n if (typeof appPathResult !== 'string') {\n return appPathResult;\n }\n const appPath = appPathResult;\n const apiContextOptions = await initialize({ appPath, configOptions: getConfigOptionsFromCliOptions(options) });\n const { config, telemetryClient } = apiContextOptions;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n runPrerequisites(apiContextOptions);\n\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n let overlayPath = await resolve('@ms-cloudpack/overlay', currentDir);\n\n // If overlay is an internal package, resolve the overlay from the current package's linked node modules\n // to \"externalize\" it, so that we always use the bundled version of the overlay instead of the source.\n if (overlayPath && !isExternalPackage(overlayPath)) {\n const cliPath = await resolve('@ms-cloudpack/cli', currentDir);\n overlayPath = cliPath ? path.join(cliPath, 'node_modules', '@ms-cloudpack/overlay') : undefined;\n }\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath,\n }),\n );\n const { packages, session } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\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 // Start api server for tracking status and handling remote requests.\n const apiServerResult = await createApiServer(options, apiContext);\n if (apiServerResult.hasErrors) {\n return apiServerResult;\n }\n const { apiServer } = apiServerResult;\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startServers } = await import('@ms-cloudpack/app-server');\n const servers = await startServers(\n {\n definition,\n bundleServerOptions: { disableCache: !options.cache, port: options.bundleServerPort },\n port: options.appServerPort,\n },\n apiContext,\n );\n\n // Save the session to active sessions.\n const sessionTracker = await trackSession(session);\n\n const cleanup = async () => {\n // Stop tracking the session.\n await sessionTracker.close();\n\n await Promise.all(\n Object.entries({ apiServer, ...servers }).map(async ([name, server]) => {\n if (!server) return;\n\n const desc = `${name} (${server.url})`;\n console.info(`Closing ${desc}`);\n try {\n await server.close();\n console.info(`Closed ${desc}`);\n } catch (err) {\n console.warn(`Error closing ${desc}:`, err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n\n const defaultUrl = makeUrl(config.server?.defaultPath || '', session.urls.appServer).href;\n\n const cliEntryMarker = performance.getEntriesByName(PerfMarkerCliEntry, 'mark')[0];\n if (cliEntryMarker) {\n telemetryClient.tracer.startSpan('TIME_TO_OPEN_BROWSER', { startTime: cliEntryMarker.startTime }).end();\n } else {\n throw new Error('TIME_TO_OPEN_BROWSER marker not found');\n }\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).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:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n\n return null; // the command should keep running\n};\n\n/**\n * Create the API server, or return an error message if the server could not be created.\n */\nasync function createApiServer(\n options: StartOptions,\n apiContext: Context,\n): Promise<{ hasErrors: false; apiServer: CloudpackServer } | { hasErrors: true; message: string }> {\n const { session } = apiContext;\n const { config } = session;\n const { server, appPath } = config;\n\n // If a cert is needed, check that it exists.\n if (server?.https === true && !(await getCertificate({ domain: server?.domain, cwd: appPath }))) {\n return {\n hasErrors: true,\n message:\n `The local site is configured to use https in cloudpack.config.json, but is missing a cert.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to create the required certificate and try start again.\\n`,\n };\n }\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n\n try {\n const apiServer = await createCloudpackServer({ port: options.apiServerPort }, apiContext);\n return { hasErrors: false, apiServer };\n } catch (err) {\n let message: string;\n if ((err as { code: string }).code === 'EADDRNOTAVAIL' && server?.domain) {\n const primaryDomain = (Array.isArray(server.domain) ? server.domain : [server.domain])[0];\n message =\n `The domain \"${cyan(bold(primaryDomain))}\" in cloudpack.config.json is not resolvable.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to add the appropriate entries to your hosts file and ` +\n `try start again.\\n`;\n } else {\n message = `Error creating API server: ${(err as Error).stack || err}`;\n }\n return { hasErrors: true, message };\n }\n}\n\n// cspell:ignore Prereqs\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import glob from 'glob
|
|
1
|
+
import glob from 'fast-glob';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
/**
|
|
4
4
|
* Find folders in the repo containing a `cloudpack.config.json` file.
|
|
@@ -6,6 +6,6 @@ import path from 'path';
|
|
|
6
6
|
* @returns An array of app paths corresponding to all discovered Cloudpack apps
|
|
7
7
|
*/
|
|
8
8
|
export function findCloudpackAppPaths(startingPath) {
|
|
9
|
-
return (glob.
|
|
9
|
+
return (glob.sync(['**/cloudpack.config.json'], { cwd: startingPath, ignore: ['**/node_modules/**'] }) ?? []).map((file) => path.join(startingPath, path.dirname(file)));
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=findCloudpackAppPaths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findCloudpackAppPaths.js","sourceRoot":"","sources":["../../src/utilities/findCloudpackAppPaths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"findCloudpackAppPaths.js","sourceRoot":"","sources":["../../src/utilities/findCloudpackAppPaths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAoB;IACxD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,0BAA0B,CAAC,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAC/G,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CACtD,CAAC;AACJ,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport path from 'path';\n\n/**\n * Find folders in the repo containing a `cloudpack.config.json` file.\n * @param startingPath The path to start searching from when finding Cloudpack apps\n * @returns An array of app paths corresponding to all discovered Cloudpack apps\n */\nexport function findCloudpackAppPaths(startingPath: string) {\n return (glob.sync(['**/cloudpack.config.json'], { cwd: startingPath, ignore: ['**/node_modules/**'] }) ?? []).map(\n (file) => path.join(startingPath, path.dirname(file)),\n );\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReadConfigOptions } from '@ms-cloudpack/config';
|
|
2
|
+
import type { BundleOptions } from '../commands/bundle/types/BundleOptions.js';
|
|
3
|
+
/**
|
|
4
|
+
* Translate CLI options into `readConfig` options. (This currently uses partial `BundleOptions` as
|
|
5
|
+
* the type, but it works for anything with at least one of the listed properties.)
|
|
6
|
+
*/
|
|
7
|
+
export declare function getConfigOptionsFromCliOptions(options: Partial<Pick<BundleOptions, 'mode' | 'bundler'>>): ReadConfigOptions;
|
|
8
|
+
//# sourceMappingURL=getConfigOptionsFromCliOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfigOptionsFromCliOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/getConfigOptionsFromCliOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE/E;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACxD,iBAAiB,CAOnB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translate CLI options into `readConfig` options. (This currently uses partial `BundleOptions` as
|
|
3
|
+
* the type, but it works for anything with at least one of the listed properties.)
|
|
4
|
+
*/
|
|
5
|
+
export function getConfigOptionsFromCliOptions(options) {
|
|
6
|
+
return {
|
|
7
|
+
mode: options.mode,
|
|
8
|
+
// Handle --bundler by passing it as a universal package override, which will be appended
|
|
9
|
+
// to any user-provided packageSettings so that it takes precedence.
|
|
10
|
+
extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getConfigOptionsFromCliOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfigOptionsFromCliOptions.js","sourceRoot":"","sources":["../../src/utilities/getConfigOptionsFromCliOptions.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAAyD;IAEzD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,yFAAyF;QACzF,oEAAoE;QACpE,oBAAoB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;KAC/F,CAAC;AACJ,CAAC","sourcesContent":["import type { ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { BundleOptions } from '../commands/bundle/types/BundleOptions.js';\n\n/**\n * Translate CLI options into `readConfig` options. (This currently uses partial `BundleOptions` as\n * the type, but it works for anything with at least one of the listed properties.)\n */\nexport function getConfigOptionsFromCliOptions(\n options: Partial<Pick<BundleOptions, 'mode' | 'bundler'>>,\n): ReadConfigOptions {\n return {\n mode: options.mode,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n };\n}\n"]}
|
|
@@ -4,9 +4,14 @@ import { Option } from 'commander';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const reusedOptions: {
|
|
6
6
|
logResolveMap: () => Option;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @param descriptionStart Start of description for this command, e.g. "Bundle specific package(s)"
|
|
9
|
+
* (it will automatically include an optional version note and examples)
|
|
10
|
+
*/
|
|
11
|
+
match: (descriptionStart: string) => Option;
|
|
8
12
|
mode: (options: {
|
|
9
13
|
action: "bundle" | "run";
|
|
10
14
|
}) => Option;
|
|
15
|
+
noCache: () => Option;
|
|
11
16
|
};
|
|
12
17
|
//# sourceMappingURL=reusedOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD;;GAEG;AACH,eAAO,MAAM,aAAa;;IAExB;;;OAGG;8BACuB,MAAM;oBAKhB;QAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAA;KAAE;;CAQ7C,CAAC"}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { InvalidArgumentError, Option } from 'commander';
|
|
2
|
+
import { parseMatch } from './parseMatch.js';
|
|
2
3
|
/**
|
|
3
4
|
* These options are used by multiple commands, but should be manually added.
|
|
4
5
|
*/
|
|
5
6
|
export const reusedOptions = {
|
|
6
7
|
logResolveMap: () => new Option('--log-resolve-map', 'Log the resolve map to "resolve-map.json" for diagnostics.'),
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @param descriptionStart Start of description for this command, e.g. "Bundle specific package(s)"
|
|
10
|
+
* (it will automatically include an optional version note and examples)
|
|
11
|
+
*/
|
|
12
|
+
match: (descriptionStart) => new Option('--match <match...>', `${descriptionStart}, optionally with a version: e.g. "foo", "@foo/*", "foo@1.2.3"`).argParser(parseMatch),
|
|
8
13
|
mode: (options) => new Option('--mode <mode>', `The mode to ${options.action === 'bundle' ? 'bundle the package' : 'run the app'} in. (library | production)`)
|
|
9
14
|
.argParser(parseBundleMode)
|
|
10
15
|
.default('library'),
|
|
16
|
+
noCache: () => new Option('--no-cache', 'Rebuild all packages, rather than using cached assets.'),
|
|
11
17
|
};
|
|
12
18
|
/** Parse the session mode based on user input (e.g. --mode argument in start.) */
|
|
13
19
|
function parseBundleMode(mode) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusedOptions.js","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"reusedOptions.js","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,mBAAmB,EAAE,4DAA4D,CAAC;IAClH;;;OAGG;IACH,KAAK,EAAE,CAAC,gBAAwB,EAAE,EAAE,CAClC,IAAI,MAAM,CACR,oBAAoB,EACpB,GAAG,gBAAgB,gEAAgE,CACpF,CAAC,SAAS,CAAC,UAAU,CAAC;IACzB,IAAI,EAAE,CAAC,OAAqC,EAAE,EAAE,CAC9C,IAAI,MAAM,CACR,eAAe,EACf,eAAe,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,aAAa,6BAA6B,CAC/G;SACE,SAAS,CAAC,eAAe,CAAC;SAC1B,OAAO,CAAC,SAAS,CAAC;IACvB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,YAAY,EAAE,wDAAwD,CAAC;CAClG,CAAC;AAEF,kFAAkF;AAClF,SAAS,eAAe,CAAC,IAAY;IACnC,QAAQ,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QAC3B,KAAK,KAAK,CAAC;QACX,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,KAAK,CAAC;QACX,KAAK,aAAa;YAChB,OAAO,aAAa,CAAC;QACvB,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB;YACE,MAAM,IAAI,oBAAoB,CAAC,4CAA4C,CAAC,CAAC;IACjF,CAAC;AACH,CAAC","sourcesContent":["import type { BundleMode } from '@ms-cloudpack/common-types';\nimport { InvalidArgumentError, Option } from 'commander';\nimport { parseMatch } from './parseMatch.js';\n\n/**\n * These options are used by multiple commands, but should be manually added.\n */\nexport const reusedOptions = {\n logResolveMap: () => new Option('--log-resolve-map', 'Log the resolve map to \"resolve-map.json\" for diagnostics.'),\n /**\n * @param descriptionStart Start of description for this command, e.g. \"Bundle specific package(s)\"\n * (it will automatically include an optional version note and examples)\n */\n match: (descriptionStart: string) =>\n new Option(\n '--match <match...>',\n `${descriptionStart}, optionally with a version: e.g. \"foo\", \"@foo/*\", \"foo@1.2.3\"`,\n ).argParser(parseMatch),\n mode: (options: { action: 'bundle' | 'run' }) =>\n new Option(\n '--mode <mode>',\n `The mode to ${options.action === 'bundle' ? 'bundle the package' : 'run the app'} in. (library | production)`,\n )\n .argParser(parseBundleMode)\n .default('library'),\n noCache: () => new Option('--no-cache', 'Rebuild all packages, rather than using cached assets.'),\n};\n\n/** Parse the session mode based on user input (e.g. --mode argument in start.) */\nfunction parseBundleMode(mode: string): BundleMode {\n switch (mode.toLowerCase()) {\n case 'lib':\n case 'library':\n return 'library';\n case 'dev':\n case 'development':\n return 'development';\n case 'prod':\n case 'production':\n return 'production';\n default:\n throw new InvalidArgumentError(`Valid options are 'lib', 'dev', or 'prod'.`);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.72.
|
|
3
|
+
"version": "0.72.20",
|
|
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",
|
|
@@ -10,33 +10,33 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.56.
|
|
14
|
-
"@ms-cloudpack/app-server": "^0.17.
|
|
15
|
-
"@ms-cloudpack/bundler": "^0.23.
|
|
16
|
-
"@ms-cloudpack/common-types": "^0.23.
|
|
17
|
-
"@ms-cloudpack/config": "^0.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.56.8",
|
|
14
|
+
"@ms-cloudpack/app-server": "^0.17.15",
|
|
15
|
+
"@ms-cloudpack/bundler": "^0.23.18",
|
|
16
|
+
"@ms-cloudpack/common-types": "^0.23.4",
|
|
17
|
+
"@ms-cloudpack/config": "^0.33.1",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.8",
|
|
19
|
-
"@ms-cloudpack/overlay": "^0.17.
|
|
20
|
-
"@ms-cloudpack/package-utilities": "^10.
|
|
19
|
+
"@ms-cloudpack/overlay": "^0.17.96",
|
|
20
|
+
"@ms-cloudpack/package-utilities": "^10.4.0",
|
|
21
21
|
"@ms-cloudpack/path-string-parsing": "^1.2.5",
|
|
22
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
23
|
-
"@ms-cloudpack/remote-cache": "^0.9.
|
|
24
|
-
"@ms-cloudpack/setup-utilities": "^0.5.
|
|
22
|
+
"@ms-cloudpack/path-utilities": "^2.7.54",
|
|
23
|
+
"@ms-cloudpack/remote-cache": "^0.9.11",
|
|
24
|
+
"@ms-cloudpack/setup-utilities": "^0.5.2",
|
|
25
25
|
"@ms-cloudpack/task-reporter": "^0.14.6",
|
|
26
|
-
"@ms-cloudpack/telemetry": "^0.9.
|
|
26
|
+
"@ms-cloudpack/telemetry": "^0.9.5",
|
|
27
27
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
28
28
|
"commander": "^11.1.0",
|
|
29
29
|
"cross-spawn": "^7.0.3",
|
|
30
30
|
"didyoumean": "^1.2.2",
|
|
31
|
+
"fast-glob": "^3.2.12",
|
|
31
32
|
"get-port": "^7.0.0",
|
|
32
|
-
"glob-hasher": "^1.4.2",
|
|
33
33
|
"open": "^9.0.0",
|
|
34
34
|
"prompts": "^2.4.2",
|
|
35
35
|
"semver": "^7.6.0",
|
|
36
36
|
"workspace-tools": "^0.38.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@ms-cloudpack/common-types": "^0.23.
|
|
39
|
+
"@ms-cloudpack/common-types": "^0.23.4",
|
|
40
40
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
41
41
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
42
42
|
"@ms-cloudpack/test-utilities": "^0.5.0",
|