@public-ui/kolibri-cli 4.0.0-rc.2 → 4.0.0-rc.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.
@@ -64,10 +64,12 @@ Target version of @public-ui/*: ${options.overwriteTargetVersion}
64
64
  Source folder to migrate: ${baseDir}
65
65
  `);
66
66
  if (!fs_1.default.existsSync(baseDir)) {
67
- throw (0, reuse_1.logAndCreateError)(`The specified source folder "${baseDir}" does not exist or is inaccessible. Please check the path and try again.`);
67
+ const absolutePath = path_1.default.resolve(process.cwd(), baseDir);
68
+ throw (0, reuse_1.logAndCreateError)(`The specified source folder "${absolutePath}" (${baseDir}) does not exist or is inaccessible. Please check the path and try again.`);
68
69
  }
69
70
  if (!(0, reuse_1.hasKoliBriTags)(baseDir)) {
70
- console.log(chalk_1.default.yellow(`No KoliBri components (web or React) found under "${baseDir}". Check the path or your task configuration.`));
71
+ const absolutePath = path_1.default.resolve(process.cwd(), baseDir);
72
+ console.log(chalk_1.default.yellow(`No KoliBri components (web or React) found under "${absolutePath}" (${baseDir}). Check the path or your task configuration.`));
71
73
  }
72
74
  if (!options.ignoreGreaterVersion && semver_1.default.lt(options.overwriteTargetVersion, options.overwriteCurrentVersion)) {
73
75
  throw (0, reuse_1.logAndCreateError)('Your current version of @public-ui/components is greater than the version of @public-ui/kolibri-cli. Please update @public-ui/kolibri-cli or force the migration with --ignore-greater-version.');
@@ -10,6 +10,26 @@ const path_1 = __importDefault(require("path"));
10
10
  const semver_1 = __importDefault(require("semver"));
11
11
  const reuse_1 = require("../shares/reuse");
12
12
  const MIN_VERSION_OF_PUBLIC_UI = '1.4.2';
13
+ /**
14
+ * Displays a progress bar in the console.
15
+ * @param {number} current Current progress
16
+ * @param {number} total Total items
17
+ * @param {string} title Optional title
18
+ */
19
+ function displayProgressBar(current, total, title = '') {
20
+ const barLength = 30;
21
+ const percentage = total === 0 ? 0 : (current / total) * 100;
22
+ const filledLength = Math.round((barLength * current) / total);
23
+ const emptyLength = barLength - filledLength;
24
+ const bar = chalk_1.default.green('█'.repeat(filledLength)) + chalk_1.default.gray('░'.repeat(emptyLength));
25
+ const percentStr = percentage.toFixed(0).padStart(3, ' ');
26
+ // Bestimme die maximale Ziffernzahl des totals
27
+ const totalDigits = total.toString().length;
28
+ const currentStr = current.toString().padStart(totalDigits, ' ');
29
+ const taskStr = `${currentStr}/${total}`;
30
+ const titleStr = title ? ` ${title}` : '';
31
+ process.stdout.write(`\r${bar} ${percentStr}% [${taskStr}]${titleStr}`);
32
+ }
13
33
  class TaskRunner {
14
34
  tasks = new Map();
15
35
  baseDir = '/';
@@ -20,6 +40,7 @@ class TaskRunner {
20
40
  tasks: {},
21
41
  },
22
42
  };
43
+ completedTasks = 0;
23
44
  constructor(baseDir, cliVersion, projectVersion, config) {
24
45
  this.setBaseDir(baseDir);
25
46
  this.setCliVersion(cliVersion);
@@ -86,10 +107,13 @@ class TaskRunner {
86
107
  }
87
108
  else {
88
109
  this.config.migrate.tasks[task.getIdentifier()] = true;
89
- if (task.getStatus() === 'pending' &&
90
- semver_1.default.satisfies(this.projectVersion, task.getVersionRange(), {
91
- includePrerelease: true,
92
- })) {
110
+ const isProjectVersionGreater = semver_1.default.gtr(this.projectVersion, task.getVersionRange(), {
111
+ includePrerelease: true,
112
+ });
113
+ const isCliVersionLower = semver_1.default.ltr(this.cliVersion, task.getVersionRange(), {
114
+ includePrerelease: true,
115
+ });
116
+ if (task.getStatus() === 'pending' && !isProjectVersionGreater && !isCliVersionLower) {
93
117
  // task.setStatus('running'); only of the task is async
94
118
  if (!this.tasks.has(task.getIdentifier())) {
95
119
  this.registerTask(task);
@@ -103,14 +127,22 @@ class TaskRunner {
103
127
  taskDependencies.forEach((dependentTask) => {
104
128
  this.dependentTaskRun(dependentTask, dependentTask.getTaskDependencies());
105
129
  });
106
- if (taskDependencies.every((dependentTask) => dependentTask.getStatus() === 'done')) {
130
+ if (taskDependencies.length === 0 || taskDependencies.every((dependentTask) => dependentTask.getStatus() === 'done')) {
131
+ displayProgressBar(this.completedTasks, this.tasks.size, task.getTitle());
107
132
  this.runTask(task);
133
+ this.completedTasks++;
108
134
  }
109
135
  }
110
136
  run() {
137
+ this.completedTasks = 0;
138
+ displayProgressBar(0, this.tasks.size);
111
139
  this.tasks.forEach((task) => {
112
140
  this.dependentTaskRun(task, task.getTaskDependencies());
113
141
  });
142
+ displayProgressBar(this.tasks.size, this.tasks.size);
143
+ if (this.tasks.size > 0) {
144
+ console.log(); // New line after progress bar
145
+ }
114
146
  }
115
147
  getPendingMinVersion() {
116
148
  let version = this.cliVersion;
@@ -47,7 +47,7 @@ function filterFilesByExt(dir, ext) {
47
47
  let files = [];
48
48
  const dirPath = path_1.default.resolve(process.cwd(), dir);
49
49
  fs_1.default.readdirSync(dirPath).forEach((file) => {
50
- const fullPath = path_1.default.resolve(dir, file);
50
+ const fullPath = path_1.default.resolve(dirPath, file);
51
51
  if (fs_1.default.lstatSync(fullPath).isDirectory()) {
52
52
  files = files.concat(filterFilesByExt(fullPath, ext));
53
53
  }
@@ -65,7 +65,8 @@ function filterFilesByExt(dir, ext) {
65
65
  */
66
66
  function hasKoliBriTags(dir) {
67
67
  const regexes = [types_1.WEB_TAG_REGEX, types_1.REACT_TAG_REGEX];
68
- const files = filterFilesByExt(dir, types_1.MARKUP_EXTENSIONS);
68
+ const dirPath = path_1.default.resolve(process.cwd(), dir);
69
+ const files = filterFilesByExt(dirPath, types_1.MARKUP_EXTENSIONS);
69
70
  for (const file of files) {
70
71
  let fd;
71
72
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/kolibri-cli",
3
- "version": "4.0.0-rc.2",
3
+ "version": "4.0.0-rc.3",
4
4
  "license": "EUPL-1.2",
5
5
  "homepage": "https://public-ui.github.io",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "prettier-plugin-organize-imports": "4.3.0",
31
31
  "semver": "7.7.3",
32
32
  "typed-bem": "1.0.2",
33
- "@public-ui/components": "4.0.0-rc.2"
33
+ "@public-ui/components": "4.0.0-rc.3"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "24.10.4",