@ms-cloudpack/cli 0.72.27 → 0.72.28

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.
Files changed (45) hide show
  1. package/lib/commands/info/lockFile/readYarnLock.js +1 -1
  2. package/lib/commands/info/lockFile/readYarnLock.js.map +1 -1
  3. package/lib/commands/info/nonSemverDeps/getNonSemverDeps.js +1 -1
  4. package/lib/commands/info/nonSemverDeps/getNonSemverDeps.js.map +1 -1
  5. package/lib/commands/init/evaluateImportsForOverrides.d.ts +1 -2
  6. package/lib/commands/init/evaluateImportsForOverrides.d.ts.map +1 -1
  7. package/lib/commands/init/evaluateImportsForOverrides.js.map +1 -1
  8. package/lib/commands/init/evaluatePath.d.ts +1 -2
  9. package/lib/commands/init/evaluatePath.d.ts.map +1 -1
  10. package/lib/commands/init/evaluatePath.js.map +1 -1
  11. package/lib/commands/link/formatLinkSummary.d.ts +1 -1
  12. package/lib/commands/link/formatLinkSummary.d.ts.map +1 -1
  13. package/lib/commands/link/formatLinkSummary.js.map +1 -1
  14. package/lib/commands/start/execute.js +1 -1
  15. package/lib/commands/start/execute.js.map +1 -1
  16. package/lib/commands/sync/execute.d.ts +1 -1
  17. package/lib/commands/sync/execute.d.ts.map +1 -1
  18. package/lib/commands/sync/execute.js +4 -4
  19. package/lib/commands/sync/execute.js.map +1 -1
  20. package/lib/commands/sync/index.d.ts.map +1 -1
  21. package/lib/commands/sync/index.js +3 -4
  22. package/lib/commands/sync/index.js.map +1 -1
  23. package/lib/utilities/CloudpackCommand.js +2 -2
  24. package/lib/utilities/CloudpackCommand.js.map +1 -1
  25. package/lib/utilities/CommandExecutor.d.ts.map +1 -1
  26. package/lib/utilities/CommandExecutor.js +8 -14
  27. package/lib/utilities/CommandExecutor.js.map +1 -1
  28. package/lib/utilities/getFilteredPackages.d.ts +1 -2
  29. package/lib/utilities/getFilteredPackages.d.ts.map +1 -1
  30. package/lib/utilities/getFilteredPackages.js.map +1 -1
  31. package/lib/utilities/getRepositoryName.js +1 -1
  32. package/lib/utilities/getRepositoryName.js.map +1 -1
  33. package/package.json +17 -16
  34. package/lib/commands/sync/isSyncDisabledByUser.d.ts +0 -2
  35. package/lib/commands/sync/isSyncDisabledByUser.d.ts.map +0 -1
  36. package/lib/commands/sync/isSyncDisabledByUser.js +0 -7
  37. package/lib/commands/sync/isSyncDisabledByUser.js.map +0 -1
  38. package/lib/utilities/isCIBuild.d.ts +0 -5
  39. package/lib/utilities/isCIBuild.d.ts.map +0 -1
  40. package/lib/utilities/isCIBuild.js +0 -7
  41. package/lib/utilities/isCIBuild.js.map +0 -1
  42. package/lib/utilities/isCodespaces.d.ts +0 -5
  43. package/lib/utilities/isCodespaces.d.ts.map +0 -1
  44. package/lib/utilities/isCodespaces.js +0 -7
  45. package/lib/utilities/isCodespaces.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import fsPromises from 'fs/promises';
3
3
  import path from 'path';
4
- import { findProjectRoot } from '@ms-cloudpack/package-utilities';
4
+ import { findProjectRoot } from '@ms-cloudpack/path-utilities';
5
5
  // This module doesn't actually provide named exports for functions (types are wrong)
6
6
  import yarnLock from '@yarnpkg/lockfile';
