@b12k/mvm 0.0.1 → 0.0.3

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.
package/dist/update.js CHANGED
@@ -41,24 +41,28 @@
41
41
  const { dependencies , devDependencies } = (0, _fsExtra.readJsonSync)(filePath);
42
42
  return {
43
43
  lockFilePath: filePath.replace('package.json', 'mvm.lock'),
44
- dependency: (0, _utils.getDependencyType)(name, dependencies, devDependencies)
44
+ dependencyType: (0, _utils.getDependencyType)(name, dependencies, devDependencies)
45
45
  };
46
- }).filter(({ dependency })=>dependency);
46
+ }).filter(({ dependencyType })=>dependencyType);
47
47
  log({
48
48
  lockFilesPaths
49
49
  });
50
- lockFilesPaths.forEach(({ lockFilePath , dependency })=>{
51
- if (!dependency) return;
50
+ lockFilesPaths.forEach(({ lockFilePath , dependencyType })=>{
51
+ if (!dependencyType) return;
52
52
  (0, _fsExtra.ensureFileSync)(lockFilePath);
53
53
  const lockFile = JSON.parse((0, _fsExtra.readFileSync)(lockFilePath, 'utf8') || '{}');
54
- const updatedLockFile = {
54
+ if (lockFile.dependencies) delete lockFile.dependencies[name];
55
+ if (lockFile.devDependencies) delete lockFile.devDependencies[name];
56
+ const updatedLockFile = (0, _utils.sortLockKeys)({
55
57
  ...lockFile,
56
- [dependency]: {
57
- ...lockFile[dependency],
58
+ [dependencyType]: {
59
+ ...lockFile[dependencyType],
58
60
  [name]: version
59
61
  }
60
- };
61
- (0, _fsExtra.writeJsonSync)(lockFilePath, updatedLockFile);
62
+ });
63
+ (0, _fsExtra.writeJsonSync)(lockFilePath, updatedLockFile, {
64
+ spaces: 2
65
+ });
62
66
  });
63
67
  };
64
68
  });
@@ -4,3 +4,4 @@ export * from './read-local-package-json';
4
4
  export * from './do-nothing';
5
5
  export * from './types';
6
6
  export * from './log-json';
7
+ export * from './sort-lock-keys';
@@ -1,5 +1,5 @@
1
1
  (function(global, factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("./get-repo-root-path"), require("./get-dependency-type"), require("./read-local-package-json"), require("./do-nothing"), require("./types"), require("./log-json"));
2
+ if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("./get-repo-root-path"), require("./get-dependency-type"), require("./read-local-package-json"), require("./do-nothing"), require("./types"), require("./log-json"), require("./sort-lock-keys"));
3
3
  else if (typeof define === "function" && define.amd) define([
4
4
  "exports",
5
5
  "./get-repo-root-path",
@@ -7,10 +7,11 @@
7
7
  "./read-local-package-json",
8
8
  "./do-nothing",
9
9
  "./types",
10
- "./log-json"
10
+ "./log-json",
11
+ "./sort-lock-keys"
11
12
  ], factory);
12
- else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.index = {}, global.getRepoRootPath, global.getDependencyType, global.readLocalPackageJson, global.doNothing, global.types, global.logJson);
13
- })(this, function(exports, _getRepoRootPath, _getDependencyType, _readLocalPackageJson, _doNothing, _types, _logJson) {
13
+ else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.index = {}, global.getRepoRootPath, global.getDependencyType, global.readLocalPackageJson, global.doNothing, global.types, global.logJson, global.sortLockKeys);
14
+ })(this, function(exports, _getRepoRootPath, _getDependencyType, _readLocalPackageJson, _doNothing, _types, _logJson, _sortLockKeys) {
14
15
  "use strict";
15
16
  Object.defineProperty(exports, "__esModule", {
16
17
  value: true
@@ -21,6 +22,7 @@
21
22
  _exportStar(_doNothing, exports);
22
23
  _exportStar(_types, exports);
23
24
  _exportStar(_logJson, exports);
25
+ _exportStar(_sortLockKeys, exports);
24
26
  function _exportStar(from, to) {
25
27
  Object.keys(from).forEach(function(k) {
26
28
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -0,0 +1,5 @@
1
+ interface Sortable {
2
+ [key: string]: string | Sortable;
3
+ }
4
+ export declare const sortLockKeys: (object: Sortable) => Sortable;
5
+ export {};
@@ -0,0 +1,21 @@
1
+ (function(global, factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") factory(exports);
3
+ else if (typeof define === "function" && define.amd) define([
4
+ "exports"
5
+ ], factory);
6
+ else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.sortLockKeys = {});
7
+ })(this, function(exports) {
8
+ "use strict";
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ Object.defineProperty(exports, "sortLockKeys", {
13
+ enumerable: true,
14
+ get: ()=>sortLockKeys
15
+ });
16
+ const sortLockKeys = (object)=>Object.keys(object).sort().reduce((acc, key)=>{
17
+ const value = object[key];
18
+ acc[key] = value && typeof value === 'object' ? sortLockKeys(value) : value;
19
+ return acc;
20
+ }, {});
21
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b12k/mvm",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Monorepo versions manager",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -79,7 +79,6 @@
79
79
  "dependencies": {
80
80
  "commander": "10.0.0",
81
81
  "fs-extra": "11.1.0",
82
- "git-raw-commits": "2.0.11",
83
82
  "glob": "8.1.0"
84
83
  }
85
84
  }