@k8slens/package-build 3.0.0 → 3.1.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.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { extensionDependenciesCheck } = require("../dist");
4
+
5
+ process.exitCode = extensionDependenciesCheck();
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { globImportPlugin } from "./src/glob-import-plugin";
2
2
  export { packageBuild } from "./src/package-build";
3
3
  export { stylesheetPlugin, type StylesheetPluginParams } from "./src/stylesheet-plugin";
4
+ export { extensionDependenciesCheck } from "./src/extension-dependencies-check";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC"}
package/dist/index.js CHANGED
@@ -1360,11 +1360,11 @@ var require_lodash = __commonJS({
1360
1360
  return isFunction(object[key]);
1361
1361
  });
1362
1362
  }
1363
- function baseGet(object, path3) {
1364
- path3 = castPath(path3, object);
1365
- var index = 0, length = path3.length;
1363
+ function baseGet(object, path4) {
1364
+ path4 = castPath(path4, object);
1365
+ var index = 0, length = path4.length;
1366
1366
  while (object != null && index < length) {
1367
- object = object[toKey(path3[index++])];
1367
+ object = object[toKey(path4[index++])];
1368
1368
  }
1369
1369
  return index && index == length ? object : undefined2;
1370
1370
  }
@@ -1428,10 +1428,10 @@ var require_lodash = __commonJS({
1428
1428
  });
1429
1429
  return accumulator;
1430
1430
  }
