@ms-cloudpack/package-utilities 7.5.3 → 7.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"getNonSemverTransform.d.ts","sourceRoot":"","sources":["../src/getNonSemverTransform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAe,MAAM,4BAA4B,CAAC;AAM1F;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,0BAA0B,CAoFlE"}
1
+ {"version":3,"file":"getNonSemverTransform.d.ts","sourceRoot":"","sources":["../src/getNonSemverTransform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAe,MAAM,4BAA4B,CAAC;AAM1F;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,0BAA0B,CAgFlE"}
@@ -55,10 +55,6 @@ export function getNonSemverTransform() {
55
55
  // package under its real name.
56
56
  result.name = importedName;
57
57
  result.version = versionRequirement;
58
- result.cloudpackRemapped = {
59
- originalName: definition.name || '',
60
- originalVersion: definition.version || '',
61
- };
62
58
  // We have changed the definition, so link the entry in nonSemverDeps to the new name/version.
63
59
  if (nonSemverDeps[`${definition.name}@${definition.version}`]) {
64
60
  nonSemverDeps[`${importedName}@${versionRequirement}`] =
@@ -1 +1 @@
1
- {"version":3,"file":"getNonSemverTransform.js","sourceRoot":"","sources":["../src/getNonSemverTransform.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,MAAM,QAAQ,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAU,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC;;;OAGG;IACH,MAAM,aAAa,GAGf,EAAE,CAAC;IAEP,OAAO,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE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9E,uBAAuB;YACvB,kHAAkH;YAClH,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,GAAG,eAAe,CAAC;YAE7D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC1D,SAAS;gBACX,CAAC;gBAED,qFAAqF;gBACrF,sFAAsF;gBACtF,qFAAqF;gBACrF,+BAA+B;gBAC/B,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC;gBAC3B,MAAM,CAAC,OAAO,GAAG,kBAAkB,CAAC;gBACpC,MAAM,CAAC,iBAAiB,GAAG;oBACzB,YAAY,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE;oBACnC,eAAe,EAAE,UAAU,CAAC,OAAO,IAAI,EAAE;iBAC1C,CAAC;gBAEF,8FAA8F;gBAC9F,IAAI,aAAa,CAAC,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;oBAC9D,aAAa,CAAC,GAAG,YAAY,IAAI,kBAAkB,EAAE,CAAC;wBACpD,aAAa,CAAC,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC9D,CAAC;gBAED,MAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionTransform, PackageJson } from '@ms-cloudpack/common-types';\nimport semver from 'semver';\nimport { generateVersionFromNonSemver } from './generateVersionFromNonSemver.js';\n\nconst depTypes = ['dependencies', 'peerDependencies'] as const;\n\n/**\n * Get a transform which handles non-semver dependencies:\n * - In a parent package, if a dependency is specified with a non-semver version, change the dep\n * to a special `0.0.0-<original-version>` prerelease version.\n * - In a child package, if the package was pulled in as a non-semver dependency by a parent\n * (per the `importerContext`), change its version to the special prerelease version as above.\n */\nexport function getNonSemverTransform(): PackageDefinitionTransform {\n /**\n * Cached info about parent packages with non-semver dependencies:\n * Map from parent name/version => dep type => non-semver dependency names\n */\n const nonSemverDeps: Record<\n `${string}@${string}`,\n Partial<Record<'dependencies' | 'peerDependencies', string[]>>\n > = {};\n\n return ({ definition, packagePath, importerContext }) => {\n const result: Partial<PackageJson> = {};\n\n // Check for non-semver dependencies\n for (const depType of depTypes) {\n const deps = definition[depType] || {};\n\n for (const [depName, depVersion] of Object.entries(deps)) {\n if (!depVersion || semver.validRange(depVersion)) {\n continue;\n }\n\n console.debug(\n `Non-semver dependency found: ${depName}@${depVersion} ` +\n `(in ${definition.name}@${definition.version} at ${packagePath}). ` +\n \"Cloudpack will attempt to handle this, but it's recommended to use semantic versions only if possible.\",\n );\n\n // Update the version in the returned dependencies:\n // \"bar\": \"npm:@custom/bar@^1\" => \"0.0.0-npm--custom-bar--1\"\n const resultDeps = (result[depType] ??= { ...deps });\n resultDeps[depName] = generateVersionFromNonSemver(depVersion);\n\n // Save that this was a non-semver dep\n const record = (nonSemverDeps[`${definition.name}@${definition.version}`] ??= {});\n (record[depType] ??= []).push(depName);\n }\n }\n\n // If this package's parent pulled it in with a non-semver dependency, make some more updates\n // (see below)\n const nonSemverParentInfo =\n importerContext && nonSemverDeps[`${importerContext.parentName}@${importerContext.parentVersion}`];\n\n // TODO: maybe this could also be used for resolutions if we have problems there:\n // adding a check for !semver.satisfies(requiredAs, definition.version) and forcing the package version?\n\n if (nonSemverParentInfo) {\n // Example: the parent depended on this package as \"bar\": \"npm:@custom/bar@^1\"\n // importedName = bar\n // versionRequirement = 0.0.0-npm--custom-bar--1 (was modified when this transform ran on the parent definition)\n const { importedName, versionRequirement } = importerContext;\n\n for (const depType of depTypes) {\n if (!nonSemverParentInfo[depType]?.includes(importedName)) {\n continue;\n }\n\n // To ensure other code handles this package properly, change its name and version to\n // the ones used by the parent (after transforms). This ensures it works properly with\n // the resolve map and isn't accidentally used by other packages which depend on this\n // package under its real name.\n result.name = importedName;\n result.version = versionRequirement;\n result.cloudpackRemapped = {\n originalName: definition.name || '',\n originalVersion: definition.version || '',\n };\n\n // We have changed the definition, so link the entry in nonSemverDeps to the new name/version.\n if (nonSemverDeps[`${definition.name}@${definition.version}`]) {\n nonSemverDeps[`${importedName}@${versionRequirement}`] =\n nonSemverDeps[`${definition.name}@${definition.version}`];\n }\n\n break;\n }\n }\n\n if (Object.keys(result).length) {\n return { ...definition, ...result };\n }\n return undefined;\n };\n}\n"]}
1
+ {"version":3,"file":"getNonSemverTransform.js","sourceRoot":"","sources":["../src/getNonSemverTransform.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,MAAM,QAAQ,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAU,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC;;;OAGG;IACH,MAAM,aAAa,GAGf,EAAE,CAAC;IAEP,OAAO,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,EAAE,EAAE;QACtD,MAAM,MAAM,GAAyB,EAAE,CAAC;QAExC,oCAAoC;QACpC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEvC,KAAK,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzD,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;oBACjD,SAAS;gBACX,CAAC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GAAG,kBAAkB,CAAC;gBAEpC,8FAA8F;gBAC9F,IAAI,aAAa,CAAC,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;oBAC9D,aAAa,CAAC,GAAG,YAAY,IAAI,kBAAkB,EAAE,CAAC;wBACpD,aAAa,CAAC,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC9D,CAAC;gBAED,MAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionTransform, PackageJson } from '@ms-cloudpack/common-types';\nimport semver from 'semver';\nimport { generateVersionFromNonSemver } from './generateVersionFromNonSemver.js';\n\nconst depTypes = ['dependencies', 'peerDependencies'] as const;\n\n/**\n * Get a transform which handles non-semver dependencies:\n * - In a parent package, if a dependency is specified with a non-semver version, change the dep\n * to a special `0.0.0-<original-version>` prerelease version.\n * - In a child package, if the package was pulled in as a non-semver dependency by a parent\n * (per the `importerContext`), change its version to the special prerelease version as above.\n */\nexport function getNonSemverTransform(): PackageDefinitionTransform {\n /**\n * Cached info about parent packages with non-semver dependencies:\n * Map from parent name/version => dep type => non-semver dependency names\n */\n const nonSemverDeps: Record<\n `${string}@${string}`,\n Partial<Record<'dependencies' | 'peerDependencies', string[]>>\n > = {};\n\n return ({ definition, packagePath, importerContext }) => {\n const result: Partial<PackageJson> = {};\n\n // Check for non-semver dependencies\n for (const depType of depTypes) {\n const deps = definition[depType] || {};\n\n for (const [depName, depVersion] of Object.entries(deps)) {\n if (!depVersion || semver.validRange(depVersion)) {\n continue;\n }\n\n console.debug(\n `Non-semver dependency found: ${depName}@${depVersion} ` +\n `(in ${definition.name}@${definition.version} at ${packagePath}). ` +\n \"Cloudpack will attempt to handle this, but it's recommended to use semantic versions only if possible.\",\n );\n\n // Update the version in the returned dependencies:\n // \"bar\": \"npm:@custom/bar@^1\" => \"0.0.0-npm--custom-bar--1\"\n const resultDeps = (result[depType] ??= { ...deps });\n resultDeps[depName] = generateVersionFromNonSemver(depVersion);\n\n // Save that this was a non-semver dep\n const record = (nonSemverDeps[`${definition.name}@${definition.version}`] ??= {});\n (record[depType] ??= []).push(depName);\n }\n }\n\n // If this package's parent pulled it in with a non-semver dependency, make some more updates\n // (see below)\n const nonSemverParentInfo =\n importerContext && nonSemverDeps[`${importerContext.parentName}@${importerContext.parentVersion}`];\n\n // TODO: maybe this could also be used for resolutions if we have problems there:\n // adding a check for !semver.satisfies(requiredAs, definition.version) and forcing the package version?\n\n if (nonSemverParentInfo) {\n // Example: the parent depended on this package as \"bar\": \"npm:@custom/bar@^1\"\n // importedName = bar\n // versionRequirement = 0.0.0-npm--custom-bar--1 (was modified when this transform ran on the parent definition)\n const { importedName, versionRequirement } = importerContext;\n\n for (const depType of depTypes) {\n if (!nonSemverParentInfo[depType]?.includes(importedName)) {\n continue;\n }\n\n // To ensure other code handles this package properly, change its name and version to\n // the ones used by the parent (after transforms). This ensures it works properly with\n // the resolve map and isn't accidentally used by other packages which depend on this\n // package under its real name.\n result.name = importedName;\n result.version = versionRequirement;\n\n // We have changed the definition, so link the entry in nonSemverDeps to the new name/version.\n if (nonSemverDeps[`${definition.name}@${definition.version}`]) {\n nonSemverDeps[`${importedName}@${versionRequirement}`] =\n nonSemverDeps[`${definition.name}@${definition.version}`];\n }\n\n break;\n }\n }\n\n if (Object.keys(result).length) {\n return { ...definition, ...result };\n }\n return undefined;\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-utilities",
3
- "version": "7.5.3",
3
+ "version": "7.6.0",
4
4
  "description": "Utilities for resolving/parsing packages and their imports.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,11 +14,11 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/common-types": "^0.7.1",
17
+ "@ms-cloudpack/common-types": "^0.8.0",
18
18
  "@ms-cloudpack/json-utilities": "^0.1.4",
19
- "@ms-cloudpack/package-overrides": "^0.9.1",
19
+ "@ms-cloudpack/package-overrides": "^0.9.3",
20
20
  "@ms-cloudpack/path-string-parsing": "^1.2.3",
21
- "@ms-cloudpack/path-utilities": "^2.7.16",
21
+ "@ms-cloudpack/path-utilities": "^2.7.18",
22
22
  "@ms-cloudpack/task-reporter": "^0.14.1",
23
23
  "acorn": "^8.11.2",
24
24
  "acorn-walk": "^8.2.1",