7
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"readYarnLock.js","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/readYarnLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,qFAAqF;AACrF,OAAO,QAAiC,MAAM,mBAAmB,CAAC;AAElE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAEzC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,iDAAiD,GAAG,EAAE,CAAC;IAChE,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,YAAY,kDAAkD,CAAC;IAC3E,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACrE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACjD,OAAO,qCAAqC,CAAC;IAC/C,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC9C,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,2BAA2B,QAAQ,CAAC,IAAI,GAAG,CAAC;AACrD,CAAC","sourcesContent":["import fs from 'fs';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { findProjectRoot } from '@ms-cloudpack/package-utilities';\n// This module doesn't actually provide named exports for functions (types are wrong)\nimport yarnLock, { type LockFileObject } from '@yarnpkg/lockfile';\n\n/**\n * Read and parse the yarn v1 lock file at the project root (usually git root), if it exists.\n * @param cwd Find the project root from here.\n * @returns Parsed lock file contents if repo uses yarn v1 and parsing was successful,\n * or an error message otherwise.\n */\nexport async function readYarnLock(cwd: string): Promise<string | LockFileObject> {\n const projectRoot = findProjectRoot(cwd);\n\n if (!projectRoot) {\n return `Project or package root not found relative to ${cwd}`;\n }\n\n const yarnLockPath = path.join(projectRoot, 'yarn.lock');\n if (!fs.existsSync(yarnLockPath)) {\n return `${yarnLockPath} not found (this command only works with Yarn 1)`;\n }\n\n const lockContents = await fsPromises.readFile(yarnLockPath, 'utf8');\n if (!lockContents.includes('# yarn lockfile v1')) {\n return 'This command only works with Yarn 1';\n }\n\n const lockfile = yarnLock.parse(lockContents);\n if (lockfile.type === 'success') {\n return lockfile.object;\n }\n\n return `Error parsing lockfile (${lockfile.type})`;\n}\n"]}
1
+ {"version":3,"file":"readYarnLock.js","sourceRoot":"","sources":["../../../../src/commands/info/lockFile/readYarnLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,qFAAqF;AACrF,OAAO,QAAiC,MAAM,mBAAmB,CAAC;AAElE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAEzC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,iDAAiD,GAAG,EAAE,CAAC;IAChE,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,YAAY,kDAAkD,CAAC;IAC3E,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACrE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACjD,OAAO,qCAAqC,CAAC;IAC/C,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC9C,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,2BAA2B,QAAQ,CAAC,IAAI,GAAG,CAAC;AACrD,CAAC","sourcesContent":["import fs from 'fs';\nimport fsPromises from 'fs/promises';\nimport path from 'path';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\n// This module doesn't actually provide named exports for functions (types are wrong)\nimport yarnLock, { type LockFileObject } from '@yarnpkg/lockfile';\n\n/**\n * Read and parse the yarn v1 lock file at the project root (usually git root), if it exists.\n * @param cwd Find the project root from here.\n * @returns Parsed lock file contents if repo uses yarn v1 and parsing was successful,\n * or an error message otherwise.\n */\nexport async function readYarnLock(cwd: string): Promise<string | LockFileObject> {\n const projectRoot = findProjectRoot(cwd);\n\n if (!projectRoot) {\n return `Project or package root not found relative to ${cwd}`;\n }\n\n const yarnLockPath = path.join(projectRoot, 'yarn.lock');\n if (!fs.existsSync(yarnLockPath)) {\n return `${yarnLockPath} not found (this command only works with Yarn 1)`;\n }\n\n const lockContents = await fsPromises.readFile(yarnLockPath, 'utf8');\n if (!lockContents.includes('# yarn lockfile v1')) {\n return 'This command only works with Yarn 1';\n }\n\n const lockfile = yarnLock.parse(lockContents);\n if (lockfile.type === 'success') {\n return lockfile.object;\n }\n\n return `Error parsing lockfile (${lockfile.type})`;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { readJson } from '@ms-cloudpack/json-utilities';
2
- import { findProjectRoot } from '@ms-cloudpack/package-utilities';
2
+ import { findProjectRoot } from '@ms-cloudpack/path-utilities';
3
3
  import { table } from '@ms-cloudpack/task-reporter';
4
4
  import path from 'path';
5
5
  import semver from 'semver';
@@ -1 +1 @@
1
- {"version":3,"file":"getNonSemverDeps.js","sourceRoot":"","sources":["../../../../src/commands/info/nonSemverDeps/getNonSemverDeps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;A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Q,CAAC,CAAC,CAAC,OAAO,CAAC;IAE3C,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC1C,GAAG,CAAC,CAAC,GAAgB,EAAE,EAAE,CACxB,QAAQ;QACN,2DAA2D;SAC1D,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;SAClG,IAAI,CAAC,CAAC,CAAC;QACR,0BAA0B;SACzB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;SACpD,GAAG,CACF,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAgB,EAAE,CAAC,CAAC;QAC1C,MAAM,EAAE,GAAG,CAAC,IAAI;QAChB,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;QACxB,OAAO;KACR,CAAC,CACH,CACJ;SACA,IAAI,EAAE,CAAC;IAEV,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,kCAAkC,CAAC;IAC5C,CAAC;IAED,OAAO,CACL,KAAK,CAAC,aAAa,EAAE;QACnB,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,SAAS;KACnB,CAAC,GAAG,IAAI,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { findProjectRoot } from '@ms-cloudpack/package-utilities';\nimport { table } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport semver from 'semver';\nimport { getPackageInfos, type PackageInfo } from 'workspace-tools';\n\ninterface NonSemverDep {\n parent: string | undefined;\n depName: string;\n type: string;\n version: string | undefined;\n}\n\n// resolutions might apply to prod or dev dependencies, so include it just in case\nconst prodDeps = ['dependencies', 'peerDependencies', 'resolutions'] as const;\nconst allDeps = [...prodDeps, 'devDependencies'] as const;\n\nconst depTypeNames = {\n dependencies: 'prod',\n peerDependencies: 'peer',\n devDependencies: 'dev',\n resolutions: 'resolution',\n};\n\n/**\n * Check the local packages in the monorepo for non-semver deps.\n * Returns either a table of those deps or a message saying there are none.\n */\nexport async function getNonSemverDeps(params: {\n cwd: string;\n /** Only include production dependencies */\n prod?: boolean;\n /** Use this directory as the root instead of calling `findProjectRoot` (for testing) */\n overrideProjectRoot?: string;\n}): Promise<string> {\n const { cwd, prod, overrideProjectRoot } = params;\n\n const projectRoot = overrideProjectRoot || findProjectRoot(cwd) || cwd;\n const packages = getPackageInfos(projectRoot);\n\n // add the root package.json to the package infos\n const rootPkgJsonPath = path.join(projectRoot, 'package.json');\n const rootPkg = await readJson<PackageJson>(rootPkgJsonPath);\n if (!rootPkg) {\n throw new Error(`${rootPkgJsonPath} does not exist`);\n }\n if (!rootPkg.name || !rootPkg.version) {\n throw new Error(`${rootPkgJsonPath} is missing a name and/or version`);\n }\n packages[rootPkg.name] = rootPkg as PackageInfo;\n\n const depTypes = prod ? prodDeps : allDeps;\n\n const nonSemverDeps = Object.values(packages)\n .map((pkg: PackageJson) =>\n depTypes\n // get dependencies, peerDependencies, etc from the package\n .map((dt) => Object.entries(pkg[dt] || {}).map(([name, version]) => ({ name, version, type: dt })))\n .flat(1)\n // get non-semver versions\n .filter(({ version }) => !semver.validRange(version))\n .map(\n ({ name, version, type }): NonSemverDep => ({\n parent: pkg.name,\n depName: name,\n type: depTypeNames[type],\n version,\n }),\n ),\n )\n .flat();\n\n if (!nonSemverDeps.length) {\n return 'No non-semver dependencies found';\n }\n\n return (\n table(nonSemverDeps, {\n parent: 'Parent package',\n depName: 'Dependency',\n type: 'Dep type',\n version: 'Version',\n }) + '\\n'\n );\n}\n"]}
1
+ {"version":3,"file":"getNonSemverDeps.js","sourceRoot":"","sources":["../../../../src/commands/info/nonSemverDeps/getNonSemverDeps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAoB,MAAM,iBAAiB,CAAC;AASpE,kFAAkF;AAClF,MAAM,QAAQ,GAAG,CAAC,cAAc,EAAE,kBAAkB,EAAE,aAAa,CAAU,CAAC;AAC9E,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,EAAE,iBAAiB,CAAU,CAAC;AAE1D,MAAM,YAAY,GAAG;IACnB,YAAY,EAAE,MAAM;IACpB,gBAAgB,EAAE,MAAM;IACxB,eAAe,EAAE,KAAK;IACtB,WAAW,EAAE,YAAY;CAC1B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAMtC;IACC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAC;IAElD,MAAM,WAAW,GAAG,mBAAmB,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;IACvE,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IAE9C,iDAAiD;IACjD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAc,eAAe,CAAC,CAAC;IAC7D,IAAI,CA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EAAE,CAAC;QAC1B,OAAO,kCAAkC,CAAC;IAC5C,CAAC;IAED,OAAO,CACL,KAAK,CAAC,aAAa,EAAE;QACnB,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,SAAS;KACnB,CAAC,GAAG,IAAI,CACV,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport { table } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport semver from 'semver';\nimport { getPackageInfos, type PackageInfo } from 'workspace-tools';\n\ninterface NonSemverDep {\n parent: string | undefined;\n depName: string;\n type: string;\n version: string | undefined;\n}\n\n// resolutions might apply to prod or dev dependencies, so include it just in case\nconst prodDeps = ['dependencies', 'peerDependencies', 'resolutions'] as const;\nconst allDeps = [...prodDeps, 'devDependencies'] as const;\n\nconst depTypeNames = {\n dependencies: 'prod',\n peerDependencies: 'peer',\n devDependencies: 'dev',\n resolutions: 'resolution',\n};\n\n/**\n * Check the local packages in the monorepo for non-semver deps.\n * Returns either a table of those deps or a message saying there are none.\n */\nexport async function getNonSemverDeps(params: {\n cwd: string;\n /** Only include production dependencies */\n prod?: boolean;\n /** Use this directory as the root instead of calling `findProjectRoot` (for testing) */\n overrideProjectRoot?: string;\n}): Promise<string> {\n const { cwd, prod, overrideProjectRoot } = params;\n\n const projectRoot = overrideProjectRoot || findProjectRoot(cwd) || cwd;\n const packages = getPackageInfos(projectRoot);\n\n // add the root package.json to the package infos\n const rootPkgJsonPath = path.join(projectRoot, 'package.json');\n const rootPkg = await readJson<PackageJson>(rootPkgJsonPath);\n if (!rootPkg) {\n throw new Error(`${rootPkgJsonPath} does not exist`);\n }\n if (!rootPkg.name || !rootPkg.version) {\n throw new Error(`${rootPkgJsonPath} is missing a name and/or version`);\n }\n packages[rootPkg.name] = rootPkg as PackageInfo;\n\n const depTypes = prod ? prodDeps : allDeps;\n\n const nonSemverDeps = Object.values(packages)\n .map((pkg: PackageJson) =>\n depTypes\n // get dependencies, peerDependencies, etc from the package\n .map((dt) => Object.entries(pkg[dt] || {}).map(([name, version]) => ({ name, version, type: dt })))\n .flat(1)\n // get non-semver versions\n .filter(({ version }) => !semver.validRange(version))\n .map(\n ({ name, version, type }): NonSemverDep => ({\n parent: pkg.name,\n depName: name,\n type: depTypeNames[type],\n version,\n }),\n ),\n )\n .flat();\n\n if (!nonSemverDeps.length) {\n return 'No non-semver dependencies found';\n }\n\n return (\n table(nonSemverDeps, {\n parent: 'Parent package',\n depName: 'Dependency',\n type: 'Dep type',\n version: 'Version',\n }) + '\\n'\n );\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import type { BundleInfo } from '@ms-cloudpack/api-server';
2
- import type { BundleMessage, CloudpackConfig, PackageDefinitionsCache, PackageImporterContext, PackageJson } from '@ms-cloudpack/common-types';
3
- import type { ResolveMap } from '@ms-cloudpack/package-utilities';
2
+ import type { BundleMessage, CloudpackConfig, PackageDefinitionsCache, PackageImporterContext, PackageJson, ResolveMap } from '@ms-cloudpack/common-types';
4
3
  import type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';
5
4
  /**
6
5
  * Evaluate the imports depended on by a package to determine if missing exports map paths need to be added.
@@ -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,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"}
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,EAEX,UAAU,EACX,MAAM,4BAA4B,CAAC;AAepC,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"}
@@ -1 +1 @@
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,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AAK,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,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,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
+ {"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;AAC9B,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,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AAc,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 ResolveMap,\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 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,6 +1,5 @@
1
1
  import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server';
2
- import type { CloudpackConfig, PackageImporterContext } from '@ms-cloudpack/common-types';
3
- import type { ResolveMap } from '@ms-cloudpack/package-utilities';
2
+ import type { CloudpackConfig, PackageImporterContext, ResolveMap } from '@ms-cloudpack/common-types';
4
3
  import type { Span } from '@ms-cloudpack/telemetry';
5
4
  import type { InitSummaryData } from './InitSummaryData.js';
6
5
  import type { InitOptions } from './types/InitOptions.js';
@@ -1 +1 @@
1
- {"version":3,"file":"evaluatePath.d.ts","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAO1D;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAC1C,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,eAAe,EAAE,sBAAsB,GAAG,SAAS,CAAC;IACpD,wEAAwE;IACxE,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,eAAe,CAAC;IAC7B,GAAG,EAAE,2BAA2B,CAAC;IACjC,uDAAuD;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,kFAAkF;IAClF,QAAQ,EAAE,MAAM,CAAC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AAC;QAEH,MAAM,EAAE,eAAe,EAAE,4BAA4B,EAAE,cAAc,EAAE,2BAA2B,EAAE,GAClG,uBAAuB,CAAC;QAC1B,qBAAqB,GAAG,uBAAuB,CAAC,qBAAqB,CAAC;QAEtE,WAAW,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,CAAC;QAE1D,KAAK,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,4BAA4B,CAAC,OAAO,EAAE,EAAE,CAAC;YAC7E,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC7C,CAAC;QACD,2BAA2B,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,iGAAiG;IACjG,6EAA6E;IAC7E,wFAAwF;IACxF,qEAAqE;IAErE,IAAI,WAAW,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,IAAI,qBAAqB,EAAE,MAAM,CAAC,EAAE,CAAC;QACvG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,EAAE;YACjC,yFAAyF;YACzF,MAAM,EAAE,cAAc,IAAI,qBAAqB,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,4BAA4B;SAC/G,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,eAAe;QACf,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig, PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { Span } from '@ms-cloudpack/telemetry';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\n\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { evaluateDynamicImports } from './evaluateDynamicImports.js';\n\n/**\n * A helper which given the packagePath, tries to evaluate the path by bundling things, finding imports,\n * and cross checking the imports with explicit exports. If any exports are missing, they are documented\n * in the generated config.\n */\nexport async function evaluatePath(options: {\n /** Path to evaluate. */\n packagePath: string;\n /** Info about how the parent package */\n importerContext: PackageImporterContext | undefined;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n appPath: string;\n resolveMap: ResolveMap;\n span: Span;\n initOptions: InitOptions;\n summaryData: InitSummaryData;\n ctx: EnsurePackageBundledContext;\n /** Whether init is running in a multi-app scenario. */\n isMultiApp: boolean;\n shouldForce: boolean;\n /** The priority of the package being evaluated. To be used in the task runner. */\n priority: number;\n}): Promise<{\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 /** Whether a fatal error was encountered. */\n shouldExit?: boolean;\n}> {\n const {\n packagePath,\n config,\n initOptions,\n span,\n resolveMap,\n summaryData,\n ctx,\n importerContext,\n shouldForce,\n isMultiApp,\n priority,\n appPath,\n } = options;\n const { packages } = ctx;\n const { features } = config;\n\n // This line is the reason we have to track the importerContext for packages to evaluate:\n // otherwise if a non-semver package is read here, we'd lose the modifications from the initial\n // time the package was read (and getNonSemverTransform was called) when building the resolve map.\n const definition = await packages.get(packagePath, { refresh: true, importerContext });\n const { name, version } = definition;\n\n console.debug(`Evaluating ${packagePath} with context ${JSON.stringify(importerContext)}`);\n\n // Bundle the package and find the imports it depends on.\n const { result } = await ensurePackageBundled({\n input: {\n name,\n version,\n isIncremental: false,\n shouldGetBundleInfo: true,\n shouldForce,\n shouldRerun: shouldForce,\n useHashAsId: isMultiApp,\n priority,\n disableCache: !initOptions.cache,\n },\n ctx,\n });\n\n const { errors, warnings, info, outputPath } = result;\n\n // Record the results for the summary.\n summaryData.recordResult({ name, version, path: packagePath, errors, warnings, info, outputPath });\n\n // If there were errors or no imports, return early.\n if (errors?.length || !info) {\n return {};\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const {\n exportsChanges,\n includedDependenciesChanges,\n errors: evalErrors,\n pathsToEvaluate,\n pathsToRefresh,\n } = await evaluateImportsForOverrides({\n definition,\n packagePath,\n packages,\n info,\n config,\n resolveMap,\n importerContext,\n appPath,\n });\n\n if (evalErrors.length) {\n summaryData.addErrors(packagePath, evalErrors);\n }\n summaryData.recordGeneratedChanges(exportsChanges);\n summaryData.recordGeneratedChanges(includedDependenciesChanges);\n\n let dynamicImportsChanges: undefined | GeneratedPackageChanges[] = undefined;\n if (features?.evaluateDynamicImports) {\n const evaluatedDynamicImports = await evaluateDynamicImports({\n definition,\n packagePath,\n info,\n config,\n packages,\n importerContext,\n });\n\n const { pathsToEvaluate: dynamicImportPathsToEvaluate, pathsToRefresh: dynamicImportPathsToRefresh } =\n evaluatedDynamicImports;\n dynamicImportsChanges = evaluatedDynamicImports.dynamicImportsChanges;\n\n summaryData.recordGeneratedChanges(dynamicImportsChanges);\n\n for (const [evalPath, evalContext] of dynamicImportPathsToEvaluate.entries()) {\n pathsToEvaluate.set(evalPath, evalContext);\n }\n dynamicImportPathsToRefresh.forEach((path) => pathsToRefresh.add(path));\n }\n\n // Uncomment this when #1694 init does not cache packages correctly after editing config is fixed\n // and the heap does not reach the limit as almost every package is enqueued.\n // importPathsToEvaluate?.forEach((path) => pathsToEvaluate.set(path, importerContext));\n // importPathsToRefresh?.forEach((path) => pathsToRefresh.add(path));\n\n if (initOptions.check && (exportsChanges.length || evalErrors.length || dynamicImportsChanges?.length)) {\n span.addEvent('INIT_CHECK_FAILED', {\n // Don't log the specific errors to telemetry, as they may contain sensitive information.\n reason: exportsChanges || dynamicImportsChanges ? 'Config needs to be updated.' : 'Errors found with imports.',\n });\n\n return { shouldExit: true };\n }\n\n return {\n pathsToEvaluate,\n pathsToRefresh,\n };\n}\n"]}
1
+ {"version":3,"file":"evaluatePath.js","sourceRoot":"","sources":["../../../src/commands/init/evaluatePath.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAkBlC;IAQC,MAAM,EACJ,WAAW,EACX,MAAM,EACN,WAAW,EACX,IAAI,EACJ,UAAU,EACV,WAAW,EACX,GAAG,EACH,eAAe,EACf,WAAW,EACX,UAAU,EACV,QAAQ,EACR,OAAO,GACR,GAAG,OAAO,CAAC;IACZ,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;IACzB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAE5B,yFAAyF;IACzF,+FAA+F;IAC/F,kGAAkG;IAClG,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IACvF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IAErC,OAAO,CAAC,KAAK,CAAC,cAAc,WAAW,iBAAiB,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAE3F,yDAAyD;IACzD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,oBAAoB,CAAC;QAC5C,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;YACP,aAAa,EAAE,KAAK;YACpB,mBAAmB,EAAE,IAAI;YACzB,WAAW;YACX,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,UAAU;YACvB,QAAQ;YACR,YAAY,EAAE,CAAC,WA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tE,WAAW,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,CAAC;QAE1D,KAAK,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,4BAA4B,CAAC,OAAO,EAAE,EAAE,CAAC;YAC7E,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC7C,CAAC;QACD,2BAA2B,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,iGAAiG;IACjG,6EAA6E;IAC7E,wFAAwF;IACxF,qEAAqE;IAErE,IAAI,WAAW,CAAC,KAAK,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,IAAI,qBAAqB,EAAE,MAAM,CAAC,EAAE,CAAC;QACvG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,EAAE;YACjC,yFAAyF;YACzF,MAAM,EAAE,cAAc,IAAI,qBAAqB,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,4BAA4B;SAC/G,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,eAAe;QACf,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import type { EnsurePackageBundledContext } from '@ms-cloudpack/api-server';\nimport type { CloudpackConfig, PackageImporterContext, ResolveMap } from '@ms-cloudpack/common-types';\nimport type { Span } from '@ms-cloudpack/telemetry';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\n\nimport { ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { evaluateImportsForOverrides } from './evaluateImportsForOverrides.js';\nimport { evaluateDynamicImports } from './evaluateDynamicImports.js';\n\n/**\n * A helper which given the packagePath, tries to evaluate the path by bundling things, finding imports,\n * and cross checking the imports with explicit exports. If any exports are missing, they are documented\n * in the generated config.\n */\nexport async function evaluatePath(options: {\n /** Path to evaluate. */\n packagePath: string;\n /** Info about how the parent package */\n importerContext: PackageImporterContext | undefined;\n /** Config so far. This will be modified if new overrides are needed. */\n config: CloudpackConfig;\n appPath: string;\n resolveMap: ResolveMap;\n span: Span;\n initOptions: InitOptions;\n summaryData: InitSummaryData;\n ctx: EnsurePackageBundledContext;\n /** Whether init is running in a multi-app scenario. */\n isMultiApp: boolean;\n shouldForce: boolean;\n /** The priority of the package being evaluated. To be used in the task runner. */\n priority: number;\n}): Promise<{\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 /** Whether a fatal error was encountered. */\n shouldExit?: boolean;\n}> {\n const {\n packagePath,\n config,\n initOptions,\n span,\n resolveMap,\n summaryData,\n ctx,\n importerContext,\n shouldForce,\n isMultiApp,\n priority,\n appPath,\n } = options;\n const { packages } = ctx;\n const { features } = config;\n\n // This line is the reason we have to track the importerContext for packages to evaluate:\n // otherwise if a non-semver package is read here, we'd lose the modifications from the initial\n // time the package was read (and getNonSemverTransform was called) when building the resolve map.\n const definition = await packages.get(packagePath, { refresh: true, importerContext });\n const { name, version } = definition;\n\n console.debug(`Evaluating ${packagePath} with context ${JSON.stringify(importerContext)}`);\n\n // Bundle the package and find the imports it depends on.\n const { result } = await ensurePackageBundled({\n input: {\n name,\n version,\n isIncremental: false,\n shouldGetBundleInfo: true,\n shouldForce,\n shouldRerun: shouldForce,\n useHashAsId: isMultiApp,\n priority,\n disableCache: !initOptions.cache,\n },\n ctx,\n });\n\n const { errors, warnings, info, outputPath } = result;\n\n // Record the results for the summary.\n summaryData.recordResult({ name, version, path: packagePath, errors, warnings, info, outputPath });\n\n // If there were errors or no imports, return early.\n if (errors?.length || !info) {\n return {};\n }\n\n // Given the package imports, find the missing exports maps and update packageOverrides.\n const {\n exportsChanges,\n includedDependenciesChanges,\n errors: evalErrors,\n pathsToEvaluate,\n pathsToRefresh,\n } = await evaluateImportsForOverrides({\n definition,\n packagePath,\n packages,\n info,\n config,\n resolveMap,\n importerContext,\n appPath,\n });\n\n if (evalErrors.length) {\n summaryData.addErrors(packagePath, evalErrors);\n }\n summaryData.recordGeneratedChanges(exportsChanges);\n summaryData.recordGeneratedChanges(includedDependenciesChanges);\n\n let dynamicImportsChanges: undefined | GeneratedPackageChanges[] = undefined;\n if (features?.evaluateDynamicImports) {\n const evaluatedDynamicImports = await evaluateDynamicImports({\n definition,\n packagePath,\n info,\n config,\n packages,\n importerContext,\n });\n\n const { pathsToEvaluate: dynamicImportPathsToEvaluate, pathsToRefresh: dynamicImportPathsToRefresh } =\n evaluatedDynamicImports;\n dynamicImportsChanges = evaluatedDynamicImports.dynamicImportsChanges;\n\n summaryData.recordGeneratedChanges(dynamicImportsChanges);\n\n for (const [evalPath, evalContext] of dynamicImportPathsToEvaluate.entries()) {\n pathsToEvaluate.set(evalPath, evalContext);\n }\n dynamicImportPathsToRefresh.forEach((path) => pathsToRefresh.add(path));\n }\n\n // Uncomment this when #1694 init does not cache packages correctly after editing config is fixed\n // and the heap does not reach the limit as almost every package is enqueued.\n // importPathsToEvaluate?.forEach((path) => pathsToEvaluate.set(path, importerContext));\n // importPathsToRefresh?.forEach((path) => pathsToRefresh.add(path));\n\n if (initOptions.check && (exportsChanges.length || evalErrors.length || dynamicImportsChanges?.length)) {\n span.addEvent('INIT_CHECK_FAILED', {\n // Don't log the specific errors to telemetry, as they may contain sensitive information.\n reason: exportsChanges || dynamicImportsChanges ? 'Config needs to be updated.' : 'Errors found with imports.',\n });\n\n return { shouldExit: true };\n }\n\n return {\n pathsToEvaluate,\n pathsToRefresh,\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { Session } from '@ms-cloudpack/api-server';
2
- import { type LinkedPath, type ResolveMap } from '@ms-cloudpack/package-utilities';
2
+ import type { LinkedPath, ResolveMap } from '@ms-cloudpack/common-types';
3
3
  export declare function formatLinkSummary(options: {
4
4
  session: Session;
5
5
  resolveMap: ResolveMap;
@@ -1 +1 @@
1
- {"version":3,"file":"formatLinkSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/link/formatLinkSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,UAAU,EAEhB,MAAM,iCAAiC,CAAC;AAEzC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;CAC1C,UA4BA"}
1
+ {"version":3,"file":"formatLinkSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/link/formatLinkSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,4BAA4B,CAAC;AAS1F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;CAC1C,UA4BA"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatLinkSummary.js","sourceRoot":"","sources":["../../../src/commands/link/formatLinkSummary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,eAAe,EACf,mBAAmB,GAMpB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,UAAU,iBAAiB,CAAC,OAKjC;IACC,MAA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AAyF;gBACzF,oEAAoE;gBACpE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SACpC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC;SAChC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC;SACnB,IAAI,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport { bulletedList, cyan } from '@ms-cloudpack/task-reporter';\nimport {\n diffResolveMaps,\n findResolveMapEntry,\n type DiffResolveMapsChanges,\n type DiffResolveMapsStats,\n type LinkedPath,\n type ResolveMap,\n type ResolveMapEntry,\n} from '@ms-cloudpack/package-utilities';\n\nexport function formatLinkSummary(options: {\n session: Session;\n resolveMap: ResolveMap;\n linkedPaths: LinkedPath[];\n resolveStrategy?: 'dedupe' | 'duplicate';\n}) {\n const { session, linkedPaths, resolveMap, resolveStrategy } = options;\n const differences = diffResolveMaps({ before: session.resolveMap, after: resolveMap });\n\n const linkedPathsMessage = linkedPaths.length\n ? [\n 'Linked paths:',\n bulletedList(\n linkedPaths\n .map((p) => p.path)\n .sort()\n .map((p) => cyan(p)),\n ),\n ]\n : ['No paths linked.'];\n\n const messages = [\n `Finished linking session: \"${session.projectName}\" (${session.id})`,\n '',\n ...linkedPathsMessage,\n '',\n `Resolve map differences:`,\n bulletedList(formatDiff(differences)),\n ...duplicatedMessages({ session, differences, resolveStrategy }),\n '',\n ];\n\n return messages.join('\\n');\n}\n\nfunction formatDiff(diff: DiffResolveMapsStats) {\n const messages = [];\n const added = formatDiffChanges(diff.added);\n const removed = formatDiffChanges(diff.removed);\n\n if (!added.length && !removed.length) {\n messages.push('No differences found');\n }\n\n if (added.length) {\n messages.push('Added:', added);\n }\n\n if (removed.length) {\n messages.push('Removed:', removed);\n }\n\n return messages;\n}\n\nfunction formatDiffChanges(changes: DiffResolveMapsChanges) {\n const messages = [];\n if (changes.linked.length) {\n messages.push('Linked:', changes.linked.map(formatEntry).sort());\n }\n\n if (changes.internal.length) {\n messages.push('Internal:', changes.internal.map(formatEntry).sort());\n }\n\n if (changes.external.length) {\n messages.push('External:', changes.external.map(formatEntry).sort());\n }\n\n return messages;\n}\n\nfunction formatEntry(entry: ResolveMapEntry) {\n return `${entry.name}@${entry.version} (${entry.path})`;\n}\n\nfunction duplicatedMessages(options: {\n session: Session;\n differences: DiffResolveMapsStats;\n resolveStrategy?: 'dedupe' | 'duplicate';\n}) {\n const { session, differences, resolveStrategy } = options;\n const duplicated = findDuplicates({ session, differences });\n\n return duplicated.length\n ? [\n '',\n `Warning:`,\n 'The following packages were duplicated by linking:',\n duplicated.join(', '),\n '',\n 'This could lead to unexpected behavior. Please review the linked paths and resolve map to ensure correctness.',\n ...(resolveStrategy == 'duplicate'\n ? ['Consider running link with `cloudpack link --resolve-strategy dedupe` to resolve these duplicates.']\n : []),\n ]\n : [];\n}\n\n/**\n * Find entries that were duplicated by linking.\n * This means that the package already existed in the resolve map,\n * and now there are more versions of the package than there were before.\n */\nfunction findDuplicates(options: { session: Session; differences: DiffResolveMapsStats }) {\n const { session, differences } = options;\n const duplicated = new Map<string, number>();\n\n for (const packageType of Object.values(differences.added)) {\n for (const change of packageType as ResolveMapEntry[]) {\n const { name } = change;\n const entry = findResolveMapEntry({ packageName: name, resolveMap: session.resolveMap });\n if (entry) {\n duplicated.set(name, (duplicated.get(name) || 0) + 1);\n }\n }\n }\n\n for (const packageType of Object.values(differences.removed)) {\n for (const change of packageType as ResolveMapEntry[]) {\n const { name } = change;\n if (duplicated.has(name)) {\n // We already checked for existence in the resolve map, so we know this will be a number.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n duplicated.set(name, duplicated.get(name)! - 1);\n }\n }\n }\n\n return Array.from(duplicated.entries())\n .filter(([, value]) => value > 0)\n .map(([key]) => key)\n .sort();\n}\n"]}
1
+ {"version":3,"file":"formatLinkSummary.js","sourceRoot":"","sources":["../../../src/commands/link/formatLinkSummary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,eAAe,EACf,mBAAmB,GAGpB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,UAAU,iBAAiB,CAAC,OAKjC;IACC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IACtE,MAAM,WAAW,GAAG,eAAe,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IAEvF,MAAM,kBAAkB,GAAG,WAAW,CAAC,MAAM;QAC3C,CAAC,CAAC;YACE,eAAe;YACf,YAAY,CACV,WAAW;iBACR,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,IAAI,EAAE;iBACN,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CACvB;SACF;QACH,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;IAEzB,MAAM,QAAQ,GAAG;QACf,8BAA8B,OAAO,CAAC,WAAW,MAAM,OAAO,CAAC,EAAE,GAAG;QACpE,EAAE;QACF,GAAG,kBAAkB;QACrB,EAAE;QACF,0BAA0B;QAC1B,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACrC,GAAG,kBAAkB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;QAChE,EAAE;KACH,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D,KAAK,MAAM,MAAM,IAAI,WAAgC,EAAE,CAAC;YACtD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;YACxB,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,yFAAyF;gBACzF,oEAAoE;gBACpE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAE,GAAG,CAAC,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SACpC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC;SAChC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC;SACnB,IAAI,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport type { LinkedPath, ResolveMap, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { bulletedList, cyan } from '@ms-cloudpack/task-reporter';\nimport {\n diffResolveMaps,\n findResolveMapEntry,\n type DiffResolveMapsChanges,\n type DiffResolveMapsStats,\n} from '@ms-cloudpack/package-utilities';\n\nexport function formatLinkSummary(options: {\n session: Session;\n resolveMap: ResolveMap;\n linkedPaths: LinkedPath[];\n resolveStrategy?: 'dedupe' | 'duplicate';\n}) {\n const { session, linkedPaths, resolveMap, resolveStrategy } = options;\n const differences = diffResolveMaps({ before: session.resolveMap, after: resolveMap });\n\n const linkedPathsMessage = linkedPaths.length\n ? [\n 'Linked paths:',\n bulletedList(\n linkedPaths\n .map((p) => p.path)\n .sort()\n .map((p) => cyan(p)),\n ),\n ]\n : ['No paths linked.'];\n\n const messages = [\n `Finished linking session: \"${session.projectName}\" (${session.id})`,\n '',\n ...linkedPathsMessage,\n '',\n `Resolve map differences:`,\n bulletedList(formatDiff(differences)),\n ...duplicatedMessages({ session, differences, resolveStrategy }),\n '',\n ];\n\n return messages.join('\\n');\n}\n\nfunction formatDiff(diff: DiffResolveMapsStats) {\n const messages = [];\n const added = formatDiffChanges(diff.added);\n const removed = formatDiffChanges(diff.removed);\n\n if (!added.length && !removed.length) {\n messages.push('No differences found');\n }\n\n if (added.length) {\n messages.push('Added:', added);\n }\n\n if (removed.length) {\n messages.push('Removed:', removed);\n }\n\n return messages;\n}\n\nfunction formatDiffChanges(changes: DiffResolveMapsChanges) {\n const messages = [];\n if (changes.linked.length) {\n messages.push('Linked:', changes.linked.map(formatEntry).sort());\n }\n\n if (changes.internal.length) {\n messages.push('Internal:', changes.internal.map(formatEntry).sort());\n }\n\n if (changes.external.length) {\n messages.push('External:', changes.external.map(formatEntry).sort());\n }\n\n return messages;\n}\n\nfunction formatEntry(entry: ResolveMapEntry) {\n return `${entry.name}@${entry.version} (${entry.path})`;\n}\n\nfunction duplicatedMessages(options: {\n session: Session;\n differences: DiffResolveMapsStats;\n resolveStrategy?: 'dedupe' | 'duplicate';\n}) {\n const { session, differences, resolveStrategy } = options;\n const duplicated = findDuplicates({ session, differences });\n\n return duplicated.length\n ? [\n '',\n `Warning:`,\n 'The following packages were duplicated by linking:',\n duplicated.join(', '),\n '',\n 'This could lead to unexpected behavior. Please review the linked paths and resolve map to ensure correctness.',\n ...(resolveStrategy == 'duplicate'\n ? ['Consider running link with `cloudpack link --resolve-strategy dedupe` to resolve these duplicates.']\n : []),\n ]\n : [];\n}\n\n/**\n * Find entries that were duplicated by linking.\n * This means that the package already existed in the resolve map,\n * and now there are more versions of the package than there were before.\n */\nfunction findDuplicates(options: { session: Session; differences: DiffResolveMapsStats }) {\n const { session, differences } = options;\n const duplicated = new Map<string, number>();\n\n for (const packageType of Object.values(differences.added)) {\n for (const change of packageType as ResolveMapEntry[]) {\n const { name } = change;\n const entry = findResolveMapEntry({ packageName: name, resolveMap: session.resolveMap });\n if (entry) {\n duplicated.set(name, (duplicated.get(name) || 0) + 1);\n }\n }\n }\n\n for (const packageType of Object.values(differences.removed)) {\n for (const change of packageType as ResolveMapEntry[]) {\n const { name } = change;\n if (duplicated.has(name)) {\n // We already checked for existence in the resolve map, so we know this will be a number.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n duplicated.set(name, duplicated.get(name)! - 1);\n }\n }\n }\n\n return Array.from(duplicated.entries())\n .filter(([, value]) => value > 0)\n .map(([key]) => key)\n .sort();\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { createPartialApiContext, ensurePackageBundled, } from '@ms-cloudpack/api-server';
2
2
  import { writeJson } from '@ms-cloudpack/json-utilities';
3
- import { isExternalPackage, resolve } from '@ms-cloudpack/package-utilities';
3
+ import { isExternalPackage, resolve } from '@ms-cloudpack/path-utilities';
4
4
  import { makeUrl } from '@ms-cloudpack/path-string-parsing';
5
5
  import { cyan, yellow, bold } from '@ms-cloudpack/task-reporter';
6
6
  import path from 'path';
@@ -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,C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C,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 await 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,MAAM,8BAA8B,CAAC;AAC1E,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,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAC;AAEnG;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAgC,KAAK,EAAE,MAAM,EAAE,EAAE;IACnE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEzD,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACjE,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,aAAa,CAAC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AAE,EAAE,UAAU,CAAC,CAAC;QAC3F,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACzC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,OAAe,CAAC;QACpB,IAAK,GAAwB,CAAC,IAAI,KAAK,eAAe,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;YACzE,MAAM,aAAa,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,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/path-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 await 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 type { SyncOptions } from './types/SyncOptions.js';
2
1
  import { type CommandAction } from '../../types/CommandAction.js';
2
+ import type { SyncOptions } from './types/SyncOptions.js';
3
3
  export declare const execute: CommandAction<SyncOptions>;
4
4
  //# sourceMappingURL=execute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;AAUtC,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAiF9C,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAM1D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAiF9C,CAAC"}
@@ -1,8 +1,8 @@
1
- import { ExitCodeAuthenticationError, ExitCodeGenericError, } from '../../types/CommandAction.js';
2
1
  import { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';
3
- import { runPrerequisites } from '../../utilities/runPrerequisites.js';
4
- import { isSyncDisabledByUser } from './isSyncDisabledByUser.js';
2
+ import { environmentInfo } from '@ms-cloudpack/environment';
5
3
  import { red } from '@ms-cloudpack/task-reporter';
4
+ import { ExitCodeAuthenticationError, ExitCodeGenericError, } from '../../types/CommandAction.js';
5
+ import { runPrerequisites } from '../../utilities/runPrerequisites.js';
6
6
  function checkErrorCode(error, code) {
7
7
  return error instanceof Error && 'code' in error && error.code === code;
8
8
  }
@@ -17,7 +17,7 @@ export const execute = async (params) => {
17
17
  if (!config.features?.syncBundles) {
18
18
  return { message: 'Sync is disabled' };
19
19
  }
20
- if (isSyncDisabledByUser()) {
20
+ if (!environmentInfo.cloudpack.isSyncEnabled) {
21
21
  span.setAttribute('syncDisabled', true);
22
22
  return { message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' };
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAElD,SAAS,cAAc,CAAC,KAAc,EAAE,IAAY;IAClD,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI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oBAC7E,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport {\n ExitCodeAuthenticationError,\n ExitCodeGenericError,\n type CommandAction,\n type CommandExitParams,\n} from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { isSyncDisabledByUser } from './isSyncDisabledByUser.js';\nimport { red } from '@ms-cloudpack/task-reporter';\n\nfunction checkErrorCode(error: unknown, code: string) {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose } = params;\n const { login, upload } = options;\n const apiContextOptions = await initialize({ appPath: cwd });\n const { config, telemetryClient } = apiContextOptions;\n try {\n // Await here to ensure that try-catch block catches any errors thrown inside the async function\n return await telemetryClient.tracer.startActiveSpan('SYNC_EXECUTE', async (span): Promise<CommandExitParams> => {\n if (!config.features?.syncBundles) {\n return { message: 'Sync is disabled' };\n }\n\n if (isSyncDisabledByUser()) {\n span.setAttribute('syncDisabled', true);\n return { message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' };\n }\n\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return {\n message:\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n };\n }\n\n const input = {\n loginMethod: login,\n };\n\n if (upload) {\n await runPrerequisites(apiContextOptions);\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n return { message: 'Sync complete' };\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return {\n message: red(\n `Cloudpack encountered an issue acquiring authentication lock. It seems Cloudpack Sync may already be active in another process. Please wait for the current process to complete and then try again`,\n ),\n exitCode: ExitCodeGenericError,\n };\n }\n if (\n error.name === 'AuthenticationRequiredError' ||\n ('statusCode' in error && (error.statusCode === '401' || error.statusCode === '403'))\n ) {\n return {\n message: red('Authentication error. Please check your credentials and try again.'),\n exitCode: ExitCodeAuthenticationError,\n };\n }\n\n if (checkErrorCode(error, 'REQUEST_SEND_ERROR')) {\n return {\n message: red('Connection error. Please check your connection and try again.'),\n exitCode: ExitCodeGenericError,\n };\n }\n }\n\n throw error;\n }\n};\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGvE,SAAS,cAAc,CAAC,KAAc,EAAE,IAAY;IAClD,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,EAAE,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{ environmentInfo } from '@ms-cloudpack/environment';\nimport { red } from '@ms-cloudpack/task-reporter';\nimport {\n ExitCodeAuthenticationError,\n ExitCodeGenericError,\n type CommandAction,\n type CommandExitParams,\n} from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\n\nfunction checkErrorCode(error: unknown, code: string) {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose } = params;\n const { login, upload } = options;\n const apiContextOptions = await initialize({ appPath: cwd });\n const { config, telemetryClient } = apiContextOptions;\n try {\n // Await here to ensure that try-catch block catches any errors thrown inside the async function\n return await telemetryClient.tracer.startActiveSpan('SYNC_EXECUTE', async (span): Promise<CommandExitParams> => {\n if (!config.features?.syncBundles) {\n return { message: 'Sync is disabled' };\n }\n\n if (!environmentInfo.cloudpack.isSyncEnabled) {\n span.setAttribute('syncDisabled', true);\n return { message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' };\n }\n\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return {\n message:\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n };\n }\n\n const input = {\n loginMethod: login,\n };\n\n if (upload) {\n await runPrerequisites(apiContextOptions);\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n return { message: 'Sync complete' };\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return {\n message: red(\n `Cloudpack encountered an issue acquiring authentication lock. It seems Cloudpack Sync may already be active in another process. Please wait for the current process to complete and then try again`,\n ),\n exitCode: ExitCodeGenericError,\n };\n }\n if (\n error.name === 'AuthenticationRequiredError' ||\n ('statusCode' in error && (error.statusCode === '401' || error.statusCode === '403'))\n ) {\n return {\n message: red('Authentication error. Please check your credentials and try again.'),\n exitCode: ExitCodeAuthenticationError,\n };\n }\n\n if (checkErrorCode(error, 'REQUEST_SEND_ERROR')) {\n return {\n message: red('Connection error. Please check your connection and try again.'),\n exitCode: ExitCodeGenericError,\n };\n }\n }\n\n throw error;\n }\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAiB9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,mBAclB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAgB9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,mBAclB,CAAC"}
@@ -1,11 +1,10 @@
1
1
  import { Option } from 'commander';
2
- import { isCIBuild } from '../../utilities/isCIBuild.js';
3
- import { isCodespaces } from '../../utilities/isCodespaces.js';
2
+ import { environmentInfo } from '@ms-cloudpack/environment';
4
3
  function getDefaultLogin() {
5
- if (isCIBuild()) {
4
+ if (environmentInfo.isCI) {
6
5
  return 'azure-cli';
7
6
  }
8
- if (isCodespaces()) {
7
+ if (environmentInfo.isCodespaces) {
9
8
  return 'device-code';
10
9
  }
11
10
  return 'interactive';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,SAAS,eAAe;IACtB,IAAI,SAAS,EAAE,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,YAAY,EAAE,EAAE,CAAC;QACnB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,+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,2CAA2C;YAC3C,2FAA2F;QAC7F,OAAO,EAAE;YACP,MAAM,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,+DAA+D,CAAC;YAC/F,KAAK,EAAE,IAAI,MAAM,CAAC,kBAAkB,EAAE,+CAA+C,CAAC;iBACnF,OAAO,CAAC,CAAC,aAAa,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;iBACpD,OAAO,CAAC,eAAe,EAAE,EAAE,gFAAgF,CAAC;SAChH;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 { SyncOptions } from './types/SyncOptions.js';\nimport { isCIBuild } from '../../utilities/isCIBuild.js';\nimport { isCodespaces } from '../../utilities/isCodespaces.js';\n\nfunction getDefaultLogin() {\n if (isCIBuild()) {\n return 'azure-cli';\n }\n\n if (isCodespaces()) {\n return 'device-code';\n }\n\n return 'interactive';\n}\n\n/** Defines the \"sync\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<SyncOptions>({\n name: 'sync',\n description:\n 'Syncs packages from/to the remote cache. ' +\n 'By default (without --upload) it will download any packages not found in the local cache.',\n options: {\n upload: new Option('--upload', 'Upload packages to the remote cache (instead of downloading).'),\n login: new Option('--login <method>', 'How to authenticate against the remote cache.')\n .choices(['interactive', 'azure-cli', 'device-code'])\n .default(getDefaultLogin(), '\"azure-cli\" in CI, \"device-code\" in Github Codespaces, \"interactive\" otherwise'),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/sync/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,SAAS,eAAe;IACtB,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,eAAe,CAAC,YAAY,EAAE,CAAC;QACjC,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,+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,2CAA2C;YAC3C,2FAA2F;QAC7F,OAAO,EAAE;YACP,MAAM,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,+DAA+D,CAAC;YAC/F,KAAK,EAAE,IAAI,MAAM,CAAC,kBAAkB,EAAE,+CAA+C,CAAC;iBACnF,OAAO,CAAC,CAAC,aAAa,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;iBACpD,OAAO,CAAC,eAAe,EAAE,EAAE,gFAAgF,CAAC;SAChH;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 { SyncOptions } from './types/SyncOptions.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\n\nfunction getDefaultLogin() {\n if (environmentInfo.isCI) {\n return 'azure-cli';\n }\n\n if (environmentInfo.isCodespaces) {\n return 'device-code';\n }\n\n return 'interactive';\n}\n\n/** Defines the \"sync\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<SyncOptions>({\n name: 'sync',\n description:\n 'Syncs packages from/to the remote cache. ' +\n 'By default (without --upload) it will download any packages not found in the local cache.',\n options: {\n upload: new Option('--upload', 'Upload packages to the remote cache (instead of downloading).'),\n login: new Option('--login <method>', 'How to authenticate against the remote cache.')\n .choices(['interactive', 'azure-cli', 'device-code'])\n .default(getDefaultLogin(), '\"azure-cli\" in CI, \"device-code\" in Github Codespaces, \"interactive\" otherwise'),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Command, Help, Option } from 'commander';
2
- import { isCIBuild } from '../utilities/isCIBuild.js';
3
2
  import { CommandExecutor } from './CommandExecutor.js';
3
+ import { environmentInfo } from '@ms-cloudpack/environment';
4
4
  /**
5
5
  * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with
6
6
  * Cloudpack-specific functionality and simpler APIs.
@@ -44,7 +44,7 @@ export class CloudpackCommand {
44
44
  quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),
45
45
  color:
46
46
  // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)
47
- new Option('-n, --no-color', 'Disable colors in the output.').default(!process.env.JEST_WORKER_ID && !process.env.LAGE_PACKAGE_NAME && !isCIBuild()),
47
+ new Option('-n, --no-color', 'Disable colors in the output.').default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),
48
48
  features: new Option('--features <featureNames...>', 'Enable experimental features.'),
49
49
  cachePath: new Option('--cache-path <path>', 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.'),
50
50
  }, params.hideSharedOptions);
@@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utputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { CommandExecutor } from './CommandExecutor.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n command.createHelp = () => new CloudpackHelp();\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.').default(\n !process.env.JEST_WORKER_ID && !process.env.LAGE_PACKAGE_NAME && !isCIBuild(),\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>) {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n\nclass CloudpackHelp extends Help {\n visibleOptions(cmd: Command): Option[] {\n const options = super.visibleOptions(cmd);\n\n if (cmd.name() !== 'cloudpack') {\n // Remove --version from help except at the top level (it's not very useful)\n return options.filter((option) => option.name() !== 'version');\n }\n\n return options;\n }\n}\n"]}
1
+ {"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAIrH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAsD5D;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAI3B;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAE7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC;QAE/C,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAA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,GAAG,CAAC,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;YAC/B,4EAA4E;YAC5E,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { Command, Help, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n command.createHelp = () => new CloudpackHelp();\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.').default(\n !environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI,\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>) {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n\nclass CloudpackHelp extends Help {\n visibleOptions(cmd: Command): Option[] {\n const options = super.visibleOptions(cmd);\n\n if (cmd.name() !== 'cloudpack') {\n // Remove --version from help except at the top level (it's not very useful)\n return options.filter((option) => option.name() !== 'version');\n }\n\n return options;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAGlB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ/D;;GAEG;AACH,qBAAa,eAAe,CAAC,QAAQ,SAAS,aAAa;IACzD,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,YAAY,CAAK;I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IACzB,OAAO,CAAC,sBAAsB,CAA+B;IAE7D,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAA8B;WAEzC,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;gBASzD,MAAM,EAAE;QAClB,iCAAiC;QACjC,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,2CAA2C;QAC3C,OAAO,EAAE,QAAQ,CAAC;QAClB,uCAAuC;QACvC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjC,0CAA0C;QAC1C,cAAc,EAAE,cAAc,CAAC;QAC/B,sDAAsD;QACtD,IAAI,EAAE,MAAM,CAAC;KACd;IAWD,uBAAuB;IAEV,OAAO;IAgCpB;;;;;OAKG;YACW,WAAW;YAuGX,cAAc;IAwD5B,SAAS,CAAC,cAAc,aActB;IAEF;;;OAGG;cACa,KAAK,CAAC,MAAM,EAAE,iBAAiB;CA+BhD"}
@@ -3,12 +3,11 @@ import { readJson } from '@ms-cloudpack/json-utilities';
3
3
  import { TaskReporter, bold, debugLoggingConfig, defaultLoggingConfig, noLoggingConfig, red, verboseLoggingConfig, yellow, } from '@ms-cloudpack/task-reporter';
4
4
  import { createTelemetryClient } from '@ms-cloudpack/telemetry';
5
5
  import path from 'path';
6
- import { isCIBuild } from '../utilities/isCIBuild.js';
7
6
  import { AutoDisposableList } from './AutoDisposableList.js';
8
7
  import { checkFeatures } from './checkFeatures.js';
9
- import { isCodespaces } from '../utilities/isCodespaces.js';
10
8
  import { getVersion } from '@ms-cloudpack/package-utilities';
11
9
  import { mergeFeatures } from './mergeFeatures.js';
10
+ import { environmentInfo } from '@ms-cloudpack/environment';
12
11
  /**
13
12
  * This class manages orchestration and shared state while executing a command.
14
13
  */
@@ -161,9 +160,9 @@ export class CommandExecutor {
161
160
  const startTime = performance.now();
162
161
  const programOptions = this._programOptions;
163
162
  const options = this._options;
164
- const connectionString = programOptions.disableTelemetry
163
+ const connectionString = programOptions.disableTelemetry || environmentInfo.isJest
165
164
  ? undefined
166
- : config.telemetry?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;
165
+ : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;
167
166
  const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;
168
167
  if (!options.debug) {
169
168
  this._reporter.ignoreLogMessage('ApplicationInsights:');
@@ -182,21 +181,16 @@ export class CommandExecutor {
182
181
  if (enabledFeatureNames.length) {
183
182
  console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);
184
183
  }
185
- const isCI = isCIBuild();
186
184
  const telemetryAttributes = {
187
185
  verb: this._verb,
188
186
  arguments: programOptions.argv.slice(3).join(' '),
189
- environment: isCI ? 'ci' : isCodespaces() ? 'codespaces' : 'local',
187
+ environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',
190
188
  appName: appName || '<unknown>',
191
189
  mode: config.mode || 'library',
192
- // External correlation Id is used to correlate telemetry across different services.
193
- externalCorrelationId: process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID,
194
- // Azure DevOps build attributes
195
- buildId: isCI ? process.env.BUILD_BUILDID : undefined,
196
- definitionId: isCI ? process.env.SYSTEM_DEFINITIONID : undefined,
197
- buildReason: isCI ? process.env.BUILD_REASON : undefined,
198
- pullRequestId: isCI ? process.env.SYSTEM_PULLREQUEST_PULLREQUESTID : undefined,
199
190
  features: enabledFeatureNames,
191
+ externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,
192
+ // Azure DevOps build attributes
193
+ ...environmentInfo.ado,
200
194
  };
201
195
  for (const [key, value] of Object.entries(telemetryAttributes)) {
202
196
  if (value) {
@@ -216,7 +210,7 @@ export class CommandExecutor {
216
210
  if (this._hasCalledExit) {
217
211
  // Skip most of the operations if exit() was called multiple times.
218
212
  // But only use the error message if not in a test, due to the way we're mocking process.exit.
219
- if (!process.env.JEST_WORKER_ID) {
213
+ if (!environmentInfo.isJest) {
220
214
  const prettyParams = Object.entries(params)
221
215
  .map(([key, value]) => `${key}="${value}"`)
222
216
  .join(', ');
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,GAAG,EACH,oBAAoB,EACpB,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,yBAAyB,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,eAAe;IAenB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAyB;QACnD,4FAA4F;QAC5F,KAAK,MAAM,QAAQ,IAAI,eAAe,CAAC,gBAAgB,EAAE,CAAC;YACxD,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;QACjD,CAAC;QACD,eAAe,CAAC,gBAAgB,GAAG,EAAE,CAAC;IACxC,CAAC;IAED,YAAY,MAWX;QA3BO,mB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M,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;qBACxC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,KAAK,GAAG,CAAC;qBAC1C,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,0DAA0D,YAAY,GAAG,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAE3B,qDAAqD;YACrD,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAE9B,sCAAsC;YACtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAEzC,MAAM,aAAa,GAAG,QAAQ,KAAK,CAAC,CAAC;YAErC,8DAA8D;YAC9D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC7E,CAAC;QAED,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;;AAlSD,yFAAyF;AAC1E,gCAAgB,GAA2B,EAAE,AAA7B,CAA8B","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type {\n CommandAction,\n CommandExitParams,\n AppCommandContext,\n CommandInitializeOptions,\n} from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { isCodespaces } from '../utilities/isCodespaces.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { mergeFeatures } from './mergeFeatures.js';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _getMessageOnInterrupt = () => `Interrupted by user`;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances: CommandExecutor<any>[] = [];\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = [];\n }\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._reporter = new TaskReporter();\n this._abortController = new AbortController();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute() {\n CommandExecutor._activeInstances.push(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', this._sigintHandler);\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n if (result) {\n await this._exit(result);\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPath: string },\n ): Promise<AppCommandContext>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPaths: string[] },\n ): Promise<AppCommandContext[]>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & {\n appPath?: string;\n appPaths?: string[];\n },\n ): Promise<AppCommandContext | AppCommandContext[]> {\n const { appPath: singleAppPath, configOptions } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const contexts: AppCommandContext[] = [];\n\n const helpMessages = new Set<string>();\n\n const configs: Record<string, CloudpackConfig> = {};\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, configOptions);\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // eslint-disable-next-line no-restricted-properties -- this will never be reached, but TypeScript doesn't know that\n process.exit(1);\n }\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n\n configs[appPath] = config;\n }\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\n\n // Merge in any additional features from the command line and remote feature flags.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: this._options.features,\n });\n\n const featureErrors = checkFeatures({ configFeatures: config.features });\n\n // If there are any invalid features, warn the user and continue.\n if (featureErrors.length) {\n featureErrors.forEach((warning) => console.warn(warning));\n }\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n });\n }\n\n return singleAppPath ? contexts[0] : contexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString = programOptions.disableTelemetry\n ? undefined\n : config.telemetry?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n });\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const isCI = isCIBuild();\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: isCI ? 'ci' : isCodespaces() ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode || 'library',\n\n // External correlation Id is used to correlate telemetry across different services.\n externalCorrelationId: process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID,\n\n // Azure DevOps build attributes\n buildId: isCI ? process.env.BUILD_BUILDID : undefined,\n definitionId: isCI ? process.env.SYSTEM_DEFINITIONID : undefined,\n buildReason: isCI ? process.env.BUILD_REASON : undefined,\n pullRequestId: isCI ? process.env.SYSTEM_PULLREQUEST_PULLREQUESTID : undefined,\n features: enabledFeatureNames,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = () => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams) {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt() : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!process.env.JEST_WORKER_ID) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n const exitWithError = exitCode !== 0;\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message, exitWithError);\n }\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
1
+ {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,GAAG,EACH,oBAAoB,EACpB,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,yBAAyB,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,eAAe;IAenB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAyB;QACnD,4FAA4F;QAC5F,KAAK,MAAM,QAAQ,IAAI,eAAe,CAAC,gBAAgB,EAAE,CAAC;YACxD,MAAM,QAA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AI,CAAC,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,0DAA0D,YAAY,GAAG,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAE3B,qDAAqD;YACrD,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAE9B,sCAAsC;YACtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAEzC,MAAM,aAAa,GAAG,QAAQ,KAAK,CAAC,CAAC;YAErC,8DAA8D;YAC9D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC7E,CAAC;QAED,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;;AA3RD,yFAAyF;AAC1E,gCAAgB,GAA2B,EAAE,AAA7B,CAA8B","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type {\n CommandAction,\n CommandExitParams,\n AppCommandContext,\n CommandInitializeOptions,\n} from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { mergeFeatures } from './mergeFeatures.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _getMessageOnInterrupt = () => `Interrupted by user`;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances: CommandExecutor<any>[] = [];\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = [];\n }\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._reporter = new TaskReporter();\n this._abortController = new AbortController();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute() {\n CommandExecutor._activeInstances.push(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', this._sigintHandler);\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n if (result) {\n await this._exit(result);\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: error instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPath: string },\n ): Promise<AppCommandContext>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & { appPaths: string[] },\n ): Promise<AppCommandContext[]>;\n private async _initialize(\n initializeParams: CommandInitializeOptions & {\n appPath?: string;\n appPaths?: string[];\n },\n ): Promise<AppCommandContext | AppCommandContext[]> {\n const { appPath: singleAppPath, configOptions } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const contexts: AppCommandContext[] = [];\n\n const helpMessages = new Set<string>();\n\n const configs: Record<string, CloudpackConfig> = {};\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, configOptions);\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // eslint-disable-next-line no-restricted-properties -- this will never be reached, but TypeScript doesn't know that\n process.exit(1);\n }\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n\n configs[appPath] = config;\n }\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\n\n // Merge in any additional features from the command line and remote feature flags.\n config.features = mergeFeatures({\n configFeatures: config.features,\n commandLineFeatures: this._options.features,\n });\n\n const featureErrors = checkFeatures({ configFeatures: config.features });\n\n // If there are any invalid features, warn the user and continue.\n if (featureErrors.length) {\n featureErrors.forEach((warning) => console.warn(warning));\n }\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n });\n }\n\n return singleAppPath ? contexts[0] : contexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString =\n programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n });\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode || 'library',\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = () => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams) {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt() : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n const exitWithError = exitCode !== 0;\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message, exitWithError);\n }\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
- import type { PackageSettingsMatch } from '@ms-cloudpack/common-types';
2
- import type { ResolveMap } from '@ms-cloudpack/package-utilities';
1
+ import type { PackageSettingsMatch, ResolveMap } from '@ms-cloudpack/common-types';
3
2
  /**
4
3
  * Find packages in the resolve map that match the requested names and versions.
5
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getFilteredPackages.d.ts","sourceRoot":"","sources":["../../src/utilities/getFilteredPackages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,4BAA4B,CAAC;AAExF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,CA6BnG"}
1
+ {"version":3,"file":"getFilteredPackages.d.ts","sourceRoot":"","sources":["../../src/utilities/getFilteredPackages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAmB,MAAM,4BAA4B,CAAC;AAIpG;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,CA6BnG"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFilteredPackages.js","sourceRoot":"","sources":["../../src/utilities/getFilteredPackages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE5F;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAsB,EAAE,KAA6B;IACvF,4CAA4C;IAC5C,MAAM,iBAAiB,GAAsB,EAAE,CAAC;IAEhD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9C,IAAI,UAAU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C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type { PackageSettingsMatch, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { checkMatch } from '@ms-cloudpack/config';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { bold, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\n\n/**\n * Find packages in the resolve map that match the requested names and versions.\n */\nexport function getFilteredPackages(resolveMap: ResolveMap, match: PackageSettingsMatch[]): string[] {\n // Find matching packages in the resolve map\n const resolveMapEntries: ResolveMapEntry[] = [];\n\n for (const entry of Object.values(resolveMap)) {\n if (checkMatch({ name: entry.name, version: entry.version, match })) {\n resolveMapEntries.push(entry);\n }\n for (const scopedEntry of Object.values(entry.scopedVersions || {})) {\n if (checkMatch({ name: scopedEntry.name, version: scopedEntry.version, match })) {\n resolveMapEntries.push(scopedEntry);\n }\n }\n }\n\n const matchArgsString = match\n .map((m) => `\"${bold(typeof m === 'object' ? `${m.name}@${m.version || '*'}` : m || '*')}\"`)\n .join(', ');\n\n if (!resolveMapEntries.length) {\n console.error(`No packages found matching ${matchArgsString}`);\n } else {\n console.log(\n `\\nFound ${plural(resolveMapEntries.length, 'package')} matching ${matchArgsString}:\\n` +\n bulletedList(resolveMapEntries.map((entry) => `${formatPackageName(entry)}: ${entry.path}`)),\n );\n }\n\n return resolveMapEntries.map((entry) => entry.path);\n}\n"]}
1
+ {"version":3,"file":"getFilteredPackages.js","sourceRoot":"","sources":["../../src/utilities/getFilteredPackages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE5F;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAsB,EAAE,KAA6B;IACvF,4CAA4C;IAC5C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AE,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAC/F,CAAC;IACJ,CAAC;IAED,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type { PackageSettingsMatch, ResolveMap, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { checkMatch } from '@ms-cloudpack/config';\nimport { bold, bulletedList, formatPackageName, plural } from '@ms-cloudpack/task-reporter';\n\n/**\n * Find packages in the resolve map that match the requested names and versions.\n */\nexport function getFilteredPackages(resolveMap: ResolveMap, match: PackageSettingsMatch[]): string[] {\n // Find matching packages in the resolve map\n const resolveMapEntries: ResolveMapEntry[] = [];\n\n for (const entry of Object.values(resolveMap)) {\n if (checkMatch({ name: entry.name, version: entry.version, match })) {\n resolveMapEntries.push(entry);\n }\n for (const scopedEntry of Object.values(entry.scopedVersions || {})) {\n if (checkMatch({ name: scopedEntry.name, version: scopedEntry.version, match })) {\n resolveMapEntries.push(scopedEntry);\n }\n }\n }\n\n const matchArgsString = match\n .map((m) => `\"${bold(typeof m === 'object' ? `${m.name}@${m.version || '*'}` : m || '*')}\"`)\n .join(', ');\n\n if (!resolveMapEntries.length) {\n console.error(`No packages found matching ${matchArgsString}`);\n } else {\n console.log(\n `\\nFound ${plural(resolveMapEntries.length, 'package')} matching ${matchArgsString}:\\n` +\n bulletedList(resolveMapEntries.map((entry) => `${formatPackageName(entry)}: ${entry.path}`)),\n );\n }\n\n return resolveMapEntries.map((entry) => entry.path);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { readJson } from '@ms-cloudpack/json-utilities';
2
- import { findProjectRoot } from '@ms-cloudpack/package-utilities';
2
+ import { findProjectRoot } from '@ms-cloudpack/path-utilities';
3
3
  import path from 'path';
4
4
  /**
5
5
  * Gets the name of the workspace or git repository from the root package.json.
@@ -1 +1 @@
1
- {"version":3,"file":"getRepositoryName.js","sourceRoot":"","sources":["../../src/utilities/getRepositoryName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;QACrD,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QAChE,MAAM,kBAAkB,GAAG,CAAC,MAAM,QAAQ,CAAC,mBAAmB,CAAC,CAAsB,CAAC;QACtF,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,kBAAkB,mBAAmB,GAAG,CAAC,CAAC;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,kBAAkB,CAAC,IAAI,CAAC;IACjC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CACV,0GAA0G,EAC1G,CAAC,CACF,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport { findProjectRoot } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\n\n/**\n * Gets the name of the workspace or git repository from the root package.json.\n * @returns The name of the workspace or repository. If the name is not found, undefined is returned.\n */\nexport async function getRepositoryName(appPath: string) {\n try {\n const rootPath = findProjectRoot(appPath) || appPath;\n const rootPackageJsonPath = path.join(rootPath, 'package.json');\n const packageJsonContent = (await readJson(rootPackageJsonPath)) as { name?: string };\n if (!packageJsonContent) {\n console.warn(`Could not read ${rootPackageJsonPath}.`);\n return undefined;\n }\n\n return packageJsonContent.name;\n } catch (e) {\n console.warn(\n 'An error occurred while getting repository name. This is not a critical error. You can continue to work.',\n e,\n );\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"getRepositoryName.js","sourceRoot":"","sources":["../../src/utilities/getRepositoryName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;QACrD,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QAChE,MAAM,kBAAkB,GAAG,CAAC,MAAM,QAAQ,CAAC,mBAAmB,CAAC,CAAsB,CAAC;QACtF,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,kBAAkB,mBAAmB,GAAG,CAAC,CAAC;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,kBAAkB,CAAC,IAAI,CAAC;IACjC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CACV,0GAA0G,EAC1G,CAAC,CACF,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport path from 'path';\n\n/**\n * Gets the name of the workspace or git repository from the root package.json.\n * @returns The name of the workspace or repository. If the name is not found, undefined is returned.\n */\nexport async function getRepositoryName(appPath: string) {\n try {\n const rootPath = findProjectRoot(appPath) || appPath;\n const rootPackageJsonPath = path.join(rootPath, 'package.json');\n const packageJsonContent = (await readJson(rootPackageJsonPath)) as { name?: string };\n if (!packageJsonContent) {\n console.warn(`Could not read ${rootPackageJsonPath}.`);\n return undefined;\n }\n\n return packageJsonContent.name;\n } catch (e) {\n console.warn(\n 'An error occurred while getting repository name. This is not a critical error. You can continue to work.',\n e,\n );\n return undefined;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.72.27",
3
+ "version": "0.72.28",
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,20 +10,21 @@
10
10
  "cloudpack": "./bin/cloudpack.js"
11
11
  },
12
12
  "dependencies": {
13
- "@ms-cloudpack/api-server": "^0.56.15",
14
- "@ms-cloudpack/app-server": "^0.17.22",
15
- "@ms-cloudpack/bundler": "^0.23.24",
16
- "@ms-cloudpack/common-types": "^0.23.6",
17
- "@ms-cloudpack/config": "^0.33.3",
18
- "@ms-cloudpack/json-utilities": "^0.1.8",
19
- "@ms-cloudpack/overlay": "^0.17.103",
20
- "@ms-cloudpack/package-utilities": "^10.4.2",
21
- "@ms-cloudpack/path-string-parsing": "^1.2.5",
22
- "@ms-cloudpack/path-utilities": "^2.7.56",
23
- "@ms-cloudpack/remote-cache": "^0.9.15",
24
- "@ms-cloudpack/setup-utilities": "^0.5.5",
25
- "@ms-cloudpack/task-reporter": "^0.14.6",
26
- "@ms-cloudpack/telemetry": "^0.10.2",
13
+ "@ms-cloudpack/api-server": "^0.56.16",
14
+ "@ms-cloudpack/app-server": "^0.17.23",
15
+ "@ms-cloudpack/bundler": "^0.23.25",
16
+ "@ms-cloudpack/common-types": "^0.23.7",
17
+ "@ms-cloudpack/config": "^0.33.4",
18
+ "@ms-cloudpack/environment": "^0.1.1",
19
+ "@ms-cloudpack/json-utilities": "^0.1.9",
20
+ "@ms-cloudpack/overlay": "^0.17.104",
21
+ "@ms-cloudpack/package-utilities": "^11.0.0",
22
+ "@ms-cloudpack/path-string-parsing": "^1.2.6",
23
+ "@ms-cloudpack/path-utilities": "^2.8.0",
24
+ "@ms-cloudpack/remote-cache": "^0.9.16",
25
+ "@ms-cloudpack/setup-utilities": "^0.5.6",
26
+ "@ms-cloudpack/task-reporter": "^0.14.7",
27
+ "@ms-cloudpack/telemetry": "^0.10.3",
27
28
  "@yarnpkg/lockfile": "^1.1.0",
28
29
  "commander": "^11.1.0",
29
30
  "cross-spawn": "^7.0.3",
@@ -36,7 +37,7 @@
36
37
  "workspace-tools": "^0.38.0"
37
38
  },
38
39
  "devDependencies": {
39
- "@ms-cloudpack/common-types": "^0.23.6",
40
+ "@ms-cloudpack/common-types": "^0.23.7",
40
41
  "@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
41
42
  "@ms-cloudpack/scripts": "^0.0.1",
42
43
  "@ms-cloudpack/test-utilities": "^0.5.0",
@@ -1,2 +0,0 @@
1
- export declare function isSyncDisabledByUser(): boolean;
2
- //# sourceMappingURL=isSyncDisabledByUser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSyncDisabledByUser.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/isSyncDisabledByUser.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,YAMnC"}
@@ -1,7 +0,0 @@
1
- export function isSyncDisabledByUser() {
2
- if (typeof process.env.CLOUDPACK_SYNC === 'undefined') {
3
- return false;
4
- }
5
- return process.env.CLOUDPACK_SYNC === 'false' || process.env.CLOUDPACK_SYNC === '0';
6
- }
7
- //# sourceMappingURL=isSyncDisabledByUser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSyncDisabledByUser.js","sourceRoot":"","sources":["../../../src/commands/sync/isSyncDisabledByUser.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB;IAClC,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,WAAW,EAAE,CAAC;QACtD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,GAAG,CAAC;AACtF,CAAC","sourcesContent":["export function isSyncDisabledByUser() {\n if (typeof process.env.CLOUDPACK_SYNC === 'undefined') {\n return false;\n }\n\n return process.env.CLOUDPACK_SYNC === 'false' || process.env.CLOUDPACK_SYNC === '0';\n}\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * @returns true if the current process is running in a CI environment
3
- */
4
- export declare function isCIBuild(): string | undefined;
5
- //# sourceMappingURL=isCIBuild.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isCIBuild.d.ts","sourceRoot":"","sources":["../../src/utilities/isCIBuild.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,SAAS,uBAExB"}
@@ -1,7 +0,0 @@
1
- /**
2
- * @returns true if the current process is running in a CI environment
3
- */
4
- export function isCIBuild() {
5
- return process.env.CI || process.env.TF_BUILD;
6
- }
7
- //# sourceMappingURL=isCIBuild.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isCIBuild.js","sourceRoot":"","sources":["../../src/utilities/isCIBuild.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAChD,CAAC","sourcesContent":["/**\n * @returns true if the current process is running in a CI environment\n */\nexport function isCIBuild() {\n return process.env.CI || process.env.TF_BUILD;\n}\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * @returns true if the current process is running in a Codespaces environment
3
- */
4
- export declare function isCodespaces(): string | undefined;
5
- //# sourceMappingURL=isCodespaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isCodespaces.d.ts","sourceRoot":"","sources":["../../src/utilities/isCodespaces.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,YAAY,uBAE3B"}
@@ -1,7 +0,0 @@
1
- /**
2
- * @returns true if the current process is running in a Codespaces environment
3
- */
4
- export function isCodespaces() {
5
- return process.env.CODESPACES;
6
- }
7
- //# sourceMappingURL=isCodespaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isCodespaces.js","sourceRoot":"","sources":["../../src/utilities/isCodespaces.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;AAChC,CAAC","sourcesContent":["/**\n * @returns true if the current process is running in a Codespaces environment\n */\n\nexport function isCodespaces() {\n return process.env.CODESPACES;\n}\n"]}