@ms-cloudpack/cli 0.77.10 → 0.77.12

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.
@@ -55,7 +55,7 @@ export async function evaluateImportsForOverrides(options, context) {
55
55
  else {
56
56
  // If we included or removed an excluded dependency, we need to ensure it is in the resolve map.
57
57
  // TODO: this is somewhat broken https://github.com/microsoft/cloudpack/issues/2390
58
- ({ dependencyPath, updatedResolution } = await ensureResolveMapEntry({ definition, packagePath, dependencyName, resolveMap, appPath }, { packages }));
58
+ ({ dependencyPath, updatedResolution } = await ensureResolveMapEntry({ definition, packagePath, dependencyName, resolveMap, appPath, moduleResolutionConfig: config.resolve }, { packages }));
59
59
  }
60
60
  // If the dependency is not resolved, add an error.
61
61
  if (!dependencyPath) {
@@ -1 +1 @@
1
- {"version":3,"file":"evaluateImportsForOverrides.js","sourceRoot":"","sources":["../../../src/commands/init/evaluateImportsForOverrides.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,iCAAiC,EACjC,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,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;AAgCxB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAA2C,EAC3C,OAA2C;IAE3C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IACnE,MAAM,E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C,EAAE;KAC3D,CAAC;AACJ,CAAC","sourcesContent":["import type { BundleInfo, PartialContext } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\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 {\n addExportsMapEntry,\n ensureResolveMapEntry,\n flattenExportsMap,\n getDependencies,\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\nexport interface EvaluateImportsForOverridesOptions {\n /** Path being evaluated */\n packagePath: string;\n /** Bundle result info for `packagePath` */\n info: BundleInfo;\n /** Package definition for `packagePath` */\n definition: PackageJson;\n /** Info about how the parent package imported `packagePath` (name and version used) */\n importerContext: PackageImporterContext | undefined;\n}\n\nexport type EvaluateImportsForOverridesContext = PartialContext<'packages', 'config' | 'resolveMap'>;\n\nexport interface EvaluateImportsForOverridesResult {\n /** Export changes made to the generated config */\n exportsChanges: GeneratedPackageChanges[];\n /** Included dependencies changes made to the generated config */\n includedDependenciesChanges: GeneratedPackageChanges[];\n /** Required removed excluded dependencies changes made to the generated config */\n removedExcludedDependenciesChanges: 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\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 *\n * **Mutates `context.session.config.generated.packageSettings` and potentially `context.session.resolveMap`.**\n */\nexport async function evaluateImportsForOverrides(\n options: EvaluateImportsForOverridesOptions,\n context: EvaluateImportsForOverridesContext,\n): Promise<EvaluateImportsForOverridesResult> {\n const { info, definition, packagePath, importerContext } = options;\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const { appPath } = config;\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 removedExcludedDependenciesChanges: 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 allDependencies = getDependencies(definition, { includeAll: true });\n const originalDefinition = await packages.get(packagePath, { disableTransforms: true });\n const allOriginalDependencies = getDependencies(originalDefinition, { includeAll: true });\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 let dependencyPath: string | undefined;\n let updatedResolution = false;\n if (dependencyName === packageName) {\n dependencyPath = packagePath;\n } else {\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 ({ dependencyPath, updatedResolution } = await ensureResolveMapEntry(\n { definition, packagePath, dependencyName, resolveMap, appPath },\n { packages },\n ));\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 const { bundlerCapabilities } = dependencyDefinition.cloudpack || {};\n const dependencyResolveWebExtensions =\n // eslint-disable-next-line etc/no-deprecated\n bundlerCapabilities?.['resolve-web-extensions'] ?? Boolean(config.features?.resolveWebExtensions);\n\n // If the dependency is not listed, add to includedDependencies.\n if (!dependencies[dependencyName] && dependencyName !== packageName && !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 // The parent if-condition (!dependencies[dependencyName]) already checks if it was added\n // in either user or generated configuration, so we only need to warn for truly undeclared deps.\n if (!allOriginalDependencies[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 // This ensures its PackageJson.cloudpack is updated accounting for the new dependency.\n // TODO could we just refresh the package definition here and skip this step?\n // (does it do anything else besides refreshing the package definition?)\n pathsToEvaluate.set(packagePath, importerContext);\n\n // Add to includedDependencies if appropriate.\n generatedPackageSettings ??= await ensureGeneratedSettingsForPackage({ packagePath }, { config, packages });\n\n const isExcludedDependency = generatedPackageSettings.excludedDependencies?.includes(dependencyName);\n\n // Excluded dependencies that don't update resolution will be handled later during optimize dependencies.\n if (updatedResolution && isExcludedDependency && generatedPackageSettings.excludedDependencies) {\n const indexOfDependency = generatedPackageSettings.excludedDependencies.indexOf(dependencyName);\n generatedPackageSettings.excludedDependencies.splice(indexOfDependency, 1);\n\n // Report that we removed a dependency from excluded as it is now imported by the package.\n removedExcludedDependenciesChanges.push({\n name: packageName,\n version: packageVersion,\n path: packagePath,\n changes: [\n {\n type: 'removed-excluded-dependency-required',\n change: dependencyName,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n } else if (!isExcludedDependency && !generatedPackageSettings.includedDependencies?.includes(dependencyName)) {\n // If the dependency is not excluded, we need to add it to includedDependencies.\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 // If the resolution was updated, this is a required change.\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 (allDependencies[dependencyName]) {\n dependencyImporterContext = {\n parentName: packageName,\n parentVersion: packageVersion,\n importedName: dependencyName,\n // TODO should this use the original version requirement even for dev deps (which might not\n // be installed at that version)?\n versionRequirement: allDependencies[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(\n { packagePath: dependencyPath, disableTransforms: true, resolveWebExtensions: dependencyResolveWebExtensions },\n { packages, config },\n ),\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 resolveWebExtensions: dependencyResolveWebExtensions,\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 {\n exportsChanges,\n includedDependenciesChanges,\n removedExcludedDependenciesChanges,\n errors,\n warnings,\n pathsToEvaluate,\n pathsToRefresh,\n };\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":"AAOA,OAAO,EACL,iCAAiC,EACjC,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,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;AAgCxB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAA2C,EAC3C,OAA2C;IAE3C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IACnE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAE3B,MAAM,EAAE,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Ac,IAAI,OAAO,KAAK,oBAAoB,GAAG;qBACtE,EACD,CAAC,CACF,EAAE,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI;oBACJ,MAAM,EAAE,kBAAkB;oBAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;iBAChC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,cAAc;QACd,2BAA2B;QAC3B,kCAAkC;QAClC,MAAM;QACN,QAAQ;QACR,eAAe;QACf,cAAc;KACf,CAAC;AACJ,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, PartialContext } from '@ms-cloudpack/api-server';\nimport type {\n BundleMessage,\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 {\n addExportsMapEntry,\n ensureResolveMapEntry,\n flattenExportsMap,\n getDependencies,\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\nexport interface EvaluateImportsForOverridesOptions {\n /** Path being evaluated */\n packagePath: string;\n /** Bundle result info for `packagePath` */\n info: BundleInfo;\n /** Package definition for `packagePath` */\n definition: PackageJson;\n /** Info about how the parent package imported `packagePath` (name and version used) */\n importerContext: PackageImporterContext | undefined;\n}\n\nexport type EvaluateImportsForOverridesContext = PartialContext<'packages', 'config' | 'resolveMap'>;\n\nexport interface EvaluateImportsForOverridesResult {\n /** Export changes made to the generated config */\n exportsChanges: GeneratedPackageChanges[];\n /** Included dependencies changes made to the generated config */\n includedDependenciesChanges: GeneratedPackageChanges[];\n /** Required removed excluded dependencies changes made to the generated config */\n removedExcludedDependenciesChanges: 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\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 *\n * **Mutates `context.session.config.generated.packageSettings` and potentially `context.session.resolveMap`.**\n */\nexport async function evaluateImportsForOverrides(\n options: EvaluateImportsForOverridesOptions,\n context: EvaluateImportsForOverridesContext,\n): Promise<EvaluateImportsForOverridesResult> {\n const { info, definition, packagePath, importerContext } = options;\n const { packages, session } = context;\n const { config, resolveMap } = session;\n const { appPath } = config;\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 removedExcludedDependenciesChanges: 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 allDependencies = getDependencies(definition, { includeAll: true });\n const originalDefinition = await packages.get(packagePath, { disableTransforms: true });\n const allOriginalDependencies = getDependencies(originalDefinition, { includeAll: true });\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 let dependencyPath: string | undefined;\n let updatedResolution = false;\n if (dependencyName === packageName) {\n dependencyPath = packagePath;\n } else {\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 ({ dependencyPath, updatedResolution } = await ensureResolveMapEntry(\n { definition, packagePath, dependencyName, resolveMap, appPath, moduleResolutionConfig: config.resolve },\n { packages },\n ));\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 const { bundlerCapabilities } = dependencyDefinition.cloudpack || {};\n const dependencyResolveWebExtensions =\n // eslint-disable-next-line etc/no-deprecated\n bundlerCapabilities?.['resolve-web-extensions'] ?? Boolean(config.features?.resolveWebExtensions);\n\n // If the dependency is not listed, add to includedDependencies.\n if (!dependencies[dependencyName] && dependencyName !== packageName && !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 // The parent if-condition (!dependencies[dependencyName]) already checks if it was added\n // in either user or generated configuration, so we only need to warn for truly undeclared deps.\n if (!allOriginalDependencies[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 // This ensures its PackageJson.cloudpack is updated accounting for the new dependency.\n // TODO could we just refresh the package definition here and skip this step?\n // (does it do anything else besides refreshing the package definition?)\n pathsToEvaluate.set(packagePath, importerContext);\n\n // Add to includedDependencies if appropriate.\n generatedPackageSettings ??= await ensureGeneratedSettingsForPackage({ packagePath }, { config, packages });\n\n const isExcludedDependency = generatedPackageSettings.excludedDependencies?.includes(dependencyName);\n\n // Excluded dependencies that don't update resolution will be handled later during optimize dependencies.\n if (updatedResolution && isExcludedDependency && generatedPackageSettings.excludedDependencies) {\n const indexOfDependency = generatedPackageSettings.excludedDependencies.indexOf(dependencyName);\n generatedPackageSettings.excludedDependencies.splice(indexOfDependency, 1);\n\n // Report that we removed a dependency from excluded as it is now imported by the package.\n removedExcludedDependenciesChanges.push({\n name: packageName,\n version: packageVersion,\n path: packagePath,\n changes: [\n {\n type: 'removed-excluded-dependency-required',\n change: dependencyName,\n reason: `Imported by \"${displayName}\"`,\n },\n ],\n });\n } else if (!isExcludedDependency && !generatedPackageSettings.includedDependencies?.includes(dependencyName)) {\n // If the dependency is not excluded, we need to add it to includedDependencies.\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 // If the resolution was updated, this is a required change.\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 (allDependencies[dependencyName]) {\n dependencyImporterContext = {\n parentName: packageName,\n parentVersion: packageVersion,\n importedName: dependencyName,\n // TODO should this use the original version requirement even for dev deps (which might not\n // be installed at that version)?\n versionRequirement: allDependencies[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(\n { packagePath: dependencyPath, disableTransforms: true, resolveWebExtensions: dependencyResolveWebExtensions },\n { packages, config },\n ),\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 resolveWebExtensions: dependencyResolveWebExtensions,\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 {\n exportsChanges,\n includedDependenciesChanges,\n removedExcludedDependenciesChanges,\n errors,\n warnings,\n pathsToEvaluate,\n pathsToRefresh,\n };\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":"linkToRemoteSession.d.ts","sourceRoot":"","sources":["../../../src/commands/link/linkToRemoteSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAoB3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,mBAAmB,CAAC,WAAW,GAAG,aAAa,CAAC,GACvD,OAAO,CAAC,iBAAiB,CAAC,CA6J5B"}
1
+ {"version":3,"file":"linkToRemoteSession.d.ts","sourceRoot":"","sources":["../../../src/commands/link/linkToRemoteSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAoB3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,mBAAmB,CAAC,WAAW,GAAG,aAAa,CAAC,GACvD,OAAO,CAAC,iBAAiB,CAAC,CAgK5B"}
@@ -69,6 +69,8 @@ export async function linkToRemoteSession(params) {
69
69
  return hostConfigResult.result;
70
70
  }
71
71
  const hostConfig = hostConfigResult.result;
72
+ // This exclusive to the local repo.
73
+ delete hostConfig?.resolve;
72
74
  hostConfig.packageSettings?.forEach((settings) => {
73
75
  // We need to delete bundler capabilities that are not internal as they won't work.
74
76
  // TODO: Figure out a way to support them.
@@ -1 +1 @@
1
- {"version":3,"file":"linkToRemoteSession.js","sourceRoot":"","sources":["../../../src/commands/link/linkToRemoteSession.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,sBAAsB,GAIvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAwD;IAExD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACjD,MAAM,EACJ,MAAM,EACN,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,UAAU,EACf,iBAAiB,EACjB,eAAe,EACf,aAAa,GACd,GAAG,OAAO,CAAC;IAEZ,MAAM,aAAa,GAAG,MAAM,4BAA4B,CAAC;QACvD,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;QAC9B,WAAW,EAAE,0BAA0B;KACxC,CAAC,CAAC;IACH,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,EAAE,SAAS,EA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,EAAE,mBAAmB,MAAM,+BAA+B,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,KAAK,UAAU,yBAAyB,CACtC,SAAqB;QAErB,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;YACxB,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,EAAsC,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YACjG,oBAAoB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAqD,EAAE,CAAC,CAAC;gBACxF,YAAY,EAAE,IAAI;gBAClB,MAAM;aACP,CAAC,CAAC;SACJ,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAAC,SAA0B,EAAE,YAAoB;IAC9E,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE;QACzC,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;QAEhD,qDAAqD;QACrD,IAAI,cAAc,IAAI,gBAAgB,KAAK,CAAC,EAAE,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,yDAAyD,EAAE,YAAY,CAAC,CAAC;YACtF,cAAc,GAAG,KAAK,CAAC;QACzB,CAAC;aAAM,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;YAChC,cAAc,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,wBAAwB;IAElC,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { CommandActionParams, CommandExitParams } from '../../types/CommandAction.js';\nimport {\n createApiContext,\n apiServerPort,\n waitForBusData,\n linkConfigSource,\n linkPathsSource,\n linkDoneSource,\n linkDisconnectedSource,\n type LinkPathOutput,\n type Context,\n type CloudpackServer,\n} from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport type { CloudpackConfig, CloudpackLinkConfig } from '@ms-cloudpack/common-types';\nimport { filterInternalCapabilities } from '@ms-cloudpack/bundler-capabilities';\nimport { createLinkResolveMap, mergeObjects } from '@ms-cloudpack/package-utilities';\nimport { createApiServer } from '../../utilities/createApiServer.js';\nimport { openBrowser } from '../start/openBrowser.js';\nimport type { LinkOptions } from './types/LinkOptions.js';\nimport type { SharedOptions } from '../../types/SharedOptions.js';\nimport { resolveCloudpackInternalPath } from '../../utilities/resolveCloudpackInternalPath.js';\nimport { createRemoteApiUrls } from './createRemoteApiUrls.js';\nimport { disposeServer } from '../../utilities/disposeServer.js';\n\n/**\n * Handles the remote linking process\n */\nexport async function linkToRemoteSession(\n params: CommandActionParams<LinkOptions & SharedOptions>,\n): Promise<CommandExitParams> {\n const { options, appPath, autoDispose } = params;\n const {\n remote,\n ignore: ignoredPackages,\n all: includeAll,\n ignoreResolutions,\n resolveStrategy,\n logResolveMap,\n } = options;\n\n const linkProxyPath = await resolveCloudpackInternalPath({\n importMetaUrl: import.meta.url,\n packageName: '@ms-cloudpack/link-proxy',\n });\n if (!linkProxyPath) {\n return { hasErrors: true, message: 'Failed to resolve link proxy path' };\n }\n\n // Override routes to default to serve link proxy instead.\n // TODO: Should this be done earlier to avoid the side effect that happens while reading the config?\n delete params.config.routes;\n\n const context = autoDispose(\n await createApiContext({\n ...params,\n // Load the link proxy to the resolve map to load it later.\n additionalPaths: [linkProxyPath],\n // Skip resolving dependencies, as we will load the resolve map later.\n skipResolveDependencies: true,\n }),\n );\n\n const { session, packages, packageHashes, bus } = context;\n\n // Start api server for tracking status and handling remote requests.\n const apiServerResult = await createApiServer(\n // Create the api server at different ports to avoid conflicts.\n { port: apiServerPort.map((p) => p + apiServerPort.length) },\n context,\n );\n if (apiServerResult.hasErrors) {\n return apiServerResult;\n }\n\n const { apiServer } = apiServerResult;\n autoDispose({ dispose: () => disposeServer('API server', apiServer) });\n\n // Get possible host api server urls.\n session.urls.hostApiServer = createRemoteApiUrls({ remote, apiServerUrl: apiServer.url });\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 // Start the app server with the link proxy.\n definition: await packages.get(linkProxyPath),\n bundleServerOptions: { disableCache: !options.cache },\n },\n context,\n );\n autoDispose({ dispose: () => disposeServer('app server', servers.appServer) });\n autoDispose({ dispose: () => disposeServer('bundle server', servers.bundleServer) });\n\n if (!session.urls.appServer || !session.urls.bundleServer) {\n return { hasErrors: true, message: 'Failed to start app server' };\n }\n\n void openBrowser({ url: session.urls.appServer }, context).catch((err: unknown) => {\n console.warn('Error opening browser:', (err as Error | undefined)?.stack || err);\n console.warn('Please open the browser manually to:', session.urls.appServer);\n });\n\n // Setup disconnection handling\n const { disconnectionPromise, withDisconnectionHandling } = createDisconnectionHandler(bus);\n\n // Get config from host api server.\n console.debug('Attempting to fetch host config from the bus.');\n const hostConfigResult = await withDisconnectionHandling(\n waitForBusData<CloudpackLinkConfig>({ bus, source: linkConfigSource }),\n );\n\n // Check if disconnection happened\n if (hostConfigResult.disconnected) {\n return hostConfigResult.result;\n }\n\n const hostConfig = hostConfigResult.result as CloudpackConfig;\n\n hostConfig.packageSettings?.forEach((settings) => {\n // We need to delete bundler capabilities that are not internal as they won't work.\n // TODO: Figure out a way to support them.\n if (settings.bundlerCapabilities) {\n settings.bundlerCapabilities = filterInternalCapabilities(settings.bundlerCapabilities);\n }\n });\n\n console.debug('Host config received:', hostConfig);\n // Merge host config with local config.\n const mergedConfig = mergeObjects([hostConfig, params.config]);\n session.config = mergedConfig;\n\n packages.reset({ newConfig: mergedConfig });\n\n console.debug('Searching for packages from paths:', appPath);\n\n // Use settings to find partial link app map.\n // Update the resolve map with the linked packages.\n context.session.resolveMap = await createLinkResolveMap({ appPath, additionalPaths: [linkProxyPath] }, context);\n\n bus.publish(linkPathsSource, {\n linkedPath: {\n path: appPath,\n ignoredPackages,\n includeAll,\n ignoreResolutions,\n resolveStrategy,\n remote: {\n // Host app must route linked paths to the bundle server.\n hostUrl: session.urls.bundleServer,\n // Linked session resolve map to resolve dependencies on the host.\n resolveMap: context.session.resolveMap,\n // Send the package definitions to create the import map.\n packages: packages.toSerializable(),\n // We must send all external hashes for the linked packages and then update internal hashes on change.\n packageHashes: packageHashes.toSerializable(),\n },\n },\n });\n\n // Get result from host.\n console.debug('Waiting for host to link paths...');\n const linkPathResult = await withDisconnectionHandling(\n waitForBusData<LinkPathOutput>({ bus, source: linkDoneSource }),\n );\n\n // Check if disconnection happened\n if (linkPathResult.disconnected) {\n return linkPathResult.result;\n }\n\n const result = linkPathResult.result;\n console.debug('Host linked paths:', result.linkedPaths);\n\n // Monitor client connections\n const connectionMonitor = setupConnectionMonitor(apiServer, session.urls.appServer);\n autoDispose({ dispose: () => clearInterval(connectionMonitor) });\n\n // Wait for the host to send back the resolve map and linked paths.\n if (logResolveMap) {\n // Write the linked resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map-linked.json'), result.resolveMap);\n }\n\n console.debug('Linked paths:', result.linkedPaths);\n\n return disconnectionPromise;\n}\n\n/**\n * Creates a disconnection handler that wraps promises\n */\nfunction createDisconnectionHandler(bus: Context['bus']) {\n // Create a promise that will resolve when host disconnection is detected\n const disconnectionPromise = new Promise<CommandExitParams>((res) => {\n // Listen for host disconnection events\n bus.subscribe(linkDisconnectedSource, ({ reason }: { reason: string }) => {\n res({ hasErrors: true, message: `Host connection ${reason}. Shutting down link session.` });\n });\n });\n\n async function withDisconnectionHandling<T>(\n operation: Promise<T>,\n ): Promise<{ disconnected: false; result: T } | { disconnected: true; result: CommandExitParams }> {\n return await Promise.race([\n operation.then((result): { disconnected: false; result: T } => ({ disconnected: false, result })),\n disconnectionPromise.then((result): { disconnected: true; result: CommandExitParams } => ({\n disconnected: true,\n result,\n })),\n ]);\n }\n\n return { disconnectionPromise, withDisconnectionHandling };\n}\n\n/**\n * Setup client connection monitoring\n */\nfunction setupConnectionMonitor(apiServer: CloudpackServer, appServerUrl: string) {\n let hadConnections = false;\n const connectionMonitor = setInterval(() => {\n const connectedClients = apiServer.clients.size;\n\n // If we previously had connections and now have none\n if (hadConnections && connectedClients === 0) {\n console.warn('Browser connection lost. Please reopen your browser to:', appServerUrl);\n hadConnections = false;\n } else if (connectedClients > 0) {\n hadConnections = true;\n }\n }, 5000); // Check every 5 seconds\n\n return connectionMonitor;\n}\n"]}
1
+ {"version":3,"file":"linkToRemoteSession.js","sourceRoot":"","sources":["../../../src/commands/link/linkToRemoteSession.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,sBAAsB,GAIvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAwD;IAExD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACjD,MAAM,EACJ,MAAM,EACN,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,UAAU,EACf,iBAAiB,EACjB,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AAE,CAAC;YAChC,cAAc,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,wBAAwB;IAElC,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { CommandActionParams, CommandExitParams } from '../../types/CommandAction.js';\nimport {\n createApiContext,\n apiServerPort,\n waitForBusData,\n linkConfigSource,\n linkPathsSource,\n linkDoneSource,\n linkDisconnectedSource,\n type LinkPathOutput,\n type Context,\n type CloudpackServer,\n} from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\nimport type { CloudpackConfig, CloudpackLinkConfig } from '@ms-cloudpack/common-types';\nimport { filterInternalCapabilities } from '@ms-cloudpack/bundler-capabilities';\nimport { createLinkResolveMap, mergeObjects } from '@ms-cloudpack/package-utilities';\nimport { createApiServer } from '../../utilities/createApiServer.js';\nimport { openBrowser } from '../start/openBrowser.js';\nimport type { LinkOptions } from './types/LinkOptions.js';\nimport type { SharedOptions } from '../../types/SharedOptions.js';\nimport { resolveCloudpackInternalPath } from '../../utilities/resolveCloudpackInternalPath.js';\nimport { createRemoteApiUrls } from './createRemoteApiUrls.js';\nimport { disposeServer } from '../../utilities/disposeServer.js';\n\n/**\n * Handles the remote linking process\n */\nexport async function linkToRemoteSession(\n params: CommandActionParams<LinkOptions & SharedOptions>,\n): Promise<CommandExitParams> {\n const { options, appPath, autoDispose } = params;\n const {\n remote,\n ignore: ignoredPackages,\n all: includeAll,\n ignoreResolutions,\n resolveStrategy,\n logResolveMap,\n } = options;\n\n const linkProxyPath = await resolveCloudpackInternalPath({\n importMetaUrl: import.meta.url,\n packageName: '@ms-cloudpack/link-proxy',\n });\n if (!linkProxyPath) {\n return { hasErrors: true, message: 'Failed to resolve link proxy path' };\n }\n\n // Override routes to default to serve link proxy instead.\n // TODO: Should this be done earlier to avoid the side effect that happens while reading the config?\n delete params.config.routes;\n\n const context = autoDispose(\n await createApiContext({\n ...params,\n // Load the link proxy to the resolve map to load it later.\n additionalPaths: [linkProxyPath],\n // Skip resolving dependencies, as we will load the resolve map later.\n skipResolveDependencies: true,\n }),\n );\n\n const { session, packages, packageHashes, bus } = context;\n\n // Start api server for tracking status and handling remote requests.\n const apiServerResult = await createApiServer(\n // Create the api server at different ports to avoid conflicts.\n { port: apiServerPort.map((p) => p + apiServerPort.length) },\n context,\n );\n if (apiServerResult.hasErrors) {\n return apiServerResult;\n }\n\n const { apiServer } = apiServerResult;\n autoDispose({ dispose: () => disposeServer('API server', apiServer) });\n\n // Get possible host api server urls.\n session.urls.hostApiServer = createRemoteApiUrls({ remote, apiServerUrl: apiServer.url });\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 // Start the app server with the link proxy.\n definition: await packages.get(linkProxyPath),\n bundleServerOptions: { disableCache: !options.cache },\n },\n context,\n );\n autoDispose({ dispose: () => disposeServer('app server', servers.appServer) });\n autoDispose({ dispose: () => disposeServer('bundle server', servers.bundleServer) });\n\n if (!session.urls.appServer || !session.urls.bundleServer) {\n return { hasErrors: true, message: 'Failed to start app server' };\n }\n\n void openBrowser({ url: session.urls.appServer }, context).catch((err: unknown) => {\n console.warn('Error opening browser:', (err as Error | undefined)?.stack || err);\n console.warn('Please open the browser manually to:', session.urls.appServer);\n });\n\n // Setup disconnection handling\n const { disconnectionPromise, withDisconnectionHandling } = createDisconnectionHandler(bus);\n\n // Get config from host api server.\n console.debug('Attempting to fetch host config from the bus.');\n const hostConfigResult = await withDisconnectionHandling(\n waitForBusData<CloudpackLinkConfig>({ bus, source: linkConfigSource }),\n );\n\n // Check if disconnection happened\n if (hostConfigResult.disconnected) {\n return hostConfigResult.result;\n }\n\n const hostConfig = hostConfigResult.result as CloudpackConfig;\n\n // This exclusive to the local repo.\n delete hostConfig?.resolve;\n\n hostConfig.packageSettings?.forEach((settings) => {\n // We need to delete bundler capabilities that are not internal as they won't work.\n // TODO: Figure out a way to support them.\n if (settings.bundlerCapabilities) {\n settings.bundlerCapabilities = filterInternalCapabilities(settings.bundlerCapabilities);\n }\n });\n\n console.debug('Host config received:', hostConfig);\n // Merge host config with local config.\n const mergedConfig = mergeObjects([hostConfig, params.config]);\n session.config = mergedConfig;\n\n packages.reset({ newConfig: mergedConfig });\n\n console.debug('Searching for packages from paths:', appPath);\n\n // Use settings to find partial link app map.\n // Update the resolve map with the linked packages.\n context.session.resolveMap = await createLinkResolveMap({ appPath, additionalPaths: [linkProxyPath] }, context);\n\n bus.publish(linkPathsSource, {\n linkedPath: {\n path: appPath,\n ignoredPackages,\n includeAll,\n ignoreResolutions,\n resolveStrategy,\n remote: {\n // Host app must route linked paths to the bundle server.\n hostUrl: session.urls.bundleServer,\n // Linked session resolve map to resolve dependencies on the host.\n resolveMap: context.session.resolveMap,\n // Send the package definitions to create the import map.\n packages: packages.toSerializable(),\n // We must send all external hashes for the linked packages and then update internal hashes on change.\n packageHashes: packageHashes.toSerializable(),\n },\n },\n });\n\n // Get result from host.\n console.debug('Waiting for host to link paths...');\n const linkPathResult = await withDisconnectionHandling(\n waitForBusData<LinkPathOutput>({ bus, source: linkDoneSource }),\n );\n\n // Check if disconnection happened\n if (linkPathResult.disconnected) {\n return linkPathResult.result;\n }\n\n const result = linkPathResult.result;\n console.debug('Host linked paths:', result.linkedPaths);\n\n // Monitor client connections\n const connectionMonitor = setupConnectionMonitor(apiServer, session.urls.appServer);\n autoDispose({ dispose: () => clearInterval(connectionMonitor) });\n\n // Wait for the host to send back the resolve map and linked paths.\n if (logResolveMap) {\n // Write the linked resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map-linked.json'), result.resolveMap);\n }\n\n console.debug('Linked paths:', result.linkedPaths);\n\n return disconnectionPromise;\n}\n\n/**\n * Creates a disconnection handler that wraps promises\n */\nfunction createDisconnectionHandler(bus: Context['bus']) {\n // Create a promise that will resolve when host disconnection is detected\n const disconnectionPromise = new Promise<CommandExitParams>((res) => {\n // Listen for host disconnection events\n bus.subscribe(linkDisconnectedSource, ({ reason }: { reason: string }) => {\n res({ hasErrors: true, message: `Host connection ${reason}. Shutting down link session.` });\n });\n });\n\n async function withDisconnectionHandling<T>(\n operation: Promise<T>,\n ): Promise<{ disconnected: false; result: T } | { disconnected: true; result: CommandExitParams }> {\n return await Promise.race([\n operation.then((result): { disconnected: false; result: T } => ({ disconnected: false, result })),\n disconnectionPromise.then((result): { disconnected: true; result: CommandExitParams } => ({\n disconnected: true,\n result,\n })),\n ]);\n }\n\n return { disconnectionPromise, withDisconnectionHandling };\n}\n\n/**\n * Setup client connection monitoring\n */\nfunction setupConnectionMonitor(apiServer: CloudpackServer, appServerUrl: string) {\n let hadConnections = false;\n const connectionMonitor = setInterval(() => {\n const connectedClients = apiServer.clients.size;\n\n // If we previously had connections and now have none\n if (hadConnections && connectedClients === 0) {\n console.warn('Browser connection lost. Please reopen your browser to:', appServerUrl);\n hadConnections = false;\n } else if (connectedClients > 0) {\n hadConnections = true;\n }\n }, 5000); // Check every 5 seconds\n\n return connectionMonitor;\n}\n"]}
package/lib/main.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AASrD,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AASrD,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwD5E"}
package/lib/main.js CHANGED
@@ -11,6 +11,7 @@ import { satisfies } from 'semver';
11
11
  * Resolves all commands defined within the "./commands" folder.
12
12
  */
13
13
  export async function main(options = {}) {
14
+ process.title = 'cloudpack';
14
15
  // Check Node.js version compatibility before doing anything else
15
16
  const requiredNodeVersion = getNodeEngineRequirement();
16
17
  if (requiredNodeVersion && !satisfies(process.version, requiredNodeVersion)) {
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAUnC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,UAAgC,EAAE;IAC3D,iEAAiE;IACjE,MAAM,mBAAmB,GAAG,wBAAwB,EAAE,CAAC;IACvD,IAAI,m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AG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,+BAA+B,UAAU,IAAI,YAAY,MAAM,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzD,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAsB,CAAC;QAEtE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC","sourcesContent":["import { getDisplayVersion } from '@ms-cloudpack/package-utilities';\nimport { globSourceFiles } from '@ms-cloudpack/path-utilities';\nimport type { OutputConfiguration } from 'commander';\nimport path from 'path';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport type { CommandInitModule } from './types/CommandInitFunction.js';\nimport { PerfMarkerCliEntry } from './performance/markers.js';\nimport { CloudpackCommand } from './utilities/CloudpackCommand.js';\nimport { getNodeEngineRequirement } from './utilities/getNodeEngineRequirement.js';\nimport { satisfies } from 'semver';\n\n/** Override options for tests */\nexport interface MainOptions {\n cwd?: string;\n disableTelemetry?: boolean;\n argv?: string[];\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * Entry point for the cloudpack CLI.\n * Resolves all commands defined within the \"./commands\" folder.\n */\nexport async function main(options: Partial<MainOptions> = {}): Promise<void> {\n // Check Node.js version compatibility before doing anything else\n const requiredNodeVersion = getNodeEngineRequirement();\n if (requiredNodeVersion && !satisfies(process.version, requiredNodeVersion)) {\n console.error(`Cloudpack requires Node.js ${requiredNodeVersion}. Current version: ${process.version}.`);\n // eslint-disable-next-line no-restricted-properties -- exit immediately\n process.exit(1);\n }\n\n const {\n argv = [...process.argv],\n // eslint-disable-next-line no-restricted-properties -- this is where the default is supplied\n cwd = process.cwd(),\n disableTelemetry,\n outputOptions,\n } = options;\n\n performance.mark(PerfMarkerCliEntry);\n\n if (argv[3] === '--') {\n // Remove the \"--\" argument in case it's added by lage\n argv.splice(3, 1);\n }\n\n const version = getDisplayVersion(import.meta.url);\n\n // Create the top-level command and apply common options\n // (avoids \"unknown option\" errors if they're specified without a verb)\n const program = new CloudpackCommand({\n name: 'cloudpack',\n description: 'A tool for managing fast inner and outer looping in web apps. Requires a sub-command.',\n usage: '<command> [options]',\n outputOptions,\n programOptions: { cwd, version, argv, disableTelemetry },\n // The top-level command should realistically only ever be used with --help or --version,\n // so hide most of the options.\n hideSharedOptions: true,\n });\n\n // Get all the available commands\n const commandsGlob = 'commands/*/index';\n const commands = await globSourceFiles(import.meta.url, commandsGlob);\n if (!commands.length) {\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n throw new Error(`No commands found matching \"${currentDir}/${commandsGlob}.*\".`);\n }\n\n for (const commandPath of commands) {\n const commandUrl = pathToFileURL(commandPath).toString();\n const commandModule = (await import(commandUrl)) as CommandInitModule;\n\n commandModule.init(program);\n }\n\n await program.run();\n}\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAUnC;;;GAGG;AACH,MAAM,CA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AAM,QAAQ,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACtE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,+BAA+B,UAAU,IAAI,YAAY,MAAM,CAAC,CAAC;IACnF,CAAC;IAED,KAAK,MAAM,WAAW,IAAI,QAAQ,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC;QACzD,MAAM,aAAa,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAsB,CAAC;QAEtE,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;AACtB,CAAC","sourcesContent":["import { getDisplayVersion } from '@ms-cloudpack/package-utilities';\nimport { globSourceFiles } from '@ms-cloudpack/path-utilities';\nimport type { OutputConfiguration } from 'commander';\nimport path from 'path';\nimport { fileURLToPath, pathToFileURL } from 'url';\nimport type { CommandInitModule } from './types/CommandInitFunction.js';\nimport { PerfMarkerCliEntry } from './performance/markers.js';\nimport { CloudpackCommand } from './utilities/CloudpackCommand.js';\nimport { getNodeEngineRequirement } from './utilities/getNodeEngineRequirement.js';\nimport { satisfies } from 'semver';\n\n/** Override options for tests */\nexport interface MainOptions {\n cwd?: string;\n disableTelemetry?: boolean;\n argv?: string[];\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * Entry point for the cloudpack CLI.\n * Resolves all commands defined within the \"./commands\" folder.\n */\nexport async function main(options: Partial<MainOptions> = {}): Promise<void> {\n process.title = 'cloudpack';\n // Check Node.js version compatibility before doing anything else\n const requiredNodeVersion = getNodeEngineRequirement();\n if (requiredNodeVersion && !satisfies(process.version, requiredNodeVersion)) {\n console.error(`Cloudpack requires Node.js ${requiredNodeVersion}. Current version: ${process.version}.`);\n // eslint-disable-next-line no-restricted-properties -- exit immediately\n process.exit(1);\n }\n\n const {\n argv = [...process.argv],\n // eslint-disable-next-line no-restricted-properties -- this is where the default is supplied\n cwd = process.cwd(),\n disableTelemetry,\n outputOptions,\n } = options;\n\n performance.mark(PerfMarkerCliEntry);\n\n if (argv[3] === '--') {\n // Remove the \"--\" argument in case it's added by lage\n argv.splice(3, 1);\n }\n\n const version = getDisplayVersion(import.meta.url);\n\n // Create the top-level command and apply common options\n // (avoids \"unknown option\" errors if they're specified without a verb)\n const program = new CloudpackCommand({\n name: 'cloudpack',\n description: 'A tool for managing fast inner and outer looping in web apps. Requires a sub-command.',\n usage: '<command> [options]',\n outputOptions,\n programOptions: { cwd, version, argv, disableTelemetry },\n // The top-level command should realistically only ever be used with --help or --version,\n // so hide most of the options.\n hideSharedOptions: true,\n });\n\n // Get all the available commands\n const commandsGlob = 'commands/*/index';\n const commands = await globSourceFiles(import.meta.url, commandsGlob);\n if (!commands.length) {\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n throw new Error(`No commands found matching \"${currentDir}/${commandsGlob}.*\".`);\n }\n\n for (const commandPath of commands) {\n const commandUrl = pathToFileURL(commandPath).toString();\n const commandModule = (await import(commandUrl)) as CommandInitModule;\n\n commandModule.init(program);\n }\n\n await program.run();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.77.10",
3
+ "version": "0.77.12",
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",
@@ -18,25 +18,25 @@
18
18
  "cloudpack": "./bin/cloudpack.js"
19
19
  },
20
20
  "dependencies": {
21
- "@ms-cloudpack/api-server": "^0.64.24",
22
- "@ms-cloudpack/app-server": "^0.20.16",
23
- "@ms-cloudpack/bundler": "^0.26.1",
24
- "@ms-cloudpack/bundler-capabilities": "^0.3.4",
25
- "@ms-cloudpack/common-types": "^0.28.1",
26
- "@ms-cloudpack/config": "^0.38.6",
27
- "@ms-cloudpack/create-express-app": "^1.10.53",
21
+ "@ms-cloudpack/api-server": "^0.64.26",
22
+ "@ms-cloudpack/app-server": "^0.20.18",
23
+ "@ms-cloudpack/bundler": "^0.26.3",
24
+ "@ms-cloudpack/bundler-capabilities": "^0.4.0",
25
+ "@ms-cloudpack/common-types": "^0.29.0",
26
+ "@ms-cloudpack/config": "^0.38.8",
27
+ "@ms-cloudpack/create-express-app": "^1.10.55",
28
28
  "@ms-cloudpack/environment": "^0.1.1",
29
- "@ms-cloudpack/file-watcher": "^0.4.11",
29
+ "@ms-cloudpack/file-watcher": "^0.4.13",
30
30
  "@ms-cloudpack/json-utilities": "^0.1.11",
31
- "@ms-cloudpack/link-proxy": "^0.2.38",
32
- "@ms-cloudpack/overlay": "^0.19.34",
33
- "@ms-cloudpack/package-utilities": "^12.5.3",
31
+ "@ms-cloudpack/link-proxy": "^0.2.40",
32
+ "@ms-cloudpack/overlay": "^0.19.36",
33
+ "@ms-cloudpack/package-utilities": "^13.0.1",
34
34
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
35
- "@ms-cloudpack/path-utilities": "^3.1.24",
36
- "@ms-cloudpack/remote-cache": "^0.11.42",
37
- "@ms-cloudpack/setup-utilities": "^0.5.45",
35
+ "@ms-cloudpack/path-utilities": "^3.1.26",
36
+ "@ms-cloudpack/remote-cache": "^0.11.44",
37
+ "@ms-cloudpack/setup-utilities": "^0.5.47",
38
38
  "@ms-cloudpack/task-reporter": "^0.17.4",
39
- "@ms-cloudpack/telemetry": "^0.11.42",
39
+ "@ms-cloudpack/telemetry": "^0.11.44",
40
40
  "@yarnpkg/lockfile": "^1.1.0",
41
41
  "commander": "^14.0.0",
42
42
  "cross-spawn": "^7.0.3",
@@ -49,7 +49,7 @@
49
49
  "workspace-tools": "^0.38.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@ms-cloudpack/common-types": "^0.28.1",
52
+ "@ms-cloudpack/common-types": "^0.29.0",
53
53
  "@ms-cloudpack/common-types-browser": "^0.6.3",
54
54
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
55
55
  "@ms-cloudpack/scripts": "^0.0.1",
@@ -102,6 +102,26 @@
102
102
  "description": "Advanced use only: Override the bundler that's used by default (if a package's source type doesn't indicate that a specific bundler should be used, and there are no applicable package settings). This will **significantly** decrease performance and should only be modified if `ori` is incompatible with your repo/build for some reason.\n\nIn most cases, you should use `packageSettings` to change the bundler instead: for example, if your repo's packages must be built with rspack/webpack to support some custom config, use `packageSettings: [{ match: [\"@yourscope/*\", \"your-unscoped-package\"], bundler: \"rspack\" }]`.",
103
103
  "default": "ori"
104
104
  },
105
+ "resolve": {
106
+ "$ref": "#/definitions/ModuleResolutionConfig",
107
+ "description": "Configuration for module resolution, specifying where to look for modules."
108
+ },
109
+ "relay": {
110
+ "type": "object",
111
+ "properties": {
112
+ "rootDir": {
113
+ "type": "string"
114
+ },
115
+ "artifactDirectory": {
116
+ "type": "string"
117
+ }
118
+ },
119
+ "required": [
120
+ "rootDir"
121
+ ],
122
+ "additionalProperties": false,
123
+ "description": "Enables Relay support for generated artifacts.\n\nNote: Root directory will be resolved relative to the config directory."
124
+ },
105
125
  "$schema": {
106
126
  "type": "string"
107
127
  }
@@ -1218,6 +1238,29 @@
1218
1238
  "type": "boolean"
1219
1239
  }
1220
1240
  ]
1241
+ },
1242
+ "relay": {
1243
+ "anyOf": [
1244
+ {
1245
+ "type": "object",
1246
+ "additionalProperties": false,
1247
+ "properties": {
1248
+ "rootDir": {
1249
+ "type": "string"
1250
+ },
1251
+ "artifactDirectory": {
1252
+ "type": "string"
1253
+ }
1254
+ },
1255
+ "required": [
1256
+ "rootDir"
1257
+ ],
1258
+ "description": "Exclude null and undefined from T"
1259
+ },
1260
+ {
1261
+ "type": "boolean"
1262
+ }
1263
+ ]
1221
1264
  }
1222
1265
  },
1223
1266
  "description": "Options used in `PackageSettings` to configure or disable bundler capabilities.\n- Key: capability name, either internal (Cloudpack-provided) or external (as specified in `AppConfig.bundlerCapabilitiesRegistry`)\n- Value: options object to configure the capability, or false to disable it."
@@ -1271,6 +1314,19 @@
1271
1314
  ]
1272
1315
  },
1273
1316
  "description": "DefineFlags is an interface that represents a collection of global variables that will be defined on the window object. Each define flag is represented by a key-value pair"
1317
+ },
1318
+ "ModuleResolutionConfig": {
1319
+ "type": "object",
1320
+ "properties": {
1321
+ "modules": {
1322
+ "type": "array",
1323
+ "items": {
1324
+ "type": "string"
1325
+ },
1326
+ "description": "Folder names or directory paths where to find modules.\n\n**Note: This completely replaces the default node_modules lookup. To keep node_modules, include it explicitly: [\"node_modules\", \"{configDir}/store\"]**\n\nAbsolute and relative paths can both be used, but be aware that they will behave a bit differently.\n\nA relative path will be scanned similarly to how Node scans for node_modules, by looking through the current directory as well as its ancestors (i.e. ./node_modules, ../node_modules, and on).\n\nWith an absolute path, it will only search in the given directory.\n\nTemplate variables:\n- {configDir} can be used to build paths relative to the configuration directory. For example: {configDir}/store resolves to an absolute path pointing to the 'store' subdirectory within the directory containing the configuration file.\n\n Restrictions: - The {configDir} template must appear at the beginning of the path - Only one {configDir} template is allowed per path - Invalid: \"some/path/{configDir}\" or \"{configDir}/{configDir}/nested\" - Valid: \"{configDir}/store\", \"{configDir}/components\""
1327
+ }
1328
+ },
1329
+ "additionalProperties": false
1274
1330
  }
1275
1331
  }
1276
1332
  }
@@ -105,6 +105,26 @@
105
105
  "type": "string",
106
106
  "description": "Advanced use only: Override the bundler that's used by default (if a package's source type doesn't indicate that a specific bundler should be used, and there are no applicable package settings). This will **significantly** decrease performance and should only be modified if `ori` is incompatible with your repo/build for some reason.\n\nIn most cases, you should use `packageSettings` to change the bundler instead: for example, if your repo's packages must be built with rspack/webpack to support some custom config, use `packageSettings: [{ match: [\"@yourscope/*\", \"your-unscoped-package\"], bundler: \"rspack\" }]`.",
107
107
  "default": "ori"
108
+ },
109
+ "resolve": {
110
+ "$ref": "#/definitions/ModuleResolutionConfig",
111
+ "description": "Configuration for module resolution, specifying where to look for modules."
112
+ },
113
+ "relay": {
114
+ "type": "object",
115
+ "properties": {
116
+ "rootDir": {
117
+ "type": "string"
118
+ },
119
+ "artifactDirectory": {
120
+ "type": "string"
121
+ }
122
+ },
123
+ "required": [
124
+ "rootDir"
125
+ ],
126
+ "additionalProperties": false,
127
+ "description": "Enables Relay support for generated artifacts.\n\nNote: Root directory will be resolved relative to the config directory."
108
128
  }
109
129
  },
