app-builder-lib 26.7.0 → 26.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/out/codeSign/windowsSignToolManager.d.ts +4 -5
  2. package/out/codeSign/windowsSignToolManager.js +76 -86
  3. package/out/codeSign/windowsSignToolManager.js.map +1 -1
  4. package/out/configuration.d.ts +34 -0
  5. package/out/configuration.js.map +1 -1
  6. package/out/index.d.ts +1 -1
  7. package/out/index.js.map +1 -1
  8. package/out/linuxPackager.js +1 -1
  9. package/out/linuxPackager.js.map +1 -1
  10. package/out/node-module-collector/index.d.ts +1 -2
  11. package/out/node-module-collector/nodeModulesCollector.js +2 -2
  12. package/out/node-module-collector/nodeModulesCollector.js.map +1 -1
  13. package/out/node-module-collector/types.d.ts +0 -4
  14. package/out/node-module-collector/types.js.map +1 -1
  15. package/out/node-module-collector/yarnNodeModulesCollector.d.ts +4 -10
  16. package/out/node-module-collector/yarnNodeModulesCollector.js +7 -197
  17. package/out/node-module-collector/yarnNodeModulesCollector.js.map +1 -1
  18. package/out/targets/AppxTarget.js +8 -7
  19. package/out/targets/AppxTarget.js.map +1 -1
  20. package/out/targets/FpmTarget.js +3 -3
  21. package/out/targets/FpmTarget.js.map +1 -1
  22. package/out/targets/MsiWrappedTarget.js +4 -3
  23. package/out/targets/MsiWrappedTarget.js.map +1 -1
  24. package/out/targets/appimage/AppImageTarget.d.ts +16 -0
  25. package/out/targets/{AppImageTarget.js → appimage/AppImageTarget.js} +65 -28
  26. package/out/targets/appimage/AppImageTarget.js.map +1 -0
  27. package/out/targets/appimage/appImageUtil.d.ts +23 -0
  28. package/out/targets/appimage/appImageUtil.js +266 -0
  29. package/out/targets/appimage/appImageUtil.js.map +1 -0
  30. package/out/targets/appimage/appLauncher.d.ts +3 -0
  31. package/out/targets/appimage/appLauncher.js +91 -0
  32. package/out/targets/appimage/appLauncher.js.map +1 -0
  33. package/out/targets/archive.js +2 -2
  34. package/out/targets/archive.js.map +1 -1
  35. package/out/toolsets/linux.d.ts +9 -0
  36. package/out/toolsets/linux.js +68 -0
  37. package/out/toolsets/linux.js.map +1 -0
  38. package/out/toolsets/windows.d.ts +42 -0
  39. package/out/toolsets/windows.js +143 -0
  40. package/out/toolsets/windows.js.map +1 -0
  41. package/out/util/packageMetadata.js +9 -5
  42. package/out/util/packageMetadata.js.map +1 -1
  43. package/out/version.d.ts +1 -1
  44. package/out/version.js +1 -1
  45. package/out/version.js.map +1 -1
  46. package/out/winPackager.js +4 -3
  47. package/out/winPackager.js.map +1 -1
  48. package/package.json +7 -7
  49. package/scheme.json +51 -0
  50. package/out/targets/AppImageTarget.d.ts +0 -14
  51. package/out/targets/AppImageTarget.js.map +0 -1
  52. package/out/targets/tools.d.ts +0 -2
  53. package/out/targets/tools.js +0 -46
  54. package/out/targets/tools.js.map +0 -1
