@ts-dev-tools/core 1.5.32 → 1.5.35

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.
@@ -39,36 +39,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.install = void 0;
40
40
  var fs_1 = require("fs");
41
41
  var path_1 = require("path");
42
- var CorePackageService_1 = require("../services/CorePackageService");
42
+ var constants_1 = require("../constants");
43
43
  var DuplicateDependenciesService_1 = require("../services/DuplicateDependenciesService");
44
44
  var MigrationsService_1 = require("../services/MigrationsService");
45
45
  var PackageJson_1 = require("../services/PackageJson");
46
+ var SymlinkDependenciesService_1 = require("../services/SymlinkDependenciesService");
46
47
  function install(_a) {
47
48
  var cwd = _a.cwd, _b = _a.dir, dir = _b === void 0 ? "." : _b;
48
49
  return __awaiter(this, void 0, void 0, function () {
49
- var packageName, absoluteProjectDir, currentVersion;
50
+ var absoluteProjectDir, currentVersion;
50
51
  return __generator(this, function (_c) {
51
52
  switch (_c.label) {
52
53
  case 0:
53
- packageName = CorePackageService_1.CorePackageService.getPackageName();
54
54
  absoluteProjectDir = (0, path_1.resolve)(cwd, dir);
55
55
  if (!(0, fs_1.existsSync)(absoluteProjectDir)) {
56
- throw new Error("Unable to install ".concat(packageName, " in given directory ").concat((0, path_1.join)(cwd, dir)));
56
+ throw new Error("Unable to install ".concat(constants_1.PROJECT_NAME, " in given directory ").concat((0, path_1.join)(cwd, dir)));
57
57
  }
58
58
  if (!absoluteProjectDir.startsWith(cwd)) {
59
- throw new Error("Unable to install ".concat(packageName, " in a different folder than current process"));
59
+ throw new Error("Unable to install ".concat(constants_1.PROJECT_NAME, " in a different folder than current process"));
60
60
  }
61
61
  currentVersion = PackageJson_1.PackageJson.fromDirPath(absoluteProjectDir).getTsDevToolsVersion();
62
62
  if (currentVersion) {
63
- console.info("Updating ".concat(packageName, " installation..."));
63
+ console.info("Updating ".concat(constants_1.PROJECT_NAME, " installation..."));
64
64
  }
65
65
  else {
66
- console.info("Installing ".concat(packageName, "..."));
66
+ console.info("Installing ".concat(constants_1.PROJECT_NAME, "..."));
67
67
  }
68
68
  return [4 /*yield*/, MigrationsService_1.MigrationsService.executeMigrations(absoluteProjectDir, currentVersion)];
69
69
  case 1:
70
70
  _c.sent();
71
- DuplicateDependenciesService_1.DuplicateDependenciesService.duplicateDependencies(absoluteProjectDir);
71
+ SymlinkDependenciesService_1.SymlinkDependenciesService.executeSymlinking(absoluteProjectDir);
72
+ DuplicateDependenciesService_1.DuplicateDependenciesService.executeDeduplication(absoluteProjectDir);
72
73
  console.info("Installation done!");
73
74
  return [2 /*return*/];
74
75
  }
@@ -1,6 +1,6 @@
1
1
  export declare class DuplicateDependenciesService {
2
- static duplicateDependencies(absoluteProjectDir: string): void;
2
+ static executeDeduplication(absoluteProjectDir: string): void;
3
3
  private static getProjectDuplicateDependencies;
4
4
  private static getPluginDuplicateDependencies;
5
- private static printDuplicateDependencies;
5
+ private static printDuplicatedDependencies;
6
6
  }
@@ -6,11 +6,11 @@ var PluginService_1 = require("./PluginService");
6
6
  var DuplicateDependenciesService = /** @class */ (function () {
7
7
  function DuplicateDependenciesService() {
8
8
  }
9
- DuplicateDependenciesService.duplicateDependencies = function (absoluteProjectDir) {
9
+ DuplicateDependenciesService.executeDeduplication = function (absoluteProjectDir) {
10
10
  console.info("Checking for duplicate dev dependencies...");
11
11
  var duplicateDependencies = new Map();
12
12
  DuplicateDependenciesService.getProjectDuplicateDependencies(absoluteProjectDir, duplicateDependencies);
13
- DuplicateDependenciesService.printDuplicateDependencies(duplicateDependencies);
13
+ DuplicateDependenciesService.printDuplicatedDependencies(duplicateDependencies);
14
14
  console.info("Check for duplicate dev dependencies done!");
15
15
  };
16
16
  DuplicateDependenciesService.getProjectDuplicateDependencies = function (absoluteProjectDir, duplicateDependencies) {
@@ -40,7 +40,7 @@ var DuplicateDependenciesService = /** @class */ (function () {
40
40
  }
41
41
  }
42
42
  };
43
- DuplicateDependenciesService.printDuplicateDependencies = function (duplicateDependencies) {
43
+ DuplicateDependenciesService.printDuplicatedDependencies = function (duplicateDependencies) {
44
44
  duplicateDependencies.forEach(function (pluginDuplicateDependencies, plugin) {
45
45
  if (pluginDuplicateDependencies.size) {
46
46
  var pluginDuplicateDependenciesValue = Array.from(pluginDuplicateDependencies);
@@ -1,9 +1,11 @@
1
1
  export declare type Migration = {
2
- name: string;
2
+ fullname: string;
3
+ shortname: string;
3
4
  path: string;
4
5
  };
5
6
  export declare type MigrationUpFunction = (absoluteProjectDir: string) => Promise<void>;
6
7
  export declare class MigrationsService {
8
+ static MIGRATION_BUILT_PATH: string;
7
9
  static executeMigrations(absoluteProjectDir: string, currentVersion: string | undefined): Promise<void>;
8
10
  private static getAvailableMigrations;
9
11
  private static getPluginMigrations;
@@ -61,7 +61,7 @@ var MigrationsService = /** @class */ (function () {
61
61
  case 2:
62
62
  if (!(_i < migrations_1.length)) return [3 /*break*/, 5];
63
63
  migration = migrations_1[_i];
64
- console.info("Applying migration \"".concat(migration.name, "\"..."));
64
+ console.info("Applying migration \"".concat(migration.fullname, "\"..."));
65
65
  up = require(migration.path).up;
66
66
  // Apply migration
67
67
  return [4 /*yield*/, up(absoluteProjectDir)];
@@ -70,9 +70,9 @@ var MigrationsService = /** @class */ (function () {
70
70
  _a.sent();
71
71
  // Upgrade current version
72
72
  PackageJson_1.PackageJson.fromDirPath(absoluteProjectDir).merge({
73
- tsDevTools: { version: migration.name },
73
+ tsDevTools: { version: migration.shortname },
74
74
  });
75
- console.info("Migration \"".concat(migration.name, "\" applied!"));
75
+ console.info("Migration \"".concat(migration.fullname, "\" applied!"));
76
76
  _a.label = 4;
77
77
  case 4:
78
78
  _i++;
@@ -98,17 +98,15 @@ var MigrationsService = /** @class */ (function () {
98
98
  migrationFiles.push.apply(migrationFiles, MigrationsService.getPluginMigrations(installedPlugin, currentVersion));
99
99
  }
100
100
  migrationFiles.sort(function (_a, _b) {
101
- var nameA = _a.name;
102
- var nameB = _b.name;
101
+ var nameA = _a.shortname;
102
+ var nameB = _b.shortname;
103
103
  return nameA.localeCompare(nameB);
104
104
  });
105
105
  return Array.from(new Set(migrationFiles));
106
106
  };
107
107
  MigrationsService.getPluginMigrations = function (plugin, currentVersion) {
108
- // First retrieve migration of inherited plugins
109
- var migrationFiles = MigrationsService.getAvailableMigrations(plugin.path, currentVersion);
110
- // Then retrieve
111
- var pluginMigrationsDirPath = (0, path_1.resolve)(plugin.path, "dist/install/migrations");
108
+ var migrationFiles = [];
109
+ var pluginMigrationsDirPath = (0, path_1.resolve)(plugin.path, MigrationsService.MIGRATION_BUILT_PATH);
112
110
  for (var _i = 0, _a = (0, fs_1.readdirSync)(pluginMigrationsDirPath); _i < _a.length; _i++) {
113
111
  var migrationFile = _a[_i];
114
112
  if (!migrationFile.match(/^[0-9]{14}-[-a-z]+\.(js|ts)$/)) {
@@ -120,7 +118,8 @@ var MigrationsService = /** @class */ (function () {
120
118
  continue;
121
119
  }
122
120
  migrationFiles.push({
123
- name: migrationName,
121
+ shortname: migrationName,
122
+ fullname: "".concat(plugin.shortname, " - ").concat(migrationName),
124
123
  path: (0, path_1.resolve)(pluginMigrationsDirPath, migrationFile),
125
124
  });
126
125
  }
@@ -133,6 +132,7 @@ var MigrationsService = /** @class */ (function () {
133
132
  MigrationsService.migrationIsAfterCurrentVersion = function (migrationName, currentVersion) {
134
133
  return !currentVersion || currentVersion.localeCompare(migrationName) < 0;
135
134
  };
135
+ MigrationsService.MIGRATION_BUILT_PATH = "dist/install/migrations";
136
136
  return MigrationsService;
137
137
  }());
138
138
  exports.MigrationsService = MigrationsService;
@@ -18,12 +18,23 @@ var PluginService = /** @class */ (function () {
18
18
  if (!allDependenciesPackageNames.length) {
19
19
  return [];
20
20
  }
21
- var plugins = allDependenciesPackageNames.filter(function (packageName) {
21
+ var pluginsFullname = allDependenciesPackageNames.filter(function (packageName) {
22
22
  return PluginService.packageNameIsPlugin(packageName);
23
23
  });
24
24
  var sortPlugins = function (pluginA, pluginB) { return pluginA.localeCompare(pluginB); };
25
- plugins.sort(sortPlugins);
26
- return plugins.map(PluginService.getPluginFromFullname);
25
+ pluginsFullname.sort(sortPlugins);
26
+ var plugins = new Map();
27
+ for (var _i = 0, pluginsFullname_1 = pluginsFullname; _i < pluginsFullname_1.length; _i++) {
28
+ var pluginFullname = pluginsFullname_1[_i];
29
+ var plugin = PluginService.getPluginFromFullname(pluginFullname);
30
+ plugins.set(pluginFullname, plugin);
31
+ var pluginParents = PluginService.getInstalledPlugins(plugin.path);
32
+ for (var _a = 0, pluginParents_1 = pluginParents; _a < pluginParents_1.length; _a++) {
33
+ var pluginParent = pluginParents_1[_a];
34
+ plugins.set(pluginParent.fullname, pluginParent);
35
+ }
36
+ }
37
+ return Array.from(plugins.values());
27
38
  };
28
39
  PluginService.getPluginShortname = function (fullname) {
29
40
  var shortname = fullname.replace("".concat(constants_1.PACKAGE_BASE_NAME, "/"), "");
@@ -0,0 +1,7 @@
1
+ export declare class SymlinkDependenciesService {
2
+ static DEPENDENCIES_FOLDER: string;
3
+ static executeSymlinking(absoluteProjectDir: string): void;
4
+ private static symlinkPluginDependencies;
5
+ private static getPluginDependencies;
6
+ private static symlinkDependency;
7
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SymlinkDependenciesService = void 0;
4
+ var fs_1 = require("fs");
5
+ var path_1 = require("path");
6
+ var PackageJson_1 = require("./PackageJson");
7
+ var PluginService_1 = require("./PluginService");
8
+ var SymlinkDependenciesService = /** @class */ (function () {
9
+ function SymlinkDependenciesService() {
10
+ }
11
+ SymlinkDependenciesService.executeSymlinking = function (absoluteProjectDir) {
12
+ console.info("Symlinking dev dependencies...");
13
+ var installedPlugins = PluginService_1.PluginService.getInstalledPlugins(absoluteProjectDir);
14
+ for (var _i = 0, installedPlugins_1 = installedPlugins; _i < installedPlugins_1.length; _i++) {
15
+ var plugin = installedPlugins_1[_i];
16
+ SymlinkDependenciesService.symlinkPluginDependencies(absoluteProjectDir, plugin);
17
+ }
18
+ console.info("Symlinking dev dependencies done!");
19
+ };
20
+ SymlinkDependenciesService.symlinkPluginDependencies = function (absoluteProjectDir, plugin) {
21
+ var pluginDependencies = SymlinkDependenciesService.getPluginDependencies(plugin);
22
+ for (var _i = 0, pluginDependencies_1 = pluginDependencies; _i < pluginDependencies_1.length; _i++) {
23
+ var pluginDependency = pluginDependencies_1[_i];
24
+ var pluginDependencyPath = (0, path_1.join)(plugin.path, SymlinkDependenciesService.DEPENDENCIES_FOLDER, pluginDependency);
25
+ if (!(0, fs_1.existsSync)(pluginDependencyPath)) {
26
+ continue;
27
+ }
28
+ var projectPluginDependencyPath = (0, path_1.join)(absoluteProjectDir, SymlinkDependenciesService.DEPENDENCIES_FOLDER, pluginDependency);
29
+ if ((0, fs_1.existsSync)(projectPluginDependencyPath)) {
30
+ continue;
31
+ }
32
+ console.info("- Symlinking ".concat(pluginDependency));
33
+ SymlinkDependenciesService.symlinkDependency(pluginDependencyPath, projectPluginDependencyPath);
34
+ }
35
+ };
36
+ SymlinkDependenciesService.getPluginDependencies = function (plugin) {
37
+ var pluginPackageJson = PackageJson_1.PackageJson.fromDirPath(plugin.path);
38
+ return pluginPackageJson.getDependenciesPackageNames();
39
+ };
40
+ SymlinkDependenciesService.symlinkDependency = function (pluginDependencyPath, projectPluginDependencyPath) {
41
+ (0, fs_1.symlinkSync)(pluginDependencyPath, projectPluginDependencyPath);
42
+ };
43
+ SymlinkDependenciesService.DEPENDENCIES_FOLDER = "node_modules";
44
+ return SymlinkDependenciesService;
45
+ }());
46
+ exports.SymlinkDependenciesService = SymlinkDependenciesService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-dev-tools/core",
3
- "version": "1.5.32",
3
+ "version": "1.5.35",
4
4
  "description": "TS dev tools Core",
5
5
  "keywords": [
6
6
  "linter",
@@ -44,26 +44,26 @@
44
44
  "url": "https://github.com/escemi-tech/ts-dev-tools/issues"
45
45
  },
46
46
  "dependencies": {
47
- "@commitlint/cli": "^17.0.3",
48
- "@commitlint/config-conventional": "^17.0.3",
49
- "@types/jest": "^28.1.6",
50
- "@types/node": "^18.0.6",
51
- "@typescript-eslint/eslint-plugin": "^5.30.7",
52
- "@typescript-eslint/parser": "^5.30.6",
53
- "eslint": "^8.19.0",
47
+ "@commitlint/cli": "^17.1.2",
48
+ "@commitlint/config-conventional": "^17.1.0",
49
+ "@types/jest": "^28.1.7",
50
+ "@types/node": "^18.7.16",
51
+ "@typescript-eslint/eslint-plugin": "^5.36.2",
52
+ "@typescript-eslint/parser": "^5.36.2",
53
+ "eslint": "^8.23.0",
54
54
  "eslint-config-prettier": "^8.5.0",
55
55
  "eslint-plugin-import": "^2.26.0",
56
- "eslint-plugin-jest": "^26.6.0",
56
+ "eslint-plugin-jest": "^27.0.2",
57
57
  "eslint-plugin-node": "^11.1.0",
58
- "eslint-plugin-promise": "^6.0.0",
58
+ "eslint-plugin-promise": "^6.0.1",
59
59
  "import-sort-style-module": "^6.0.0",
60
60
  "jest": "^28.1.3",
61
61
  "lint-staged": "^13.0.3",
62
62
  "prettier": "^2.7.1",
63
63
  "prettier-plugin-import-sort": "^0.0.7",
64
64
  "pretty-quick": "^3.1.3",
65
- "ts-jest": "^28.0.6",
66
- "typescript": "^4.7.4"
65
+ "ts-jest": "^28.0.8",
66
+ "typescript": "^4.8.3"
67
67
  },
68
68
  "devDependencies": {
69
69
  "pinst": "^3.0.0"
@@ -116,5 +116,5 @@
116
116
  "github-actions"
117
117
  ]
118
118
  },
119
- "gitHead": "d2950589218ac5dcbe4700bbb1a1db4cfc230636"
119
+ "gitHead": "ac2511f89c409bb89f7c3b42468be2607f89d611"
120
120
  }