110
130
  "additionalProperties": false,
@@ -1219,6 +1239,29 @@
1219
1239
  "type": "boolean"
1220
1240
  }
1221
1241
  ]
1242
+ },
1243
+ "relay": {
1244
+ "anyOf": [
1245
+ {
1246
+ "type": "object",
1247
+ "additionalProperties": false,
1248
+ "properties": {
1249
+ "rootDir": {
1250
+ "type": "string"
1251
+ },
1252
+ "artifactDirectory": {
1253
+ "type": "string"
1254
+ }
1255
+ },
1256
+ "required": [
1257
+ "rootDir"
1258
+ ],
1259
+ "description": "Exclude null and undefined from T"
1260
+ },
1261
+ {
1262
+ "type": "boolean"
1263
+ }
1264
+ ]
1222
1265
  }
1223
1266
  },
1224
1267
  "description": "Options used in `PackageSettings` to configure or disable bundler capabilities.\n- Key: capability name, either internal (Cloudpack-provided) or external (as specified in `AppConfig.bundlerCapabilitiesRegistry`)\n- Value: options object to configure the capability, or false to disable it."
@@ -1272,6 +1315,19 @@
1272
1315
  ]
1273
1316
  },
1274
1317
  "description": "DefineFlags is an interface that represents a collection of global variables that will be defined on the window object. Each define flag is represented by a key-value pair"