package/out/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAwEA,4DAMC;AAED,sBA2DC;AA3ID,+CAA6E;AAC7E,+DAA8C;AAE9C,yCAAqC;AAErC,6DAAyD;AACzD,4CAAgD;AAEhD,6CAAkE;AAAzD,oGAAA,IAAI,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,6GAAA,aAAa,OAAA;AAC5C,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAahB,+BAWe;AARb,sGAAA,cAAc,OAAA;AACd,kGAAA,UAAU,OAAA;AACV,gGAAA,QAAQ,OAAA;AAER,8FAAA,MAAM,OAAA;AAmBR,uCAAkD;AAA5B,oGAAA,QAAQ,OAAA;AAI9B,6DAAsE;AAA7D,yHAAA,iBAAiB,OAAA;AAU1B,6CAAwD;AAAjC,yGAAA,UAAU,OAAA;AAEjC,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AACtB,6CAAgF;AAAlC,0GAAA,WAAW,OAAA;AACzD,uDAAqD;AAA5C,oHAAA,gB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IAAI,eAAe,EAAE,CAAC;YACpB,cAAc,CAAC,WAAW,EAAE,CAAA;YAC5B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,cAAc,CAAC,UAAU,EAAE,CAAA;QACvC,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YACvB,QAAQ,CAAC,2BAA2B,EAAE,CAAA;YACtC,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;QACjD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { InvalidConfigurationError, executeFinally, log } from \"builder-util\"\nimport { asArray } from \"builder-util-runtime\"\nimport { PublishOptions } from \"electron-publish\"\nimport { Packager } from \"./packager\"\nimport { PackagerOptions } from \"./packagerApi\"\nimport { PublishManager } from \"./publish/PublishManager\"\nimport { resolveFunction } from \"./util/resolve\"\n\nexport { Arch, archFromString, getArchSuffix } from \"builder-util\"\nexport { AppInfo } from \"./appInfo\"\nexport {\n AfterExtractContext,\n AfterPackContext,\n BeforePackContext,\n CommonConfiguration,\n Configuration,\n FuseOptionsV1,\n Hook,\n Hooks,\n MetadataDirectories,\n PackContext,\n} from \"./configuration\"\nexport {\n BeforeBuildContext,\n CompressionLevel,\n DEFAULT_TARGET,\n DIR_TARGET,\n Platform,\n SourceRepositoryInfo,\n Target,\n TargetConfigType,\n TargetConfiguration,\n TargetSpecificOptions,\n} from \"./core\"\nexport { ElectronBrandingOptions, ElectronDownloadOptions, ElectronPlatformName } from \"./electron/ElectronFramework\"\nexport { AppXOptions } from \"./options/AppXOptions\"\nexport { CommonWindowsInstallerConfiguration } from \"./options/CommonWindowsInstallerConfiguration\"\nexport { FileAssociation } from \"./options/FileAssociation\"\nexport { AppImageOptions, CommonLinuxOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxDesktopFile, LinuxTargetSpecificOptions } from \"./options/linuxOptions\"\nexport { DmgContent, DmgOptions, DmgWindow, MacConfiguration, MacOsTargetName, MasConfiguration } from \"./options/macOptions\"\nexport { AuthorMetadata, Metadata, RepositoryInfo } from \"./options/metadata\"\nexport { MsiOptions } from \"./options/MsiOptions\"\nexport { MsiWrappedOptions } from \"./options/MsiWrappedOptions\"\nexport { BackgroundAlignment, BackgroundScaling, PkgBackgroundOptions, PkgOptions } from \"./options/pkgOptions\"\nexport { AsarOptions, FileSet, FilesBuildOptions, PlatformSpecificBuildOptions, Protocol, ReleaseInfo } from \"./options/PlatformSpecificBuildOptions\"\nexport { PlugDescriptor, SlotDescriptor, SnapOptions } from \"./options/SnapOptions\"\nexport { SquirrelWindowsOptions } from \"./options/SquirrelWindowsOptions\"\nexport { WindowsAzureSigningConfiguration, WindowsConfiguration, WindowsSigntoolConfiguration } from \"./options/winOptions\"\nexport { BuildResult, Packager } from \"./packager\"\nexport { ArtifactBuildStarted, ArtifactCreated, PackagerOptions } from \"./packagerApi\"\nexport { CommonNsisOptions, CustomNsisBinary, NsisOptions, NsisWebOptions, PortableOptions } from \"./targets/nsis/nsisOptions\"\n\nexport { CancellationToken, ProgressInfo } from \"builder-util-runtime\"\nexport { PublishOptions, UploadTask } from \"electron-publish\"\nexport { WindowsSignOptions } from \"./codeSign/windowsCodeSign\"\nexport {\n CertificateFromStoreInfo,\n CustomWindowsSign,\n CustomWindowsSignTaskConfiguration,\n FileCodeSigningInfo,\n WindowsSignTaskConfiguration,\n} from \"./codeSign/windowsSignToolManager\"\nexport { ForgeOptions, buildForge } from \"./forge-maker\"\nexport { Framework, PrepareApplicationStageDirectoryOptions } from \"./Framework\"\nexport { LinuxPackager } from \"./linuxPackager\"\nexport { CustomMacSign, CustomMacSignOptions, MacPackager } from \"./macPackager\"\nexport { PlatformPackager } from \"./platformPackager\"\nexport { PublishManager } from \"./publish/PublishManager\"\nexport { WinPackager } from \"./winPackager\"\n\nconst expectedOptions = new Set([\"publish\", \"targets\", \"mac\", \"win\", \"linux\", \"projectDir\", \"platformPackagerFactory\", \"config\", \"effectiveOptionComputed\", \"prepackaged\"])\n\nexport function checkBuildRequestOptions(options: PackagerOptions & PublishOptions) {\n for (const optionName of Object.keys(options)) {\n if (!expectedOptions.has(optionName) && (options as any)[optionName] !== undefined) {\n throw new InvalidConfigurationError(`Unknown option \"${optionName}\"`)\n }\n }\n}\n\nexport function build(options: PackagerOptions & PublishOptions, packager: Packager = new Packager(options)): Promise<Array<string>> {\n checkBuildRequestOptions(options)\n\n const publishManager = new PublishManager(packager, options)\n const sigIntHandler = () => {\n log.warn(\"cancelled by SIGINT\")\n packager.cancellationToken.cancel()\n publishManager.cancelTasks()\n }\n process.once(\"SIGINT\", sigIntHandler)\n\n const promise = packager.build().then(async buildResult => {\n const afterAllArtifactBuild = await resolveFunction(packager.appInfo.type, buildResult.configuration.afterAllArtifactBuild, \"afterAllArtifactBuild\")\n if (afterAllArtifactBuild != null) {\n const newArtifacts = asArray(await Promise.resolve(afterAllArtifactBuild(buildResult)))\n if (newArtifacts.length === 0 || !publishManager.isPublish) {\n return buildResult.artifactPaths\n }\n\n const publishConfigurations = await publishManager.getGlobalPublishConfigurations()\n if (publishConfigurations == null || publishConfigurations.length === 0) {\n return buildResult.artifactPaths\n }\n\n for (const newArtifact of newArtifacts) {\n if (buildResult.artifactPaths.includes(newArtifact)) {\n log.warn({ newArtifact }, \"skipping publish of artifact, already published\")\n continue\n }\n buildResult.artifactPaths.push(newArtifact)\n for (const publishConfiguration of publishConfigurations) {\n await publishManager.scheduleUpload(\n publishConfiguration,\n {\n file: newArtifact,\n arch: null,\n },\n packager.appInfo\n )\n }\n }\n }\n return buildResult.artifactPaths\n })\n\n return executeFinally(promise, isErrorOccurred => {\n let promise: Promise<any>\n if (isErrorOccurred) {\n publishManager.cancelTasks()\n promise = Promise.resolve(null)\n } else {\n promise = publishManager.awaitTasks()\n }\n\n return promise.then(() => {\n packager.clearPackagerEventListeners()\n process.removeListener(\"SIGINT\", sig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AClC,CAAC;YAED,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;gBACvC,IAAI,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;oBACpD,kBAAG,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,EAAE,iDAAiD,CAAC,CAAA;oBAC5E,SAAQ;gBACV,CAAC;gBACD,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;gBAC3C,KAAK,MAAM,oBAAoB,IAAI,qBAAqB,EAAE,CAAC;oBACzD,MAAM,cAAc,CAAC,cAAc,CACjC,oBAAoB,EACpB;wBACE,IAAI,EAAE,WAAW;wBACjB,IAAI,EAAE,IAAI;qBACX,EACD,QAAQ,CAAC,OAAO,CACjB,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,WAAW,CAAC,aAAa,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,OAAO,IAAA,6BAAc,EAAC,OAAO,EAAE,eAAe,CAAC,EAAE;QAC/C,IAAI,OAAqB,CAAA;QACzB,IAAI,eAAe,EAAE,CAAC;YACpB,cAAc,CAAC,WAAW,EAAE,CAAA;YAC5B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,cAAc,CAAC,UAAU,EAAE,CAAA;QACvC,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;YACvB,QAAQ,CAAC,2BAA2B,EAAE,CAAA;YACtC,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;QACjD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { InvalidConfigurationError, executeFinally, log } from \"builder-util\"\nimport { asArray } from \"builder-util-runtime\"\nimport { PublishOptions } from \"electron-publish\"\nimport { Packager } from \"./packager\"\nimport { PackagerOptions } from \"./packagerApi\"\nimport { PublishManager } from \"./publish/PublishManager\"\nimport { resolveFunction } from \"./util/resolve\"\n\nexport { Arch, archFromString, getArchSuffix } from \"builder-util\"\nexport { AppInfo } from \"./appInfo\"\nexport {\n AfterExtractContext,\n AfterPackContext,\n BeforePackContext,\n CommonConfiguration,\n Configuration,\n FuseOptionsV1,\n Hook,\n Hooks,\n MetadataDirectories,\n PackContext,\n ToolsetConfig,\n} from \"./configuration\"\nexport {\n BeforeBuildContext,\n CompressionLevel,\n DEFAULT_TARGET,\n DIR_TARGET,\n Platform,\n SourceRepositoryInfo,\n Target,\n TargetConfigType,\n TargetConfiguration,\n TargetSpecificOptions,\n} from \"./core\"\nexport { ElectronBrandingOptions, ElectronDownloadOptions, ElectronPlatformName } from \"./electron/ElectronFramework\"\nexport { AppXOptions } from \"./options/AppXOptions\"\nexport { CommonWindowsInstallerConfiguration } from \"./options/CommonWindowsInstallerConfiguration\"\nexport { FileAssociation } from \"./options/FileAssociation\"\nexport { AppImageOptions, CommonLinuxOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxDesktopFile, LinuxTargetSpecificOptions } from \"./options/linuxOptions\"\nexport { DmgContent, DmgOptions, DmgWindow, MacConfiguration, MacOsTargetName, MasConfiguration } from \"./options/macOptions\"\nexport { AuthorMetadata, Metadata, RepositoryInfo } from \"./options/metadata\"\nexport { MsiOptions } from \"./options/MsiOptions\"\nexport { MsiWrappedOptions } from \"./options/MsiWrappedOptions\"\nexport { BackgroundAlignment, BackgroundScaling, PkgBackgroundOptions, PkgOptions } from \"./options/pkgOptions\"\nexport { AsarOptions, FileSet, FilesBuildOptions, PlatformSpecificBuildOptions, Protocol, ReleaseInfo } from \"./options/PlatformSpecificBuildOptions\"\nexport { PlugDescriptor, SlotDescriptor, SnapOptions } from \"./options/SnapOptions\"\nexport { SquirrelWindowsOptions } from \"./options/SquirrelWindowsOptions\"\nexport { WindowsAzureSigningConfiguration, WindowsConfiguration, WindowsSigntoolConfiguration } from \"./options/winOptions\"\nexport { BuildResult, Packager } from \"./packager\"\nexport { ArtifactBuildStarted, ArtifactCreated, PackagerOptions } from \"./packagerApi\"\nexport { CommonNsisOptions, CustomNsisBinary, NsisOptions, NsisWebOptions, PortableOptions } from \"./targets/nsis/nsisOptions\"\n\nexport { CancellationToken, ProgressInfo } from \"builder-util-runtime\"\nexport { PublishOptions, UploadTask } from \"electron-publish\"\nexport { WindowsSignOptions } from \"./codeSign/windowsCodeSign\"\nexport {\n CertificateFromStoreInfo,\n CustomWindowsSign,\n CustomWindowsSignTaskConfiguration,\n FileCodeSigningInfo,\n WindowsSignTaskConfiguration,\n} from \"./codeSign/windowsSignToolManager\"\nexport { ForgeOptions, buildForge } from \"./forge-maker\"\nexport { Framework, PrepareApplicationStageDirectoryOptions } from \"./Framework\"\nexport { LinuxPackager } from \"./linuxPackager\"\nexport { CustomMacSign, CustomMacSignOptions, MacPackager } from \"./macPackager\"\nexport { PlatformPackager } from \"./platformPackager\"\nexport { PublishManager } from \"./publish/PublishManager\"\nexport { WinPackager } from \"./winPackager\"\n\nconst expectedOptions = new Set([\"publish\", \"targets\", \"mac\", \"win\", \"linux\", \"projectDir\", \"platformPackagerFactory\", \"config\", \"effectiveOptionComputed\", \"prepackaged\"])\n\nexport function checkBuildRequestOptions(options: PackagerOptions & PublishOptions) {\n for (const optionName of Object.keys(options)) {\n if (!expectedOptions.has(optionName) && (options as any)[optionName] !== undefined) {\n throw new InvalidConfigurationError(`Unknown option \"${optionName}\"`)\n }\n }\n}\n\nexport function build(options: PackagerOptions & PublishOptions, packager: Packager = new Packager(options)): Promise<Array<string>> {\n checkBuildRequestOptions(options)\n\n const publishManager = new PublishManager(packager, options)\n const sigIntHandler = () => {\n log.warn(\"cancelled by SIGINT\")\n packager.cancellationToken.cancel()\n publishManager.cancelTasks()\n }\n process.once(\"SIGINT\", sigIntHandler)\n\n const promise = packager.build().then(async buildResult => {\n const afterAllArtifactBuild = await resolveFunction(packager.appInfo.type, buildResult.configuration.afterAllArtifactBuild, \"afterAllArtifactBuild\")\n if (afterAllArtifactBuild != null) {\n const newArtifacts = asArray(await Promise.resolve(afterAllArtifactBuild(buildResult)))\n if (newArtifacts.length === 0 || !publishManager.isPublish) {\n return buildResult.artifactPaths\n }\n\n const publishConfigurations = await publishManager.getGlobalPublishConfigurations()\n if (publishConfigurations == null || publishConfigurations.length === 0) {\n return buildResult.artifactPaths\n }\n\n for (const newArtifact of newArtifacts) {\n if (buildResult.artifactPaths.includes(newArtifact)) {\n log.warn({ newArtifact }, \"skipping publish of artifact, already published\")\n continue\n }\n buildResult.artifactPaths.push(newArtifact)\n for (const publishConfiguration of publishConfigurations) {\n await publishManager.scheduleUpload(\n publishConfiguration,\n {\n file: newArtifact,\n arch: null,\n },\n packager.appInfo\n )\n }\n }\n }\n return buildResult.artifactPaths\n })\n\n return executeFinally(promise, isErrorOccurred => {\n let promise: Promise<any>\n if (isErrorOccurred) {\n publishManager.cancelTasks()\n promise = Promise.resolve(null)\n } else {\n promise = publishManager.awaitTasks()\n }\n\n return promise.then(() => {\n packager.clearPackagerEventListeners()\n process.removeListener(\"SIGINT\", sigIntHandler)\n })\n })\n}\n"]}
@@ -33,7 +33,7 @@ class LinuxPackager extends platformPackager_1.PlatformPackager {
33
33
  const targetClass = (() => {
34
34
  switch (name) {
35
35
  case "appimage":
36
- return require("./targets/AppImageTarget").default;
36
+ return require("./targets/appimage/AppImageTarget").default;
37
37
  case "snap":
38
38
  return require("./targets/snap").default;
39
39
  case "flatpak":
@@ -1 +1 @@
1
- {"version":3,"file":"linuxPackager.js","sourceRoot":"","sources":["../src/linuxPackager.ts"],"names":[],"mappings":";;;AAyEA,oDAcC;AAvFD,+CAAmC;AACnC,wDAA4D;AAC5D,iCAAqD;AAGrD,yDAAqD;AAIrD,mEAA+D;AAE/D,2DAA4D;AAE5D,MAAa,aAAc,SAAQ,mCAAoC;IAGrE,YAAY,IAAc;;QACxB,KAAK,CAAC,IAAI,EAAE,eAAQ,CAAC,KAAK,CAA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AC,qBAAqB,CAAC,CAAC,OAAO,CAAA;oBAC/C;wBACE,OAAO,IAAI,CAAA;gBACf,CAAC;YACH,CAAC,CAAC,EAAE,CAAA;YAEJ,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;gBACpB,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;oBACzB,OAAO,IAAA,kCAAkB,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;gBAC/C,CAAC;gBAED,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAA;YACzD,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AA1DD,sCA0DC;AAED,SAAgB,oBAAoB,CAAC,IAAU;IAC7C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,mBAAI,CAAC,GAAG;YACX,OAAO,QAAQ,CAAA;QACjB,KAAK,mBAAI,CAAC,IAAI;YACZ,OAAO,MAAM,CAAA;QACf,KAAK,mBAAI,CAAC,MAAM;YACd,OAAO,KAAK,CAAA;QACd,KAAK,mBAAI,CAAC,KAAK;YACb,OAAO,aAAa,CAAA;QAEtB;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC","sourcesContent":["import { Arch } from \"builder-util\"\nimport { sanitizeFileName } from \"builder-util/out/filename\"\nimport { DIR_TARGET, Platform, Target } from \"./core\"\nimport { LinuxConfiguration } from \"./options/linuxOptions\"\nimport { Packager } from \"./packager\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport AppImageTarget from \"./targets/AppImageTarget\"\nimport FlatpakTarget from \"./targets/FlatpakTarget\"\nimport FpmTarget from \"./targets/FpmTarget\"\nimport { LinuxTargetHelper } from \"./targets/LinuxTargetHelper\"\nimport SnapTarget from \"./targets/snap\"\nimport { createCommonTarget } from \"./targets/targetFactory\"\n\nexport class LinuxPackager extends PlatformPackager<LinuxConfiguration> {\n readonly executableName: string\n\n constructor(info: Packager) {\n super(info, Platform.LINUX)\n\n const executableName = this.platformSpecificBuildOptions.executableName ?? info.config.executableName\n this.executableName = executableName == null ? this.appInfo.sanitizedName.toLowerCase() : sanitizeFileName(executableName)\n }\n\n get defaultTarget(): Array<string> {\n return [\"snap\", \"appimage\"]\n }\n\n createTargets(targets: Array<string>, mapper: (name: string, factory: (outDir: string) => Target) => void): void {\n let helper: LinuxTargetHelper | null\n const getHelper = () => {\n if (helper == null) {\n helper = new LinuxTargetHelper(this)\n }\n return helper\n }\n\n for (const name of targets) {\n if (name === DIR_TARGET) {\n continue\n }\n\n const targetClass: typeof AppImageTarget | typeof SnapTarget | typeof FlatpakTarget | typeof FpmTarget | null = (() => {\n switch (name) {\n case \"appimage\":\n return require(\"./targets/AppImageTarget\").default\n case \"snap\":\n return require(\"./targets/snap\").default\n case \"flatpak\":\n return require(\"./targets/FlatpakTarget\").default\n case \"deb\":\n case \"rpm\":\n case \"sh\":\n case \"freebsd\":\n case \"pacman\":\n case \"apk\":\n case \"p5p\":\n return require(\"./targets/FpmTarget\").default\n default:\n return null\n }\n })()\n\n mapper(name, outDir => {\n if (targetClass === null) {\n return createCommonTarget(name, outDir, this)\n }\n\n return new targetClass(name, this, getHelper(), outDir)\n })\n }\n }\n}\n\nexport function toAppImageOrSnapArch(arch: Arch): string {\n switch (arch) {\n case Arch.x64:\n return \"x86_64\"\n case Arch.ia32:\n return \"i386\"\n case Arch.armv7l:\n return \"arm\"\n case Arch.arm64:\n return \"arm_aarch64\"\n\n default:\n throw new Error(`Unsupported arch ${arch}`)\n }\n}\n"]}
1
+ {"version":3,"file":"linuxPackager.js","sourceRoot":"","sources":["../src/linuxPackager.ts"],"names":[],"mappings":";;;AAyEA,oDAcC;AAvFD,+CAAmC;AACnC,wDAA4D;AAC5D,iCAAqD;AAGrD,yDAAqD;AAIrD,mEAA+D;AAE/D,2DAA4D;AAE5D,MAAa,aAAc,SAAQ,mCAAoC;IAG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,CAAC;oBACd,KAAK,KAAK,CAAC;oBACX,KAAK,KAAK;wBACR,OAAO,OAAO,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAA;oBAC/C;wBACE,OAAO,IAAI,CAAA;gBACf,CAAC;YACH,CAAC,CAAC,EAAE,CAAA;YAEJ,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;gBACpB,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;oBACzB,OAAO,IAAA,kCAAkB,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;gBAC/C,CAAC;gBAED,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAA;YACzD,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AA1DD,sCA0DC;AAED,SAAgB,oBAAoB,CAAC,IAAU;IAC7C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,mBAAI,CAAC,GAAG;YACX,OAAO,QAAQ,CAAA;QACjB,KAAK,mBAAI,CAAC,IAAI;YACZ,OAAO,MAAM,CAAA;QACf,KAAK,mBAAI,CAAC,MAAM;YACd,OAAO,KAAK,CAAA;QACd,KAAK,mBAAI,CAAC,KAAK;YACb,OAAO,aAAa,CAAA;QAEtB;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC","sourcesContent":["import { Arch } from \"builder-util\"\nimport { sanitizeFileName } from \"builder-util/out/filename\"\nimport { DIR_TARGET, Platform, Target } from \"./core\"\nimport { LinuxConfiguration } from \"./options/linuxOptions\"\nimport { Packager } from \"./packager\"\nimport { PlatformPackager } from \"./platformPackager\"\nimport AppImageTarget from \"./targets/appimage/AppImageTarget\"\nimport FlatpakTarget from \"./targets/FlatpakTarget\"\nimport FpmTarget from \"./targets/FpmTarget\"\nimport { LinuxTargetHelper } from \"./targets/LinuxTargetHelper\"\nimport SnapTarget from \"./targets/snap\"\nimport { createCommonTarget } from \"./targets/targetFactory\"\n\nexport class LinuxPackager extends PlatformPackager<LinuxConfiguration> {\n readonly executableName: string\n\n constructor(info: Packager) {\n super(info, Platform.LINUX)\n\n const executableName = this.platformSpecificBuildOptions.executableName ?? info.config.executableName\n this.executableName = executableName == null ? this.appInfo.sanitizedName.toLowerCase() : sanitizeFileName(executableName)\n }\n\n get defaultTarget(): Array<string> {\n return [\"snap\", \"appimage\"]\n }\n\n createTargets(targets: Array<string>, mapper: (name: string, factory: (outDir: string) => Target) => void): void {\n let helper: LinuxTargetHelper | null\n const getHelper = () => {\n if (helper == null) {\n helper = new LinuxTargetHelper(this)\n }\n return helper\n }\n\n for (const name of targets) {\n if (name === DIR_TARGET) {\n continue\n }\n\n const targetClass: typeof AppImageTarget | typeof SnapTarget | typeof FlatpakTarget | typeof FpmTarget | null = (() => {\n switch (name) {\n case \"appimage\":\n return require(\"./targets/appimage/AppImageTarget\").default\n case \"snap\":\n return require(\"./targets/snap\").default\n case \"flatpak\":\n return require(\"./targets/FlatpakTarget\").default\n case \"deb\":\n case \"rpm\":\n case \"sh\":\n case \"freebsd\":\n case \"pacman\":\n case \"apk\":\n case \"p5p\":\n return require(\"./targets/FpmTarget\").default\n default:\n return null\n }\n })()\n\n mapper(name, outDir => {\n if (targetClass === null) {\n return createCommonTarget(name, outDir, this)\n }\n\n return new targetClass(name, this, getHelper(), outDir)\n })\n }\n }\n}\n\nexport function toAppImageOrSnapArch(arch: Arch): string {\n switch (arch) {\n case Arch.x64:\n return \"x86_64\"\n case Arch.ia32:\n return \"i386\"\n case Arch.armv7l:\n return \"arm\"\n case Arch.arm64:\n return \"arm_aarch64\"\n\n default:\n throw new Error(`Unsupported arch ${arch}`)\n }\n}\n"]}
@@ -4,12 +4,11 @@ import { NpmNodeModulesCollector } from "./npmNodeModulesCollector";
4
4
  import { getPackageManagerCommand, PM } from "./packageManager";
5
5
  import { PnpmNodeModulesCollector } from "./pnpmNodeModulesCollector";
6
6
  import { NodeModuleInfo } from "./types";
7
- import { YarnNodeModulesCollector } from "./yarnNodeModulesCollector";
8
7
  import { BunNodeModulesCollector } from "./bunNodeModulesCollector";
9
8
  import { Lazy } from "lazy-val";
10
9
  import { TraversalNodeModulesCollector } from "./traversalNodeModulesCollector";
11
10
  export { getPackageManagerCommand, PM };
12
- export declare function getCollectorByPackageManager(pm: PM, rootDir: string, tempDirManager: TmpDir): NpmNodeModulesCollector | PnpmNodeModulesCollector | YarnNodeModulesCollector | TraversalNodeModulesCollector | BunNodeModulesCollector;
11
+ export declare function getCollectorByPackageManager(pm: PM, rootDir: string, tempDirManager: TmpDir): NpmNodeModulesCollector | PnpmNodeModulesCollector | TraversalNodeModulesCollector | BunNodeModulesCollector;
13
12
  export declare function getNodeModules(pm: PM, { rootDir, tempDirManager, packageName, }: {
14
13
  rootDir: string;
15
14
  tempDirManager: TmpDir;
@@ -305,7 +305,7 @@ class NodeModulesCollector {
305
305
  // If the command is a Windows script file (.cmd), we need to wrap it in a .bat file to ensure it runs correctly with cmd.exe
306
306
  // This is necessary because .cmd files are not directly executable in the same way as .bat files.
307
307
  // We create a temporary .bat file that calls the .cmd file with the provided arguments. The .bat file will be executed by cmd.exe.
308
- // Note: This is a workaround for Windows command execution quirks for specifically when `shell: false`
308
+ // Note: This is a workaround for Windows command execution quirks when using `shell: true`
309
309
  const tempBatFile = await this.tempDirManager.getTempFile({
310
310
  prefix: execName,
311
311
  suffix: ".bat",
@@ -313,7 +313,7 @@ class NodeModulesCollector {
313
313
  const batScript = `@echo off\r\n"${command}" %*\r\n`; // <-- CRLF required for .bat
314
314
  await fs.writeFile(tempBatFile, batScript, { encoding: "utf8" });
315
315
  command = "cmd.exe";
316
- args = ["/c", tempBatFile, ...args];
316
+ args = ["/c", `"${tempBatFile}"`, ...args];
317
317
  }
318
318
  await new Promise((resolve, reject) => {
319
319
  const outStream = (0, fs_extra_1.createWriteStream)(tempOutputFile);
@@ -1 +1 @@
1
- {"version":3,"file":"node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AE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;gBACvB,SAAS,CAAC,KAAK,EAAE,CAAA;gBACjB,0CAA0C;gBAC1C,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;gBAC5F,IAAI,YAAY,EAAE,CAAC;oBACjB,kBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,uIAAuI,CAAC,CAAA;gBAC1J,CAAC;gBACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,kBAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,wDAAwD,CAAC,CAAA;gBACjF,CAAC;gBACD,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,IAAI,YAAY,CAAA;gBAChD,OAAO,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kDAAkD,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC,CAAA;YAC5H,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA/XD,oDA+XC","sourcesContent":["import { exists, log, retry, TmpDir } from \"builder-util\"\nimport * as childProcess from \"child_process\"\nimport * as fs from \"fs-extra\"\nimport { createWriteStream } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { hoist, type HoisterResult, type HoisterTree } from \"./hoist\"\nimport { ModuleManager } from \"./moduleManager\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\nimport type { Dependency, DependencyGraph, NodeModuleInfo, PackageJson } from \"./types\"\n\nexport abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDepType, OptionalDepType>, OptionalDepType> {\n private readonly nodeModules: NodeModuleInfo[] = []\n protected readonly allDependencies: Map<string, ProdDepType> = new Map()\n protected readonly productionGraph: DependencyGraph = {}\n protected readonly cache: ModuleManager = new ModuleManager()\n\n protected isHoisted = new Lazy<boolean>(async () => {\n const { manager } = this.installOptions\n const command = getPackageManagerCommand(manager)\n const config = (await this.asyncExec(command, [\"config\", \"list\"])).stdout\n if (config == null) {\n log.debug({ manager }, \"unable to determine if node_modules are hoisted: no config output. falling back to hoisted mode\")\n return false\n }\n const lines = Object.fromEntries(config.split(\"\\n\").map(line => line.split(\"=\").map(s => s.trim())))\n if (lines[\"node-linker\"] === \"hoisted\") {\n log.debug({ manager }, \"node_modules are hoisted\")\n return true\n }\n return false\n })\n\n constructor(\n protected readonly rootDir: string,\n private readonly tempDirManager: TmpDir\n ) {}\n\n /**\n * Retrieves and collects all Node.js modules for a given package.\n *\n * This method orchestrates the entire module collection process by:\n * 1. Fetching the dependency tree from the package manager\n * 2. Collecting all dependencies recursively\n * 3. Extracting workspace references if applicable\n * 4. Building a production dependency graph\n * 5. Hoisting the dependencies to their final locations\n * 6. Resolving and returning module information\n *\n * @param options - Configuration object\n * @param options.packageName - The name of the package to collect modules for\n * @returns Promise resolving to an array of NodeModuleInfo objects representing all collected modules\n */\n public async getNodeModules({ packageName }: { packageName: string }): Promise<NodeModuleInfo[]> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\n\n const hoisterResult: HoisterResult = hoist(this.transformToHoisterTree(this.productionGraph, packageName), {\n check: log.isDebugEnabled,\n })\n\n await this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\n\n return this.nodeModules\n }\n\n public abstract readonly installOptions: {\n manager: PM\n lockfile: string\n }\n\n protected abstract getArgs(): string[]\n protected abstract extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n /**\n * Retrieves the dependency tree from the package manager.\n *\n * Executes the appropriate package manager command to fetch the dependency tree and writes\n * the output to a temporary file. Includes retry logic to handle transient failures such as\n * incomplete JSON output or missing files. Will retry up to 1 time with exponential backoff.\n *\n * @param pm - The package manager to use (npm, yarn, pnpm, etc.)\n * @returns Promise resolving to the parsed dependency tree\n * @throws {Error} If the dependency tree cannot be retrieved after retries\n */\n protected async getDependenciesTree(pm: PM): Promise<ProdDepType> {\n const command = getPackageManagerCommand(pm)\n const args = this.getArgs()\n\n const tempOutputFile = await this.tempDirManager.getTempFile({\n prefix: path.basename(command, path.extname(command)),\n suffix: \"output.json\",\n })\n\n return retry(\n async () => {\n await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile)\n const shellOutput = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n const result = await Promise.resolve(this.parseDependenciesTree(shellOutput))\n return result\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const fields: Record<string, string> = { error: error.message, tempOutputFile, cwd: this.rootDir, packageManager: pm }\n\n if (!(await exists(tempOutputFile))) {\n log.debug(fields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n fields.fileContentLength = fileContent.length.toString()\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n // extract small start/end sample for debugging purposes (e.g. polluted console output)\n const lines = fileContent.split(\"\\n\")\n const lineSampleSize = Math.min(5, lines.length / 2)\n if (2 * lineSampleSize > 5) {\n fields.sampleStart = lines.slice(0, lineSampleSize).join(\"\\n\")\n fields.sampleEnd = lines.slice(-lineSampleSize).join(\"\\n\")\n } else {\n fields.content = fileContent\n }\n\n if (error.message?.includes(\"Unexpected end of JSON input\")) {\n log.debug(fields, \"JSON parse error in dependency tree, retrying\")\n return true\n }\n\n log.error(fields, \"error parsing dependencies tree\")\n return false\n },\n }\n )\n }\n\n /**\n * Parses the dependencies tree from shell command output.\n *\n **/\n protected parseDependenciesTree(shellOutput: string): ProdDepType | Promise<ProdDepType> {\n return this.extractJsonFromPollutedOutput<ProdDepType>(shellOutput)\n }\n\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n // Please for the love of all that is holy, this should cover 99% of cases where npm/pnpm/yarn output is clean JSON\n return JSON.parse(consoleOutput)\n } catch {\n // ignore\n }\n\n // DEDICATED FALLBACK FOR POLLUTED OUTPUT, non-trivial to implement correctly, not needed in most cases, and highly inefficient\n\n // Find the first index that starts with { or [\n const bracketOpen = Math.max(consoleOutput.indexOf(\"{\"), 0)\n const bracketOpenSquare = Math.max(consoleOutput.indexOf(\"[\"), 0)\n const start = Math.min(bracketOpen, bracketOpenSquare) // always non-negative due to Math.max above\n\n for (let i = start; i < consoleOutput.length; i++) {\n const slice = consoleOutput.slice(start, i + 1)\n try {\n return JSON.parse(slice)\n } catch {\n // ignore, try next\n }\n }\n throw new Error(\"No JSON content found in output\")\n }\n\n protected cacheKey(pkg: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n protected packageVersionString(pkg: Pick<ProdDepType, \"name\" | \"version\">): string {\n return `${pkg.name}@${pkg.version}`\n }\n\n /**\n * Determines if a given dependency is a production dependency of a package.\n *\n * Checks both the dependencies and optionalDependencies of a package to see if\n * the specified dependency name is listed.\n *\n * @param depName - The name of the dependency to check\n * @param pkg - The package to search for the dependency in\n * @returns True if the dependency is found in either dependencies or optionalDependencies, false otherwise\n */\n protected isProdDependency(depName: string, pkg: ProdDepType): boolean {\n const prodDeps = { ...pkg.dependencies, ...pkg.optionalDependencies }\n return prodDeps[depName] != null\n }\n\n protected async locatePackageWithVersion(depTree: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): Promise<{ packageDir: string; packageJson: PackageJson } | null> {\n const result = await this.cache.locatePackageVersion({\n parentDir: depTree.path,\n pkgName: depTree.name,\n requiredRange: depTree.version,\n })\n return result\n }\n /**\n * Parses a dependency identifier string into name and version components.\n *\n * Handles both scoped packages (e.g., \"@scope/pkg@1.2.3\") and regular packages (e.g., \"pkg@1.2.3\").\n * If the identifier is malformed or cannot be parsed, defaults to treating the entire string as\n * the package name with an \"unknown\" version.\n */\n protected parseNameVersion(identifier: string): { name: string; version: string } {\n const lastAt = identifier.lastIndexOf(\"@\")\n if (lastAt <= 0) {\n // fallback for scoped packages or malformed strings\n return { name: identifier, version: \"unknown\" }\n }\n const name = identifier.slice(0, lastAt)\n const version = identifier.slice(lastAt + 1)\n return { name, version }\n }\n\n /**\n * Retrieves the dependency tree and handles workspace package self-references.\n *\n * If the project is a workspace project, this method removes the root package's self-reference\n * from the dependency tree to avoid circular dependencies. It promotes the root package's\n * direct dependencies to the top level of the tree.\n *\n * @param tree - The original dependency tree\n * @param packageName - The name of the package to check for and remove from the tree\n * @returns The extracted dependency subtree\n */\n protected getTreeFromWorkspaces(tree: ProdDepType, packageName: string): ProdDepType {\n if (tree.workspaces && tree.dependencies) {\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (key === packageName) {\n return value\n }\n }\n }\n\n return tree\n }\n\n private transformToHoisterTree(obj: DependencyGraph, key: string, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const { name, version } = this.parseNameVersion(key)\n\n if (!node) {\n node = {\n name,\n identName: name,\n reference: version,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>(),\n }\n\n nodes.set(key, node)\n\n const deps = (obj[key] || {}).dependencies || []\n for (const dep of deps) {\n const child = this.transformToHoisterTree(obj, dep, nodes)\n node.dependencies.add(child)\n }\n }\n\n return node\n }\n\n private async _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[]) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n const reference = [...d.references][0]\n const p = this.allDependencies.get(`${d.name}@${reference}`)?.path\n if (p === undefined) {\n log.warn({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n\n // fix npm list issue\n // https://github.com/npm/cli/issues/8535\n if (!(await this.cache.exists[p])) {\n log.debug({ name: d.name, reference, p }, \"dependency path does not exist\")\n continue\n }\n\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: await this.cache.realPath[p],\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n await this._getNodeModules(d.dependencies, node.dependencies)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n async asyncExec(command: string, args: string[], cwd: string = this.rootDir): Promise<{ stdout: string | undefined; stderr: string | undefined }> {\n const file = await this.tempDirManager.getTempFile({ prefix: \"exec-\", suffix: \".txt\" })\n try {\n await this.streamCollectorCommandToFile(command, args, cwd, file)\n const result = await fs.readFile(file, { encoding: \"utf8\" })\n return { stdout: result?.trim(), stderr: undefined }\n } catch (error: any) {\n log.debug({ error: error.message }, \"failed to execute command\")\n return { stdout: undefined, stderr: error.message }\n }\n }\n\n /**\n * Executes a command and streams its output to a file.\n *\n * Spawns a child process to execute the specified command with arguments, capturing stdout\n * to a file. Handles Windows-specific quirks by wrapping .cmd files in a temporary .bat file\n * when necessary. Enables corepack strict mode by default but allows process.env overrides.\n *\n * Special handling for `npm list` exit code 1, which is expected in certain scenarios.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param tempOutputFile - The path to the temporary file where stdout will be written\n * @returns Promise that resolves when the command completes successfully or rejects if it fails\n * @throws {Error} If the child process spawn fails or exits with a non-zero code\n */\n async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string) {\n const execName = path.basename(command, path.extname(command))\n const isWindowsScriptFile = process.platform === \"win32\" && path.extname(command).toLowerCase() === \".cmd\"\n if (isWindowsScriptFile) {\n // If the command is a Windows script file (.cmd), we need to wrap it in a .bat file to ensure it runs correctly with cmd.exe\n // This is necessary because .cmd files are not directly executable in the same way as .bat files.\n // We create a temporary .bat file that calls the .cmd file with the provided arguments. The .bat file will be executed by cmd.exe.\n // Note: This is a workaround for Windows command execution quirks for specifically when `shell: false`\n const tempBatFile = await this.tempDirManager.getTempFile({\n prefix: execName,\n suffix: \".bat\",\n })\n const batScript = `@echo off\\r\\n\"${command}\" %*\\r\\n` // <-- CRLF required for .bat\n await fs.writeFile(tempBatFile, batScript, { encoding: \"utf8\" })\n command = \"cmd.exe\"\n args = [\"/c\", tempBatFile, ...args]\n }\n\n await new Promise<void>((resolve, reject) => {\n const outStream = createWriteStream(tempOutputFile)\n\n const child = childProcess.spawn(command, args, {\n cwd,\n env: { COREPACK_ENABLE_STRICT: \"0\", ...process.env }, // allow `process.env` overrides\n shell: true, // `true`` is now required: https://github.com/electron-userland/electron-builder/issues/9488\n })\n\n let stderr = \"\"\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n child.on(\"error\", err => {\n reject(new Error(`Node module collector spawn failed: ${err.message}`))\n })\n\n child.on(\"close\", code => {\n outStream.close()\n // https://github.com/npm/npm/issues/17624\n const shouldIgnore = code === 1 && \"npm\" === execName.toLowerCase() && args.includes(\"list\")\n if (shouldIgnore) {\n log.debug(null, \"`npm list` returned non-zero exit code, but it MIGHT be expected (https://github.com/npm/npm/issues/17624). Check stderr for details.\")\n }\n if (stderr.length > 0) {\n log.debug({ stderr }, \"note: there was node module collector output on stderr\")\n }\n const shouldResolve = code === 0 || shouldIgnore\n return shouldResolve ? resolve() : reject(new Error(`Node module collector process exited with code ${code}:\\n${stderr}`))\n })\n })\n }\n}\n"]}
1
+ {"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAyD;AACzD,8CAA6C;AAC7C,+BAA8B;AA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M,YAAY,GAAG,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;gBAC5F,IAAI,YAAY,EAAE,CAAC;oBACjB,kBAAG,CAAC,KAAK,CAAC,IAAI,EAAE,uIAAuI,CAAC,CAAA;gBAC1J,CAAC;gBACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,kBAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,wDAAwD,CAAC,CAAA;gBACjF,CAAC;gBACD,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,IAAI,YAAY,CAAA;gBAChD,OAAO,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kDAAkD,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC,CAAA;YAC5H,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA/XD,oDA+XC","sourcesContent":["import { exists, log, retry, TmpDir } from \"builder-util\"\nimport * as childProcess from \"child_process\"\nimport * as fs from \"fs-extra\"\nimport { createWriteStream } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { hoist, type HoisterResult, type HoisterTree } from \"./hoist\"\nimport { ModuleManager } from \"./moduleManager\"\nimport { getPackageManagerCommand, PM } from \"./packageManager\"\nimport type { Dependency, DependencyGraph, NodeModuleInfo, PackageJson } from \"./types\"\n\nexport abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDepType, OptionalDepType>, OptionalDepType> {\n private readonly nodeModules: NodeModuleInfo[] = []\n protected readonly allDependencies: Map<string, ProdDepType> = new Map()\n protected readonly productionGraph: DependencyGraph = {}\n protected readonly cache: ModuleManager = new ModuleManager()\n\n protected isHoisted = new Lazy<boolean>(async () => {\n const { manager } = this.installOptions\n const command = getPackageManagerCommand(manager)\n const config = (await this.asyncExec(command, [\"config\", \"list\"])).stdout\n if (config == null) {\n log.debug({ manager }, \"unable to determine if node_modules are hoisted: no config output. falling back to hoisted mode\")\n return false\n }\n const lines = Object.fromEntries(config.split(\"\\n\").map(line => line.split(\"=\").map(s => s.trim())))\n if (lines[\"node-linker\"] === \"hoisted\") {\n log.debug({ manager }, \"node_modules are hoisted\")\n return true\n }\n return false\n })\n\n constructor(\n protected readonly rootDir: string,\n private readonly tempDirManager: TmpDir\n ) {}\n\n /**\n * Retrieves and collects all Node.js modules for a given package.\n *\n * This method orchestrates the entire module collection process by:\n * 1. Fetching the dependency tree from the package manager\n * 2. Collecting all dependencies recursively\n * 3. Extracting workspace references if applicable\n * 4. Building a production dependency graph\n * 5. Hoisting the dependencies to their final locations\n * 6. Resolving and returning module information\n *\n * @param options - Configuration object\n * @param options.packageName - The name of the package to collect modules for\n * @returns Promise resolving to an array of NodeModuleInfo objects representing all collected modules\n */\n public async getNodeModules({ packageName }: { packageName: string }): Promise<NodeModuleInfo[]> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\n\n const hoisterResult: HoisterResult = hoist(this.transformToHoisterTree(this.productionGraph, packageName), {\n check: log.isDebugEnabled,\n })\n\n await this._getNodeModules(hoisterResult.dependencies, this.nodeModules)\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\n\n return this.nodeModules\n }\n\n public abstract readonly installOptions: {\n manager: PM\n lockfile: string\n }\n\n protected abstract getArgs(): string[]\n protected abstract extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n /**\n * Retrieves the dependency tree from the package manager.\n *\n * Executes the appropriate package manager command to fetch the dependency tree and writes\n * the output to a temporary file. Includes retry logic to handle transient failures such as\n * incomplete JSON output or missing files. Will retry up to 1 time with exponential backoff.\n *\n * @param pm - The package manager to use (npm, yarn, pnpm, etc.)\n * @returns Promise resolving to the parsed dependency tree\n * @throws {Error} If the dependency tree cannot be retrieved after retries\n */\n protected async getDependenciesTree(pm: PM): Promise<ProdDepType> {\n const command = getPackageManagerCommand(pm)\n const args = this.getArgs()\n\n const tempOutputFile = await this.tempDirManager.getTempFile({\n prefix: path.basename(command, path.extname(command)),\n suffix: \"output.json\",\n })\n\n return retry(\n async () => {\n await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile)\n const shellOutput = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n const result = await Promise.resolve(this.parseDependenciesTree(shellOutput))\n return result\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const fields: Record<string, string> = { error: error.message, tempOutputFile, cwd: this.rootDir, packageManager: pm }\n\n if (!(await exists(tempOutputFile))) {\n log.debug(fields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await fs.readFile(tempOutputFile, { encoding: \"utf8\" })\n fields.fileContentLength = fileContent.length.toString()\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n // extract small start/end sample for debugging purposes (e.g. polluted console output)\n const lines = fileContent.split(\"\\n\")\n const lineSampleSize = Math.min(5, lines.length / 2)\n if (2 * lineSampleSize > 5) {\n fields.sampleStart = lines.slice(0, lineSampleSize).join(\"\\n\")\n fields.sampleEnd = lines.slice(-lineSampleSize).join(\"\\n\")\n } else {\n fields.content = fileContent\n }\n\n if (error.message?.includes(\"Unexpected end of JSON input\")) {\n log.debug(fields, \"JSON parse error in dependency tree, retrying\")\n return true\n }\n\n log.error(fields, \"error parsing dependencies tree\")\n return false\n },\n }\n )\n }\n\n /**\n * Parses the dependencies tree from shell command output.\n *\n **/\n protected parseDependenciesTree(shellOutput: string): ProdDepType | Promise<ProdDepType> {\n return this.extractJsonFromPollutedOutput<ProdDepType>(shellOutput)\n }\n\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n // Please for the love of all that is holy, this should cover 99% of cases where npm/pnpm/yarn output is clean JSON\n return JSON.parse(consoleOutput)\n } catch {\n // ignore\n }\n\n // DEDICATED FALLBACK FOR POLLUTED OUTPUT, non-trivial to implement correctly, not needed in most cases, and highly inefficient\n\n // Find the first index that starts with { or [\n const bracketOpen = Math.max(consoleOutput.indexOf(\"{\"), 0)\n const bracketOpenSquare = Math.max(consoleOutput.indexOf(\"[\"), 0)\n const start = Math.min(bracketOpen, bracketOpenSquare) // always non-negative due to Math.max above\n\n for (let i = start; i < consoleOutput.length; i++) {\n const slice = consoleOutput.slice(start, i + 1)\n try {\n return JSON.parse(slice)\n } catch {\n // ignore, try next\n }\n }\n throw new Error(\"No JSON content found in output\")\n }\n\n protected cacheKey(pkg: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n protected packageVersionString(pkg: Pick<ProdDepType, \"name\" | \"version\">): string {\n return `${pkg.name}@${pkg.version}`\n }\n\n /**\n * Determines if a given dependency is a production dependency of a package.\n *\n * Checks both the dependencies and optionalDependencies of a package to see if\n * the specified dependency name is listed.\n *\n * @param depName - The name of the dependency to check\n * @param pkg - The package to search for the dependency in\n * @returns True if the dependency is found in either dependencies or optionalDependencies, false otherwise\n */\n protected isProdDependency(depName: string, pkg: ProdDepType): boolean {\n const prodDeps = { ...pkg.dependencies, ...pkg.optionalDependencies }\n return prodDeps[depName] != null\n }\n\n protected async locatePackageWithVersion(depTree: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): Promise<{ packageDir: string; packageJson: PackageJson } | null> {\n const result = await this.cache.locatePackageVersion({\n parentDir: depTree.path,\n pkgName: depTree.name,\n requiredRange: depTree.version,\n })\n return result\n }\n /**\n * Parses a dependency identifier string into name and version components.\n *\n * Handles both scoped packages (e.g., \"@scope/pkg@1.2.3\") and regular packages (e.g., \"pkg@1.2.3\").\n * If the identifier is malformed or cannot be parsed, defaults to treating the entire string as\n * the package name with an \"unknown\" version.\n */\n protected parseNameVersion(identifier: string): { name: string; version: string } {\n const lastAt = identifier.lastIndexOf(\"@\")\n if (lastAt <= 0) {\n // fallback for scoped packages or malformed strings\n return { name: identifier, version: \"unknown\" }\n }\n const name = identifier.slice(0, lastAt)\n const version = identifier.slice(lastAt + 1)\n return { name, version }\n }\n\n /**\n * Retrieves the dependency tree and handles workspace package self-references.\n *\n * If the project is a workspace project, this method removes the root package's self-reference\n * from the dependency tree to avoid circular dependencies. It promotes the root package's\n * direct dependencies to the top level of the tree.\n *\n * @param tree - The original dependency tree\n * @param packageName - The name of the package to check for and remove from the tree\n * @returns The extracted dependency subtree\n */\n protected getTreeFromWorkspaces(tree: ProdDepType, packageName: string): ProdDepType {\n if (tree.workspaces && tree.dependencies) {\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (key === packageName) {\n return value\n }\n }\n }\n\n return tree\n }\n\n private transformToHoisterTree(obj: DependencyGraph, key: string, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const { name, version } = this.parseNameVersion(key)\n\n if (!node) {\n node = {\n name,\n identName: name,\n reference: version,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>(),\n }\n\n nodes.set(key, node)\n\n const deps = (obj[key] || {}).dependencies || []\n for (const dep of deps) {\n const child = this.transformToHoisterTree(obj, dep, nodes)\n node.dependencies.add(child)\n }\n }\n\n return node\n }\n\n private async _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[]) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n const reference = [...d.references][0]\n const p = this.allDependencies.get(`${d.name}@${reference}`)?.path\n if (p === undefined) {\n log.warn({ name: d.name, reference }, \"cannot find path for dependency\")\n continue\n }\n\n // fix npm list issue\n // https://github.com/npm/cli/issues/8535\n if (!(await this.cache.exists[p])) {\n log.debug({ name: d.name, reference, p }, \"dependency path does not exist\")\n continue\n }\n\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir: await this.cache.realPath[p],\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n await this._getNodeModules(d.dependencies, node.dependencies)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n async asyncExec(command: string, args: string[], cwd: string = this.rootDir): Promise<{ stdout: string | undefined; stderr: string | undefined }> {\n const file = await this.tempDirManager.getTempFile({ prefix: \"exec-\", suffix: \".txt\" })\n try {\n await this.streamCollectorCommandToFile(command, args, cwd, file)\n const result = await fs.readFile(file, { encoding: \"utf8\" })\n return { stdout: result?.trim(), stderr: undefined }\n } catch (error: any) {\n log.debug({ error: error.message }, \"failed to execute command\")\n return { stdout: undefined, stderr: error.message }\n }\n }\n\n /**\n * Executes a command and streams its output to a file.\n *\n * Spawns a child process to execute the specified command with arguments, capturing stdout\n * to a file. Handles Windows-specific quirks by wrapping .cmd files in a temporary .bat file\n * when necessary. Enables corepack strict mode by default but allows process.env overrides.\n *\n * Special handling for `npm list` exit code 1, which is expected in certain scenarios.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param tempOutputFile - The path to the temporary file where stdout will be written\n * @returns Promise that resolves when the command completes successfully or rejects if it fails\n * @throws {Error} If the child process spawn fails or exits with a non-zero code\n */\n async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string) {\n const execName = path.basename(command, path.extname(command))\n const isWindowsScriptFile = process.platform === \"win32\" && path.extname(command).toLowerCase() === \".cmd\"\n if (isWindowsScriptFile) {\n // If the command is a Windows script file (.cmd), we need to wrap it in a .bat file to ensure it runs correctly with cmd.exe\n // This is necessary because .cmd files are not directly executable in the same way as .bat files.\n // We create a temporary .bat file that calls the .cmd file with the provided arguments. The .bat file will be executed by cmd.exe.\n // Note: This is a workaround for Windows command execution quirks when using `shell: true`\n const tempBatFile = await this.tempDirManager.getTempFile({\n prefix: execName,\n suffix: \".bat\",\n })\n const batScript = `@echo off\\r\\n\"${command}\" %*\\r\\n` // <-- CRLF required for .bat\n await fs.writeFile(tempBatFile, batScript, { encoding: \"utf8\" })\n command = \"cmd.exe\"\n args = [\"/c\", `\"${tempBatFile}\"`, ...args]\n }\n\n await new Promise<void>((resolve, reject) => {\n const outStream = createWriteStream(tempOutputFile)\n\n const child = childProcess.spawn(command, args, {\n cwd,\n env: { COREPACK_ENABLE_STRICT: \"0\", ...process.env }, // allow `process.env` overrides\n shell: true, // `true`` is now required: https://github.com/electron-userland/electron-builder/issues/9488\n })\n\n let stderr = \"\"\n child.stdout.pipe(outStream)\n child.stderr.on(\"data\", chunk => {\n stderr += chunk.toString()\n })\n child.on(\"error\", err => {\n reject(new Error(`Node module collector spawn failed: ${err.message}`))\n })\n\n child.on(\"close\", code => {\n outStream.close()\n // https://github.com/npm/npm/issues/17624\n const shouldIgnore = code === 1 && \"npm\" === execName.toLowerCase() && args.includes(\"list\")\n if (shouldIgnore) {\n log.debug(null, \"`npm list` returned non-zero exit code, but it MIGHT be expected (https://github.com/npm/npm/issues/17624). Check stderr for details.\")\n }\n if (stderr.length > 0) {\n log.debug({ stderr }, \"note: there was node module collector output on stderr\")\n }\n const shouldResolve = code === 0 || shouldIgnore\n return shouldResolve ? resolve() : reject(new Error(`Node module collector process exited with code ${code}:\\n${stderr}`))\n })\n })\n }\n}\n"]}
@@ -33,10 +33,6 @@ export interface NpmDependency extends Dependency<NpmDependency, string> {
33
33
  [packageName: string]: string;
34
34
  };
35
35
  }
36
- export interface YarnBerryDependency extends Dependency<YarnBerryDependency, string> {
37
- }
38
- export interface YarnDependency extends Dependency<YarnDependency, YarnDependency> {
39
- }
40
36
  export interface TraversedDependency extends Dependency<TraversedDependency, TraversedDependency> {
41
37
  }
42
38
  export type Dependency<T, V> = Dependencies<T, V> & ParsedDependencyTree;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node-module-collector/types.ts"],"names":[],"mappings":"","sourcesContent":["export type PackageJson = {\n name: string\n version: string\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n optionalDependencies?: Record<string, string>\n workspaces?: string[] | { packages: string[] }\n}\n\nexport interface NodeModuleInfo {\n name: string\n version: string\n dir: string\n dependencies?: Array<NodeModuleInfo>\n}\n\nexport type ParsedDependencyTree = {\n readonly name: string\n readonly version: string\n readonly path: string\n readonly workspaces?: string[] | { packages: string[] } // we only use this at root level\n}\n\n// Note: `PnpmDependency` and `NpmDependency` include the output of `JSON.parse(...)` of `pnpm list` and `npm list` respectively\n// This object has a TON of info - a majority, if not all, of each dependency's package.json\n// We extract only what we need when constructing DependencyTree in `extractProductionDependencyTree`\nexport interface PnpmDependency extends Dependency<PnpmDependency, PnpmDependency> {\n readonly from: string\n readonly resolved: string\n}\n\nexport interface NpmDependency extends Dependency<NpmDependency, string> {\n readonly resolved?: string\n // implicit dependencies, returned only through `npm list`\n readonly _dependencies?: {\n [packageName: string]: string\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface YarnBerryDependency extends Dependency<YarnBerryDependency, string> {}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface YarnDependency extends Dependency<YarnDependency, YarnDependency> {}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface TraversedDependency extends Dependency<TraversedDependency, TraversedDependency> {}\n\nexport type Dependency<T, V> = Dependencies<T, V> & ParsedDependencyTree\n\nexport type Dependencies<T, V> = {\n readonly dependencies?: {\n [packageName: string]: T\n }\n readonly optionalDependencies?: {\n [packageName: string]: V\n }\n}\n\nexport interface DependencyGraph {\n [packageNameAndVersion: string]: {\n readonly dependencies: string[]\n }\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/node-module-collector/types.ts"],"names":[],"mappings":"","sourcesContent":["export type PackageJson = {\n name: string\n version: string\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n optionalDependencies?: Record<string, string>\n workspaces?: string[] | { packages: string[] }\n}\n\nexport interface NodeModuleInfo {\n name: string\n version: string\n dir: string\n dependencies?: Array<NodeModuleInfo>\n}\n\nexport type ParsedDependencyTree = {\n readonly name: string\n readonly version: string\n readonly path: string\n readonly workspaces?: string[] | { packages: string[] } // we only use this at root level\n}\n\n// Note: `PnpmDependency` and `NpmDependency` include the output of `JSON.parse(...)` of `pnpm list` and `npm list` respectively\n// This object has a TON of info - a majority, if not all, of each dependency's package.json\n// We extract only what we need when constructing DependencyTree in `extractProductionDependencyTree`\nexport interface PnpmDependency extends Dependency<PnpmDependency, PnpmDependency> {\n readonly from: string\n readonly resolved: string\n}\n\nexport interface NpmDependency extends Dependency<NpmDependency, string> {\n readonly resolved?: string\n // implicit dependencies, returned only through `npm list`\n readonly _dependencies?: {\n [packageName: string]: string\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface TraversedDependency extends Dependency<TraversedDependency, TraversedDependency> {}\n\nexport type Dependency<T, V> = Dependencies<T, V> & ParsedDependencyTree\n\nexport type Dependencies<T, V> = {\n readonly dependencies?: {\n [packageName: string]: T\n }\n readonly optionalDependencies?: {\n [packageName: string]: V\n }\n}\n\nexport interface DependencyGraph {\n [packageNameAndVersion: string]: {\n readonly dependencies: string[]\n }\n}\n"]}
@@ -1,16 +1,10 @@
1
- import { Lazy } from "lazy-val";
2
- import { NodeModulesCollector } from "./nodeModulesCollector";
1
+ import { NpmNodeModulesCollector } from "./npmNodeModulesCollector";
3
2
  import { PM } from "./packageManager";
4
- import { YarnDependency } from "./types";
5
- export declare class YarnNodeModulesCollector extends NodeModulesCollector<YarnDependency, YarnDependency> {
3
+ import { NpmDependency } from "./types";
4
+ export declare class YarnNodeModulesCollector extends NpmNodeModulesCollector {
6
5
  readonly installOptions: {
7
6
  manager: PM;
8
7
  lockfile: string;
9
8
  };
10
- protected isHoisted: Lazy<boolean>;
11
- protected getArgs(): string[];
12
- protected extractProductionDependencyGraph(tree: YarnDependency, dependencyId: string): Promise<void>;
13
- protected parseDependenciesTree(jsonBlob: string): Promise<YarnDependency>;
14
- private normalizeTree;
15
- protected collectAllDependencies(tree: YarnDependency, packageToExclude: string): Promise<void>;
9
+ protected getDependenciesTree(_pm: PM): Promise<NpmDependency>;
16
10
  }
@@ -1,211 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.YarnNodeModulesCollector = void 0;
4
- const builder_util_1 = require("builder-util");
5
- const lazy_val_1 = require("lazy-val");
6
- const path = require("path");
7
- const nodeModulesCollector_1 = require("./nodeModulesCollector");
4
+ const npmNodeModulesCollector_1 = require("./npmNodeModulesCollector");
8
5
  const packageManager_1 = require("./packageManager");
9
- class YarnNodeModulesCollector extends nodeModulesCollector_1.NodeModulesCollector {
6
+ // Yarn Classic (v1) produces a hoisted node_modules structure similar to npm.
7
+ // Instead of parsing Yarn's custom NDJSON output, we leverage npm's list command
8
+ // which NpmNodeModulesCollector already handles.
9
+ class YarnNodeModulesCollector extends npmNodeModulesCollector_1.NpmNodeModulesCollector {
10
10
  constructor() {
11
11
  super(...arguments);
12
12
  this.installOptions = {
13
13
  manager: packageManager_1.PM.YARN,
14
14
  lockfile: "yarn.lock",
15
15
  };
16
- this.isHoisted = new lazy_val_1.Lazy(async () => {
17
- return Promise.resolve(true); // Yarn Classic always hoists
18
- });
19
16
  }
20
- getArgs() {
21
- return ["list", "--production", "--json", "--depth=Infinity", "--no-progress"];
22
- }
23
- async extractProductionDependencyGraph(tree, dependencyId) {
24
- if (this.productionGraph[dependencyId]) {
25
- return;
26
- }
27
- const productionDeps = Object.entries(tree.dependencies || {}).map(async ([, dependency]) => {
28
- const dep = {
29
- ...dependency,
30
- path: await this.cache.realPath[dependency.path],
31
- };
32
- const childDependencyId = this.packageVersionString(dep);
33
- await this.extractProductionDependencyGraph(dep, childDependencyId);
34
- return childDependencyId;
35
- });
36
- const dependencies = [];
37
- for (const dep of productionDeps) {
38
- dependencies.push(await dep);
39
- }
40
- this.productionGraph[dependencyId] = { dependencies };
41
- }
42
- async parseDependenciesTree(jsonBlob) {
43
- const lines = jsonBlob
44
- .split("\n")
45
- .map(l => l.trim())
46
- .filter(Boolean)
47
- .map(l => {
48
- try {
49
- return JSON.parse(l);
50
- }
51
- catch {
52
- return undefined;
53
- }
54
- })
55
- .filter(Boolean);
56
- const parsedTree = lines
57
- .filter(l => l.type === "tree")
58
- .map(l => l.data.trees)
59
- .shift();
60
- if (!parsedTree) {
61
- throw new Error('Failed to extract Yarn tree: no "type":"tree" line found in console output');
62
- }
63
- const rootPkgJson = (await this.cache.json[path.join(this.rootDir, "package.json")]);
64
- const normalizedTree = await this.normalizeTree({ tree: parsedTree, seen: new Set(), appName: rootPkgJson.name, parentPath: this.rootDir });
65
- const dependencies = {};
66
- for (const [name, dep] of Object.entries(normalizedTree)) {
67
- dependencies[name] = dep;
68
- }
69
- return Promise.resolve({
70
- name: rootPkgJson.name,
71
- version: rootPkgJson.version,
72
- path: this.rootDir,
73
- dependencies,
74
- workspaces: rootPkgJson === null || rootPkgJson === void 0 ? void 0 : rootPkgJson.workspaces,
75
- });
76
- }
77
- async normalizeTree(options) {
78
- const { tree, seen, appName, parentPath = this.rootDir } = options;
79
- const normalized = {};
80
- for (const node of tree) {
81
- const match = node.name.match(/^(.*)@([^@]+)$/);
82
- if (!match) {
83
- builder_util_1.log.debug({ name: node.name }, "invalid node name format");
84
- continue;
85
- }
86
- const [, pkgName, version] = match;
87
- const id = `${pkgName}@${version}`;
88
- const isShadow = node.shadow && node.color === "dim";
89
- if (isShadow) {
90
- builder_util_1.log.debug({ pkgName, version }, "registering shadow node (hoisted elsewhere), will resolve");
91
- }
92
- if (seen.has(id)) {
93
- continue;
94
- }
95
- // Find the correct package path that matches the required version
96
- const pkg = await this.locatePackageWithVersion({ name: pkgName, version, path: parentPath });
97
- const pkgPath = pkg === null || pkg === void 0 ? void 0 : pkg.packageDir;
98
- if (!pkgPath) {
99
- builder_util_1.log.warn({ pkgName, version, parentPath }, "could not find package matching version");
100
- continue;
101
- }
102
- seen.add(id);
103
- const normalizedDep = {
104
- name: pkgName,
105
- version,
106
- path: pkgPath,
107
- dependencies: {},
108
- optionalDependencies: {},
109
- };
110
- // Recursively process children, passing this package's info
111
- if (node.children && node.children.length > 0) {
112
- const childDeps = await this.normalizeTree({
113
- tree: node.children,
114
- seen,
115
- appName,
116
- parentPath: pkgPath,
117
- });
118
- for (const [childDepName, childDep] of Object.entries(childDeps)) {
119
- normalizedDep.dependencies[childDepName] = childDep;
120
- }
121
- }
122
- normalized[pkgName] = normalizedDep;
123
- }
124
- return normalized;
125
- }
126
- async collectAllDependencies(tree, packageToExclude) {
127
- const rootPkgJson = (await this.cache.json[path.join(this.rootDir, "package.json")]);
128
- const failedPackages = new Set();
129
- const collect = async (deps = {}, isOptionalDependency, parentIsOptional = false) => {
130
- var _a, _b, _c, _d;
131
- for (const [, value] of Object.entries(deps)) {
132
- const isRootOptional = !!((_a = rootPkgJson.optionalDependencies) === null || _a === void 0 ? void 0 : _a[value.name]);
133
- const isDirectRootDep = ((_b = rootPkgJson.dependencies) === null || _b === void 0 ? void 0 : _b[value.name]) || ((_c = rootPkgJson.optionalDependencies) === null || _c === void 0 ? void 0 : _c[value.name]) || ((_d = rootPkgJson.devDependencies) === null || _d === void 0 ? void 0 : _d[value.name]);
134
- const treatAsOptional = isOptionalDependency || parentIsOptional || isRootOptional;
135
- const logFields = { name: value.name, version: value.version, path: value.path };
136
- const p = await this.cache.realPath[value.path];
137
- if (!(await this.cache.exists[p])) {
138
- if (treatAsOptional) {
139
- builder_util_1.log.debug(logFields, "failed to find optional dependency, skipping");
140
- failedPackages.add(value.name);
141
- continue;
142
- }
143
- if (!isDirectRootDep) {
144
- builder_util_1.log.debug(logFields, "failed to find transitive dependency, treating as optional");
145
- failedPackages.add(value.name);
146
- continue;
147
- }
148
- const message = "unable to find module directory; is the path correct?";
149
- builder_util_1.log.error(logFields, message);
150
- throw new Error(`Failed to resolve module directory for ${value.name}@${value.version} at path: ${value.path}`);
151
- }
152
- let resolvedVersion = value.version;
153
- const versionMatch = p.match(/[/\\]node_modules[/\\][^@]+@([^/\\]+)[/\\]/);
154
- if (versionMatch) {
155
- resolvedVersion = versionMatch[1];
156
- if (resolvedVersion !== value.version) {
157
- builder_util_1.log.debug({ name: value.name, declared: value.version, resolved: resolvedVersion }, "resolved actual version from path");
158
- }
159
- }
160
- const m = {
161
- ...value,
162
- version: resolvedVersion,
163
- path: p,
164
- };
165
- const moduleKey = this.packageVersionString(m);
166
- if (this.allDependencies.has(moduleKey)) {
167
- continue;
168
- }
169
- this.allDependencies.set(moduleKey, m);
170
- const childIsOptional = treatAsOptional;
171
- await collect(m.dependencies, false, childIsOptional);
172
- await collect(m.optionalDependencies, true, true);
173
- }
174
- };
175
- await collect(tree.dependencies, false, false);
176
- await collect(tree.optionalDependencies, true, true);
177
- // Final cleanup: remove the app package from allDependencies
178
- if (packageToExclude) {
179
- for (const [key, dep] of this.allDependencies.entries()) {
180
- if (dep.name === packageToExclude) {
181
- builder_util_1.log.debug({ key, name: dep.name }, "removing app package from allDependencies");
182
- for (const [, d] of Object.entries(dep.dependencies || {})) {
183
- this.allDependencies.set(this.packageVersionString(d), d);
184
- }
185
- this.allDependencies.delete(key);
186
- }
187
- }
188
- }
189
- if (failedPackages.size > 0) {
190
- const cleanDependencies = (deps = {}) => {
191
- for (const [key, dep] of Object.entries(deps)) {
192
- if (failedPackages.has(dep.name)) {
193
- builder_util_1.log.debug({ name: dep.name }, "removing failed package from tree");
194
- delete deps[key];
195
- }
196
- else {
197
- if (dep.dependencies) {
198
- cleanDependencies(dep.dependencies);
199
- }
200
- if (dep.optionalDependencies) {
201
- cleanDependencies(dep.optionalDependencies);
202
- }
203
- }
204
- }
205
- };
206
- cleanDependencies(tree.dependencies);
207
- cleanDependencies(tree.optionalDependencies);
208
- }
17
+ async getDependenciesTree(_pm) {
18
+ return super.getDependenciesTree(packageManager_1.PM.NPM);
209
19
  }
210
20
  }
211
21
  exports.YarnNodeModulesCollector = YarnNodeModulesCollector;
@@ -1 +1 @@
1
- {"version":3,"file":"yarnNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/yarnNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,+CAAkC;AAClC,uCAA+B;AAC/B,6BAA4B;AAC5B,iEAA6D;AAC7D,qDAAqC;AAyBrC,MAAa,wBAAyB,SAAQ,2CAAoD;IAAlG;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,mBAAE,CAAC,IAAI;YAChB,QAAQ,EAAE,WAAW;SACtB,CAAA;QAES,cAAS,GAAkB,IAAI,eAAI,CAAU,KAAK,IAAI,EAAE;YAChE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA,CAAC,6BAA6B;QAC5D,CAAC,CAAC,CAAA;IAqOJ,CAAC;IAnOW,OAAO;QACf,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAA;IAChF,CAAC;IAES,KAAK,CAAC,gCAAgC,CAAC,IAAoB,EAAE,YAAoB;QACzF,IAAI,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;YACvC,OAAM;QACR,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE;YAC1F,MAAM,GAAG,GAAG;gBACV,GAAG,UAAU;gBACb,IAAI,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAA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port { NodeModulesCollector } from \"./nodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { YarnDependency } from \"./types\"\n\ntype YarnListJsonLine =\n | {\n type: \"tree\"\n data: {\n type: \"list\"\n trees: YarnListTree[]\n }\n }\n | {\n type: \"info\" | \"warning\" | \"error\"\n data: string\n }\n\ninterface YarnListTree {\n name: string // e.g. \"lodash@4.17.21\"\n children: YarnListTree[]\n shadow?: boolean\n color?: string\n hint?: any\n depth?: number\n}\n\nexport class YarnNodeModulesCollector extends NodeModulesCollector<YarnDependency, YarnDependency> {\n public readonly installOptions = {\n manager: PM.YARN,\n lockfile: \"yarn.lock\",\n }\n\n protected isHoisted: Lazy<boolean> = new Lazy<boolean>(async () => {\n return Promise.resolve(true) // Yarn Classic always hoists\n })\n\n protected getArgs(): string[] {\n return [\"list\", \"--production\", \"--json\", \"--depth=Infinity\", \"--no-progress\"]\n }\n\n protected async extractProductionDependencyGraph(tree: YarnDependency, dependencyId: string): Promise<void> {\n if (this.productionGraph[dependencyId]) {\n return\n }\n\n const productionDeps = Object.entries(tree.dependencies || {}).map(async ([, dependency]) => {\n const dep = {\n ...dependency,\n path: await this.cache.realPath[dependency.path],\n }\n\n const childDependencyId = this.packageVersionString(dep)\n await this.extractProductionDependencyGraph(dep, childDependencyId)\n return childDependencyId\n })\n\n const dependencies: string[] = []\n for (const dep of productionDeps) {\n dependencies.push(await dep)\n }\n this.productionGraph[dependencyId] = { dependencies }\n }\n\n protected async parseDependenciesTree(jsonBlob: string): Promise<YarnDependency> {\n const lines = jsonBlob\n .split(\"\\n\")\n .map(l => l.trim())\n .filter(Boolean)\n .map(l => {\n try {\n return JSON.parse(l)\n } catch {\n return undefined\n }\n })\n .filter(Boolean) as YarnListJsonLine[]\n\n const parsedTree: YarnListTree[] | undefined = lines\n .filter(l => l.type === \"tree\")\n .map(l => (l.data as any).trees)\n .shift()\n\n if (!parsedTree) {\n throw new Error('Failed to extract Yarn tree: no \"type\":\"tree\" line found in console output')\n }\n const rootPkgJson = (await this.cache.json[path.join(this.rootDir, \"package.json\")])!\n\n const normalizedTree = await this.normalizeTree({ tree: parsedTree, seen: new Set<string>(), appName: rootPkgJson.name, parentPath: this.rootDir })\n\n const dependencies: Record<string, YarnDependency> = {}\n for (const [name, dep] of Object.entries(normalizedTree)) {\n dependencies[name] = dep\n }\n\n return Promise.resolve({\n name: rootPkgJson.name,\n version: rootPkgJson.version,\n path: this.rootDir,\n dependencies,\n workspaces: rootPkgJson?.workspaces,\n })\n }\n\n private async normalizeTree(options: { tree: YarnListTree[]; seen: Set<string>; appName?: string; parentPath: string }): Promise<Record<string, YarnDependency>> {\n const { tree, seen, appName, parentPath = this.rootDir } = options\n const normalized: Record<string, YarnDependency> = {}\n\n for (const node of tree) {\n const match = node.name.match(/^(.*)@([^@]+)$/)\n if (!match) {\n log.debug({ name: node.name }, \"invalid node name format\")\n continue\n }\n\n const [, pkgName, version] = match\n const id = `${pkgName}@${version}`\n\n const isShadow = node.shadow && node.color === \"dim\"\n if (isShadow) {\n log.debug({ pkgName, version }, \"registering shadow node (hoisted elsewhere), will resolve\")\n }\n\n if (seen.has(id)) {\n continue\n }\n\n // Find the correct package path that matches the required version\n const pkg = await this.locatePackageWithVersion({ name: pkgName, version, path: parentPath })\n const pkgPath = pkg?.packageDir\n\n if (!pkgPath) {\n log.warn({ pkgName, version, parentPath }, \"could not find package matching version\")\n continue\n }\n\n seen.add(id)\n\n const normalizedDep: YarnDependency = {\n name: pkgName,\n version,\n path: pkgPath,\n dependencies: {},\n optionalDependencies: {},\n }\n\n // Recursively process children, passing this package's info\n if (node.children && node.children.length > 0) {\n const childDeps = await this.normalizeTree({\n tree: node.children,\n seen,\n appName,\n parentPath: pkgPath,\n })\n\n for (const [childDepName, childDep] of Object.entries(childDeps)) {\n normalizedDep.dependencies![childDepName] = childDep\n }\n }\n\n normalized[pkgName] = normalizedDep\n }\n\n return normalized\n }\n\n protected async collectAllDependencies(tree: YarnDependency, packageToExclude: string) {\n const rootPkgJson = (await this.cache.json[path.join(this.rootDir, \"package.json\")])!\n const failedPackages = new Set<string>()\n\n const collect = async (\n deps: YarnDependency[\"dependencies\"] | YarnDependency[\"optionalDependencies\"] = {},\n isOptionalDependency: boolean,\n parentIsOptional: boolean = false\n ) => {\n for (const [, value] of Object.entries(deps)) {\n const isRootOptional = !!rootPkgJson.optionalDependencies?.[value.name]\n const isDirectRootDep = rootPkgJson.dependencies?.[value.name] || rootPkgJson.optionalDependencies?.[value.name] || rootPkgJson.devDependencies?.[value.name]\n const treatAsOptional = isOptionalDependency || parentIsOptional || isRootOptional\n\n const logFields = { name: value.name, version: value.version, path: value.path }\n const p = await this.cache.realPath[value.path]\n if (!(await this.cache.exists[p])) {\n if (treatAsOptional) {\n log.debug(logFields, \"failed to find optional dependency, skipping\")\n failedPackages.add(value.name)\n continue\n }\n\n if (!isDirectRootDep) {\n log.debug(logFields, \"failed to find transitive dependency, treating as optional\")\n failedPackages.add(value.name)\n continue\n }\n\n const message = \"unable to find module directory; is the path correct?\"\n log.error(logFields, message)\n throw new Error(`Failed to resolve module directory for ${value.name}@${value.version} at path: ${value.path}`)\n }\n\n let resolvedVersion = value.version\n const versionMatch = p.match(/[/\\\\]node_modules[/\\\\][^@]+@([^/\\\\]+)[/\\\\]/)\n if (versionMatch) {\n resolvedVersion = versionMatch[1]\n if (resolvedVersion !== value.version) {\n log.debug({ name: value.name, declared: value.version, resolved: resolvedVersion }, \"resolved actual version from path\")\n }\n }\n\n const m: YarnDependency = {\n ...value,\n version: resolvedVersion,\n path: p,\n }\n\n const moduleKey = this.packageVersionString(m)\n if (this.allDependencies.has(moduleKey)) {\n continue\n }\n this.allDependencies.set(moduleKey, m)\n\n const childIsOptional = treatAsOptional\n await collect(m.dependencies, false, childIsOptional)\n await collect(m.optionalDependencies, true, true)\n }\n }\n\n await collect(tree.dependencies, false, false)\n await collect(tree.optionalDependencies, true, true)\n\n // Final cleanup: remove the app package from allDependencies\n if (packageToExclude) {\n for (const [key, dep] of this.allDependencies.entries()) {\n if (dep.name === packageToExclude) {\n log.debug({ key, name: dep.name }, \"removing app package from allDependencies\")\n for (const [, d] of Object.entries(dep.dependencies || {})) {\n this.allDependencies.set(this.packageVersionString(d), d)\n }\n this.allDependencies.delete(key)\n }\n }\n }\n\n if (failedPackages.size > 0) {\n const cleanDependencies = (deps: Record<string, YarnDependency> = {}) => {\n for (const [key, dep] of Object.entries(deps)) {\n if (failedPackages.has(dep.name)) {\n log.debug({ name: dep.name }, \"removing failed package from tree\")\n delete deps[key]\n } else {\n if (dep.dependencies) {\n cleanDependencies(dep.dependencies)\n }\n if (dep.optionalDependencies) {\n cleanDependencies(dep.optionalDependencies)\n }\n }\n }\n }\n\n cleanDependencies(tree.dependencies)\n cleanDependencies(tree.optionalDependencies)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"yarnNodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/yarnNodeModulesCollector.ts"],"names":[],"mappings":";;;AAAA,uEAAmE;AACnE,qDAAqC;AAGrC,8EAA8E;AAC9E,iFAAiF;AACjF,iDAAiD;AACjD,MAAa,wBAAyB,SAAQ,iDAAuB;IAArE;;QACkB,mBAAc,GAAG;YAC/B,OAAO,EAAE,mBAAE,CAAC,IAAI;YAChB,QAAQ,EAAE,WAAW;SACtB,CAAA;IAKH,CAAC;IAHW,KAAK,CAAC,mBAAmB,CAAC,GAAO;QACzC,OAAO,KAAK,CAAC,mBAAmB,CAAC,mBAAE,CAAC,GAAG,CAAC,CAAA;IAC1C,CAAC;CACF;AATD,4DASC","sourcesContent":["import { NpmNodeModulesCollector } from \"./npmNodeModulesCollector\"\nimport { PM } from \"./packageManager\"\nimport { NpmDependency } from \"./types\"\n\n// Yarn Classic (v1) produces a hoisted node_modules structure similar to npm.\n// Instead of parsing Yarn's custom NDJSON output, we leverage npm's list command\n// which NpmNodeModulesCollector already handles.\nexport class YarnNodeModulesCollector extends NpmNodeModulesCollector {\n public readonly installOptions = {\n manager: PM.YARN,\n lockfile: \"yarn.lock\",\n }\n\n protected async getDependenciesTree(_pm: PM): Promise<NpmDependency> {\n return super.getDependenciesTree(PM.NPM)\n }\n}\n"]}