1431
- function baseInvoke(object, path3, args) {
1432
- path3 = castPath(path3, object);
1433
- object = parent(object, path3);
1434
- var func = object == null ? object : object[toKey(last(path3))];
1431
+ function baseInvoke(object, path4, args) {
1432
+ path4 = castPath(path4, object);
1433
+ object = parent(object, path4);
1434
+ var func = object == null ? object : object[toKey(last(path4))];
1435
1435
  return func == null ? undefined2 : apply(func, object, args);
1436
1436
  }
1437
1437
  function baseIsArguments(value) {
@@ -1587,13 +1587,13 @@ var require_lodash = __commonJS({
1587
1587
  return object === source || baseIsMatch(object, source, matchData);
1588
1588
  };
1589
1589
  }
1590
- function baseMatchesProperty(path3, srcValue) {
1591
- if (isKey(path3) && isStrictComparable(srcValue)) {
1592
- return matchesStrictComparable(toKey(path3), srcValue);
1590
+ function baseMatchesProperty(path4, srcValue) {
1591
+ if (isKey(path4) && isStrictComparable(srcValue)) {
1592
+ return matchesStrictComparable(toKey(path4), srcValue);
1593
1593
  }
1594
1594
  return function(object) {
1595
- var objValue = get(object, path3);
1596
- return objValue === undefined2 && objValue === srcValue ? hasIn(object, path3) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
1595
+ var objValue = get(object, path4);
1596
+ return objValue === undefined2 && objValue === srcValue ? hasIn(object, path4) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
1597
1597
  };
1598
1598
  }
1599
1599
  function baseMerge(object, source, srcIndex, customizer, stack) {
@@ -1690,23 +1690,23 @@ var require_lodash = __commonJS({
1690
1690
  });
1691
1691
  }
1692
1692
  function basePick(object, paths) {
1693
- return basePickBy(object, paths, function(value, path3) {
1694
- return hasIn(object, path3);
1693
+ return basePickBy(object, paths, function(value, path4) {
1694
+ return hasIn(object, path4);
1695
1695
  });
1696
1696
  }
1697
1697
  function basePickBy(object, paths, predicate) {
1698
1698
  var index = -1, length = paths.length, result2 = {};
1699
1699
  while (++index < length) {
1700
- var path3 = paths[index], value = baseGet(object, path3);
1701
- if (predicate(value, path3)) {
1702
- baseSet(result2, castPath(path3, object), value);
1700
+ var path4 = paths[index], value = baseGet(object, path4);
1701
+ if (predicate(value, path4)) {
1702
+ baseSet(result2, castPath(path4, object), value);
1703
1703
  }
1704
1704
  }
1705
1705
  return result2;
1706
1706
  }
1707
- function basePropertyDeep(path3) {
1707
+ function basePropertyDeep(path4) {
1708
1708
  return function(object) {
1709
- return baseGet(object, path3);
1709
+ return baseGet(object, path4);
1710
1710
  };
1711
1711
  }
1712
1712
  function basePullAll(array, values2, iteratee2, comparator) {
@@ -1780,14 +1780,14 @@ var require_lodash = __commonJS({
1780
1780
  var array = values(collection);
1781
1781
  return shuffleSelf(array, baseClamp(n, 0, array.length));
1782
1782
  }
1783
- function baseSet(object, path3, value, customizer) {
1783
+ function baseSet(object, path4, value, customizer) {
1784
1784
  if (!isObject(object)) {
1785
1785
  return object;
1786
1786
  }
1787
- path3 = castPath(path3, object);
1788
- var index = -1, length = path3.length, lastIndex = length - 1, nested = object;
1787
+ path4 = castPath(path4, object);
1788
+ var index = -1, length = path4.length, lastIndex = length - 1, nested = object;
1789
1789
  while (nested != null && ++index < length) {
1790
- var key = toKey(path3[index]), newValue = value;
1790
+ var key = toKey(path4[index]), newValue = value;
1791
1791
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
1792
1792
  return object;
1793
1793
  }
@@ -1795,7 +1795,7 @@ var require_lodash = __commonJS({
1795
1795
  var objValue = nested[key];
1796
1796
  newValue = customizer ? customizer(objValue, key, nested) : undefined2;
1797
1797
  if (newValue === undefined2) {
1798
- newValue = isObject(objValue) ? objValue : isIndex(path3[index + 1]) ? [] : {};
1798
+ newValue = isObject(objValue) ? objValue : isIndex(path4[index + 1]) ? [] : {};
1799
1799
  }
1800
1800
  }
1801
1801
  assignValue(nested, key, newValue);
@@ -1961,33 +1961,33 @@ var require_lodash = __commonJS({
1961
1961
  }
1962
1962
  return result2;
1963
1963
  }
1964
- function baseUnset(object, path3) {
1965
- path3 = castPath(path3, object);
1966
- var index = -1, length = path3.length;
1964
+ function baseUnset(object, path4) {
1965
+ path4 = castPath(path4, object);
1966
+ var index = -1, length = path4.length;
1967
1967
  if (!length) {
1968
1968
  return true;
1969
1969
  }
1970
1970
  var isRootPrimitive = object == null || typeof object !== "object" && typeof object !== "function";
1971
1971
  while (++index < length) {
1972
- var key = path3[index];
1972
+ var key = path4[index];
1973
1973
  if (typeof key !== "string") {
1974
1974
  continue;
1975
1975
  }
1976
1976
  if (key === "__proto__" && !hasOwnProperty.call(object, "__proto__")) {
1977
1977
  return false;
1978
1978
  }
1979
- if (key === "constructor" && index + 1 < length && typeof path3[index + 1] === "string" && path3[index + 1] === "prototype") {
1979
+ if (key === "constructor" && index + 1 < length && typeof path4[index + 1] === "string" && path4[index + 1] === "prototype") {
1980
1980
  if (isRootPrimitive && index === 0) {
1981
1981
  continue;
1982
1982
  }
1983
1983
  return false;
1984
1984
  }
1985
1985
  }
1986
- var obj = parent(object, path3);
1987
- return obj == null || delete obj[toKey(last(path3))];
1986
+ var obj = parent(object, path4);
1987
+ return obj == null || delete obj[toKey(last(path4))];
1988
1988
  }
1989
- function baseUpdate(object, path3, updater, customizer) {
1990
- return baseSet(object, path3, updater(baseGet(object, path3)), customizer);
1989
+ function baseUpdate(object, path4, updater, customizer) {
1990
+ return baseSet(object, path4, updater(baseGet(object, path4)), customizer);
1991
1991
  }
1992
1992
  function baseWhile(array, predicate, isDrop, fromRight) {
1993
1993
  var length = array.length, index = fromRight ? length : -1;
@@ -2870,11 +2870,11 @@ var require_lodash = __commonJS({
2870
2870
  var match = source.match(reWrapDetails);
2871
2871
  return match ? match[1].split(reSplitDetails) : [];
2872
2872
  }
2873
- function hasPath(object, path3, hasFunc) {
2874
- path3 = castPath(path3, object);
2875
- var index = -1, length = path3.length, result2 = false;
2873
+ function hasPath(object, path4, hasFunc) {
2874
+ path4 = castPath(path4, object);
2875
+ var index = -1, length = path4.length, result2 = false;
2876
2876
  while (++index < length) {
2877
- var key = toKey(path3[index]);
2877
+ var key = toKey(path4[index]);
2878
2878
  if (!(result2 = object != null && hasFunc(object, key))) {
2879
2879
  break;
2880
2880
  }
@@ -3076,8 +3076,8 @@ var require_lodash = __commonJS({
3076
3076
  return apply(func, this, otherArgs);
3077
3077
  };
3078
3078
  }
3079
- function parent(object, path3) {
3080
- return path3.length < 2 ? object : baseGet(object, baseSlice(path3, 0, -1));
3079
+ function parent(object, path4) {
3080
+ return path4.length < 2 ? object : baseGet(object, baseSlice(path4, 0, -1));
3081
3081
  }
3082
3082
  function reorder(array, indexes) {
3083
3083
  var arrLength = array.length, length = nativeMin(indexes.length, arrLength), oldArray = copyArray(array);
@@ -3712,10 +3712,10 @@ var require_lodash = __commonJS({
3712
3712
  }
3713
3713
  return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
3714
3714
  }
3715
- var invokeMap = baseRest(function(collection, path3, args) {
3716
- var index = -1, isFunc = typeof path3 == "function", result2 = isArrayLike(collection) ? Array2(collection.length) : [];
3715
+ var invokeMap = baseRest(function(collection, path4, args) {
3716
+ var index = -1, isFunc = typeof path4 == "function", result2 = isArrayLike(collection) ? Array2(collection.length) : [];
3717
3717
  baseEach(collection, function(value) {
3718
- result2[++index] = isFunc ? apply(path3, value, args) : baseInvoke(value, path3, args);
3718
+ result2[++index] = isFunc ? apply(path4, value, args) : baseInvoke(value, path4, args);
3719
3719
  });
3720
3720
  return result2;
3721
3721
  });
@@ -4367,15 +4367,15 @@ var require_lodash = __commonJS({
4367
4367
  function functionsIn(object) {
4368
4368
  return object == null ? [] : baseFunctions(object, keysIn(object));
4369
4369
  }
4370
- function get(object, path3, defaultValue) {
4371
- var result2 = object == null ? undefined2 : baseGet(object, path3);
4370
+ function get(object, path4, defaultValue) {
4371
+ var result2 = object == null ? undefined2 : baseGet(object, path4);
4372
4372
  return result2 === undefined2 ? defaultValue : result2;
4373
4373
  }
4374
- function has(object, path3) {
4375
- return object != null && hasPath(object, path3, baseHas);
4374
+ function has(object, path4) {
4375
+ return object != null && hasPath(object, path4, baseHas);
4376
4376
  }
4377
- function hasIn(object, path3) {
4378
- return object != null && hasPath(object, path3, baseHasIn);
4377
+ function hasIn(object, path4) {
4378
+ return object != null && hasPath(object, path4, baseHasIn);
4379
4379
  }
4380
4380
  var invert = createInverter(function(result2, value, key) {
4381
4381
  if (value != null && typeof value.toString != "function") {
@@ -4428,10 +4428,10 @@ var require_lodash = __commonJS({
4428
4428
  return result2;
4429
4429
  }
4430
4430
  var isDeep = false;
4431
- paths = arrayMap(paths, function(path3) {
4432
- path3 = castPath(path3, object);
4433
- isDeep || (isDeep = path3.length > 1);
4434
- return path3;
4431
+ paths = arrayMap(paths, function(path4) {
4432
+ path4 = castPath(path4, object);
4433
+ isDeep || (isDeep = path4.length > 1);
4434
+ return path4;
4435
4435
  });
4436
4436
  copyObject(object, getAllKeysIn(object), result2);
4437
4437
  if (isDeep) {
@@ -4457,19 +4457,19 @@ var require_lodash = __commonJS({
4457
4457
  return [prop];
4458
4458
  });
4459
4459
  predicate = getIteratee(predicate);
4460
- return basePickBy(object, props, function(value, path3) {
4461
- return predicate(value, path3[0]);
4460
+ return basePickBy(object, props, function(value, path4) {
4461
+ return predicate(value, path4[0]);
4462
4462
  });
4463
4463
  }
4464
- function result(object, path3, defaultValue) {
4465
- path3 = castPath(path3, object);
4466
- var index = -1, length = path3.length;
4464
+ function result(object, path4, defaultValue) {
4465
+ path4 = castPath(path4, object);
4466
+ var index = -1, length = path4.length;
4467
4467
  if (!length) {
4468
4468
  length = 1;
4469
4469
  object = undefined2;
4470
4470
  }
4471
4471
  while (++index < length) {
4472
- var value = object == null ? undefined2 : object[toKey(path3[index])];
4472
+ var value = object == null ? undefined2 : object[toKey(path4[index])];
4473
4473
  if (value === undefined2) {
4474
4474
  index = length;
4475
4475
  value = defaultValue;
@@ -4478,12 +4478,12 @@ var require_lodash = __commonJS({
4478
4478
  }
4479
4479
  return object;
4480
4480
  }
4481
- function set(object, path3, value) {
4482
- return object == null ? object : baseSet(object, path3, value);
4481
+ function set(object, path4, value) {
4482
+ return object == null ? object : baseSet(object, path4, value);
4483
4483
  }
4484
- function setWith(object, path3, value, customizer) {
4484
+ function setWith(object, path4, value, customizer) {
4485
4485
  customizer = typeof customizer == "function" ? customizer : undefined2;
4486
- return object == null ? object : baseSet(object, path3, value, customizer);
4486
+ return object == null ? object : baseSet(object, path4, value, customizer);
4487
4487
  }
4488
4488
  var toPairs = createToPairs(keys);
4489
4489
  var toPairsIn = createToPairs(keysIn);
@@ -4505,15 +4505,15 @@ var require_lodash = __commonJS({
4505
4505
  });
4506
4506
  return accumulator;
4507
4507
  }
4508
- function unset(object, path3) {
4509
- return object == null ? true : baseUnset(object, path3);
4508
+ function unset(object, path4) {
4509
+ return object == null ? true : baseUnset(object, path4);
4510
4510
  }
4511
- function update(object, path3, updater) {
4512
- return object == null ? object : baseUpdate(object, path3, castFunction(updater));
4511
+ function update(object, path4, updater) {
4512
+ return object == null ? object : baseUpdate(object, path4, castFunction(updater));
4513
4513
  }
4514
- function updateWith(object, path3, updater, customizer) {
4514
+ function updateWith(object, path4, updater, customizer) {
4515
4515
  customizer = typeof customizer == "function" ? customizer : undefined2;
4516
- return object == null ? object : baseUpdate(object, path3, castFunction(updater), customizer);
4516
+ return object == null ? object : baseUpdate(object, path4, castFunction(updater), customizer);
4517
4517
  }
4518
4518
  function values(object) {
4519
4519
  return object == null ? [] : baseValues(object, keys(object));
@@ -4894,17 +4894,17 @@ var require_lodash = __commonJS({
4894
4894
  function matches(source) {
4895
4895
  return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
4896
4896
  }
4897
- function matchesProperty(path3, srcValue) {
4898
- return baseMatchesProperty(path3, baseClone(srcValue, CLONE_DEEP_FLAG));
4897
+ function matchesProperty(path4, srcValue) {
4898
+ return baseMatchesProperty(path4, baseClone(srcValue, CLONE_DEEP_FLAG));
4899
4899
  }
4900
- var method = baseRest(function(path3, args) {
4900
+ var method = baseRest(function(path4, args) {
4901
4901
  return function(object) {
4902
- return baseInvoke(object, path3, args);
4902
+ return baseInvoke(object, path4, args);
4903
4903
  };
4904
4904
  });
4905
4905
  var methodOf = baseRest(function(object, args) {
4906
- return function(path3) {
4907
- return baseInvoke(object, path3, args);
4906
+ return function(path4) {
4907
+ return baseInvoke(object, path4, args);
4908
4908
  };
4909
4909
  });
4910
4910
  function mixin(object, source, options) {
@@ -4951,12 +4951,12 @@ var require_lodash = __commonJS({
4951
4951
  var over = createOver(arrayMap);
4952
4952
  var overEvery = createOver(arrayEvery);
4953
4953
  var overSome = createOver(arraySome);
4954
- function property(path3) {
4955
- return isKey(path3) ? baseProperty(toKey(path3)) : basePropertyDeep(path3);
4954
+ function property(path4) {
4955
+ return isKey(path4) ? baseProperty(toKey(path4)) : basePropertyDeep(path4);
4956
4956
  }
4957
4957
  function propertyOf(object) {
4958
- return function(path3) {
4959
- return object == null ? undefined2 : baseGet(object, path3);
4958
+ return function(path4) {
4959
+ return object == null ? undefined2 : baseGet(object, path4);
4960
4960
  };
4961
4961
  }
4962
4962
  var range = createRange();
@@ -5409,12 +5409,12 @@ var require_lodash = __commonJS({
5409
5409
  LazyWrapper.prototype.findLast = function(predicate) {
5410
5410
  return this.reverse().find(predicate);
5411
5411
  };
5412
- LazyWrapper.prototype.invokeMap = baseRest(function(path3, args) {
5413
- if (typeof path3 == "function") {
5412
+ LazyWrapper.prototype.invokeMap = baseRest(function(path4, args) {
5413
+ if (typeof path4 == "function") {
5414
5414
  return new LazyWrapper(this);
5415
5415
  }
5416
5416
  return this.map(function(value) {
5417
- return baseInvoke(value, path3, args);
5417
+ return baseInvoke(value, path4, args);
5418
5418
  });
5419
5419
  });
5420
5420
  LazyWrapper.prototype.reject = function(predicate) {
@@ -5533,6 +5533,7 @@ var require_lodash = __commonJS({
5533
5533
  // index.ts
5534
5534
  var index_exports = {};
5535
5535
  __export(index_exports, {
5536
+ extensionDependenciesCheck: () => extensionDependenciesCheck,
5536
5537
  globImportPlugin: () => globImportPlugin,
5537
5538
  packageBuild: () => packageBuild,
5538
5539
  stylesheetPlugin: () => stylesheetPlugin
@@ -5548,24 +5549,24 @@ var globImportPlugin = () => ({
5548
5549
  setup: (build2) => {
5549
5550
  const uniquenessCache = /* @__PURE__ */ new Map();
5550
5551
  build2.onResolve({ filter: /\*/ }, async (args) => {
5551
- const { resolveDir, path: path3 } = args;
5552
+ const { resolveDir, path: path4 } = args;
5552
5553
  if (resolveDir === "") {
5553
5554
  return;
5554
5555
  }
5555
- const cacheKey = (0, import_node_path.resolve)(resolveDir, path3);
5556
+ const cacheKey = (0, import_node_path.resolve)(resolveDir, path4);
5556
5557
  const uniqueId = getOrInsertWith(uniquenessCache, cacheKey, getRandomUniqueId);
5557
5558
  return {
5558
- path: `${path3}/proof-of-uniqueness/${uniqueId}`,
5559
+ path: `${path4}/proof-of-uniqueness/${uniqueId}`,
5559
5560
  namespace: "import-glob",
5560
5561
  pluginData: { resolveDir }
5561
5562
  };
5562
5563
  });
5563
5564
  build2.onLoad({ filter: /.*/, namespace: "import-glob" }, async (args) => {
5564
5565
  const {
5565
- path: path3,
5566
+ path: path4,
5566
5567
  pluginData: { resolveDir }
5567
5568
  } = args;
5568
- const [globImportString] = path3.split("/proof-of-uniqueness/");
5569
+ const [globImportString] = path4.split("/proof-of-uniqueness/");
5569
5570
  const files = (await (0, import_fast_glob.default)(globImportString, { cwd: resolveDir })).sort();
5570
5571
  const contents = [
5571
5572
  files.map((module2, index) => `import * as module${index} from './${module2}'`).join(";"),
@@ -5784,9 +5785,9 @@ var { builtinModules, disallowedBuiltinModules } = (() => {
5784
5785
  const builtinModules2 = new Set(allowed.flatMap(alsoAddNodeRefs));
5785
5786
  return { disallowedBuiltinModules: disallowedBuiltinModules2, builtinModules: builtinModules2 };
5786
5787
  })();
5787
- var getPackageName = (path3) => {
5788
- const [firstPart, secondPart] = path3.split("/");
5789
- if (path3.startsWith("@")) {
5788
+ var getPackageName = (path4) => {
5789
+ const [firstPart, secondPart] = path4.split("/");
5790
+ if (path4.startsWith("@")) {
5790
5791
  return [firstPart, secondPart].join("/");
5791
5792
  }
5792
5793
  return firstPart;
@@ -5936,6 +5937,98 @@ var packageBuild = async () => {
5936
5937
  process.exit(1);
5937
5938
  }
5938
5939
  };
5940
+
5941
+ // src/extension-dependencies-check.ts
5942
+ var import_node_fs3 = require("node:fs");
5943
+ var import_node_os = require("node:os");
5944
+ var import_node_path4 = __toESM(require("node:path"));
5945
+ var import_semver = __toESM(require("semver"));
5946
+ var extensionDependencyVersionsFileEnvironmentVariable = "LENS_EXTENSION_DEPENDENCY_VERSIONS_FILE";
5947
+ var defaultVersionsFilePath = () => import_node_path4.default.join(
5948
+ (0, import_node_os.homedir)(),
5949
+ ".k8slens",
5950
+ "extensions",
5951
+ "extension-development-instructions",
5952
+ "extension-dependency-versions.json"
5953
+ );
5954
+ var commandName = "lens-extension-dependencies-check";
5955
+ var isSatisfied = (hostVersion, declaredRange) => import_semver.default.satisfies(hostVersion, declaredRange, { includePrerelease: true });
5956
+ var describeMismatch = ({ name, declaredRange, hostVersion }) => `"${name}": "${declaredRange}" does not include Lens's ${hostVersion}, declare "^${hostVersion}"`;
5957
+ var readVersions = (versionsFilePath) => {
5958
+ try {
5959
+ return JSON.parse((0, import_node_fs3.readFileSync)(versionsFilePath, "utf-8"));
5960
+ } catch (error) {
5961
+ if (error.code === "ENOENT") {
5962
+ return void 0;
5963
+ }
5964
+ throw error;
5965
+ }
5966
+ };
5967
+ var mismatchesOf = (packageJson2, versions) => ["dependencies", "peerDependencies", "devDependencies"].flatMap(
5968
+ (section) => Object.entries(packageJson2[section] ?? {}).flatMap(([name, declaredRange]) => {
5969
+ const hostVersion = versions[name];
5970
+ return hostVersion !== void 0 && !isSatisfied(hostVersion, declaredRange) ? [{ section, name, declaredRange, hostVersion }] : [];
5971
+ })
5972
+ );
5973
+ var indentationOf = (json) => /^([ \t]+)"/m.exec(json)?.[1] ?? 2;
5974
+ var checkExtensionDependencies = ({
5975
+ packageJsonPath,
5976
+ versionsFilePath,
5977
+ fix,
5978
+ log
5979
+ }) => {
5980
+ const versions = readVersions(versionsFilePath);
5981
+ if (!versions) {
5982
+ log(
5983
+ `Skipped checking dependency ranges against Lens: no "${versionsFilePath}", which Lens writes when it runs on this machine.`
5984
+ );
5985
+ return 0;
5986
+ }
5987
+ const packageJsonText = (0, import_node_fs3.readFileSync)(packageJsonPath, "utf-8");
5988
+ const packageJson2 = JSON.parse(packageJsonText);
5989
+ const mismatches = mismatchesOf(packageJson2, versions);
5990
+ if (fix) {
5991
+ if (mismatches.length === 0) {
5992
+ log("Nothing to fix: every dependency range includes the version Lens serves.");
5993
+ return 0;
5994
+ }
5995
+ for (const { section, name, declaredRange, hostVersion } of mismatches) {
5996
+ packageJson2[section] = { ...packageJson2[section], [name]: `^${hostVersion}` };
5997
+ log(`Rewrote "${name}" in ${section} from "${declaredRange}" to "^${hostVersion}".`);
5998
+ }
5999
+ (0, import_node_fs3.writeFileSync)(packageJsonPath, `${JSON.stringify(packageJson2, null, indentationOf(packageJsonText))}
6000
+ `);
6001
+ log('Run "npm install" so node_modules has the versions Lens serves.');
6002
+ return 0;
6003
+ }
6004
+ const refusedByLens = mismatches.filter(
6005
+ ({ section, name }) => section === "peerDependencies" || section === "dependencies" && !packageJson2.peerDependencies?.[name]
6006
+ );
6007
+ const devOnly = mismatches.filter(({ section }) => section === "devDependencies");
6008
+ for (const mismatch of devOnly) {
6009
+ log(
6010
+ `Warning: in devDependencies, ${describeMismatch(mismatch)}. The extension builds against another version than it runs on.`
6011
+ );
6012
+ }
6013
+ if (refusedByLens.length === 0) {
6014
+ log(`Every dependency range includes the version Lens serves (read from "${versionsFilePath}").`);
6015
+ return 0;
6016
+ }
6017
+ log(
6018
+ [
6019
+ `Lens would refuse to load this extension. These ranges in package.json do not include the version Lens serves (read from "${versionsFilePath}"):`,
6020
+ ...refusedByLens.map((mismatch) => ` in ${mismatch.section}, ${describeMismatch(mismatch)}`),
6021
+ `Run "npx ${commandName} --fix" to rewrite them, then "npm install".`
6022
+ ].join("\n")
6023
+ );
6024
+ return 1;
6025
+ };
6026
+ var extensionDependenciesCheck = () => checkExtensionDependencies({
6027
+ packageJsonPath: import_node_path4.default.resolve(process.cwd(), "package.json"),
6028
+ versionsFilePath: process.env[extensionDependencyVersionsFileEnvironmentVariable] || defaultVersionsFilePath(),
6029
+ fix: process.argv.slice(2).includes("--fix"),
6030
+ log: (line) => console.log(line)
6031
+ });
5939
6032
  /*! Bundled license information:
5940
6033
 
5941
6034
  lodash/lodash.js:
@@ -0,0 +1,21 @@
1
+ /** Overrides where the check reads the versions Lens serves, e.g. to check against another Lens than the one on this machine. */
2
+ export declare const extensionDependencyVersionsFileEnvironmentVariable = "LENS_EXTENSION_DEPENDENCY_VERSIONS_FILE";
3
+ export interface CheckExtensionDependenciesParams {
4
+ readonly packageJsonPath: string;
5
+ readonly versionsFilePath: string;
6
+ readonly fix: boolean;
7
+ readonly log: (line: string) => void;
8
+ }
9
+ /**
10
+ * Checks the ranges an extension's package.json declares for the packages Lens serves to
11
+ * extensions against the versions the Lens on this machine serves, with the rule Lens applies
12
+ * before loading the extension. A range Lens would refuse in `dependencies` or `peerDependencies`
13
+ * fails the check; one in `devDependencies` only warns, as Lens never reads those. With `fix`,
14
+ * rewrites every such range, in all three, to the caret range of the version Lens serves.
15
+ *
16
+ * @returns the exit code: 0 when Lens would load the extension, or when there is nothing to check against.
17
+ */
18
+ export declare const checkExtensionDependencies: ({ packageJsonPath, versionsFilePath, fix, log, }: CheckExtensionDependenciesParams) => number;
19
+ /** The `lens-extension-dependencies-check [--fix]` command, run in the extension's directory. */
20
+ export declare const extensionDependenciesCheck: () => number;
21
+ //# sourceMappingURL=extension-dependencies-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension-dependencies-check.d.ts","sourceRoot":"","sources":["../../src/extension-dependencies-check.ts"],"names":[],"mappings":"AAKA,iIAAiI;AACjI,eAAO,MAAM,kDAAkD,4CAA4C,CAAC;AAoB5G,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAyCD;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,qDAKpC,gCAAgC,KAAG,MA8DrC,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,0BAA0B,QAAO,MAM1C,CAAC"}