1318
+ },
1319
+ "ModuleResolutionConfig": {
1320
+ "type": "object",
1321
+ "properties": {
1322
+ "modules": {
1323
+ "type": "array",
1324
+ "items": {
1325
+ "type": "string"
1326
+ },
1327
+ "description": "Folder names or directory paths where to find modules.\n\n**Note: This completely replaces the default node_modules lookup. To keep node_modules, include it explicitly: [\"node_modules\", \"{configDir}/store\"]**\n\nAbsolute and relative paths can both be used, but be aware that they will behave a bit differently.\n\nA relative path will be scanned similarly to how Node scans for node_modules, by looking through the current directory as well as its ancestors (i.e. ./node_modules, ../node_modules, and on).\n\nWith an absolute path, it will only search in the given directory.\n\nTemplate variables:\n- {configDir} can be used to build paths relative to the configuration directory. For example: {configDir}/store resolves to an absolute path pointing to the 'store' subdirectory within the directory containing the configuration file.\n\n Restrictions: - The {configDir} template must appear at the beginning of the path - Only one {configDir} template is allowed per path - Invalid: \"some/path/{configDir}\" or \"{configDir}/{configDir}/nested\" - Valid: \"{configDir}/store\", \"{configDir}/components\""
1328
+ }
1329
+ },
1330
+ "additionalProperties": false
1275
1331
  }
1276
1332
  },
1277
1333
  "properties": {