@public-ui/kolibri-cli 3.0.2-rc.1 → 3.0.2-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.
package/README.md CHANGED
@@ -25,6 +25,8 @@ pnpm i -g @public-ui/kolibri-cli
25
25
  yarn add -g @public-ui/kolibri-cli
26
26
  ```
27
27
 
28
+ > **Important:** Install exactly the CLI version you want to upgrade to. The migration tool compares your locally installed `@public-ui/components` version with the CLI version to decide which migration tasks must run and in which order.
29
+
28
30
  ## Usage
29
31
 
30
32
  The `KoliBri` CLI is intended to be executed in your project root directory. Use the `kolibri` command to start the CLI.
package/dist/index.js CHANGED
@@ -26,4 +26,4 @@ program.name('kolibri').description('CLI for executing some helpful commands for
26
26
  (0, generate_scss_1.default)(program);
27
27
  (0, info_1.default)(program);
28
28
  (0, migrate_1.default)(program);
29
- program.parse();
29
+ void program.parseAsync();
@@ -11,6 +11,19 @@ const fs_1 = __importDefault(require("fs"));
11
11
  // Function to get the binary version
12
12
  const getBinaryVersion = (command) => {
13
13
  try {
14
+ // For yarn, use a temporary directory to prevent package.json modification
15
+ // Yarn with Corepack automatically adds packageManager field when executed
16
+ if (command === 'yarn') {
17
+ const originalCwd = process.cwd();
18
+ const tmpDir = os_1.default.tmpdir();
19
+ process.chdir(tmpDir);
20
+ try {
21
+ return (0, child_process_1.execSync)(`${command} --version`, { encoding: 'utf8' }).trim();
22
+ }
23
+ finally {
24
+ process.chdir(originalCwd);
25
+ }
26
+ }
14
27
  return (0, child_process_1.execSync)(`${command} --version`, { encoding: 'utf8' }).trim();
15
28
  }
16
29
  catch {
@@ -62,6 +62,12 @@ Current version of @public-ui/*: ${options.overwriteCurrentVersion}
62
62
  Target version of @public-ui/*: ${options.overwriteTargetVersion}
63
63
  Source folder to migrate: ${baseDir}
64
64
  `);
65
+ if (!fs_1.default.existsSync(baseDir)) {
66
+ throw (0, reuse_1.logAndCreateError)(`The specified source folder "${baseDir}" does not exist or is inaccessible. Please check the path and try again.`);
67
+ }
68
+ if (!(0, reuse_1.hasKoliBriTags)(baseDir)) {
69
+ console.log(chalk_1.default.yellow(`No KoliBri components (web or React) found under "${baseDir}". Check the path or your task configuration.`));
70
+ }
65
71
  if (!options.ignoreGreaterVersion && semver_1.default.lt(options.overwriteTargetVersion, options.overwriteCurrentVersion)) {
66
72
  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.');
67
73
  }
@@ -163,6 +169,9 @@ Modified files: ${reuse_1.MODIFIED_FILES.size}`);
163
169
  reuse_1.MODIFIED_FILES.forEach((file) => {
164
170
  console.log(`- ${file}`);
165
171
  });
172
+ if (reuse_1.MODIFIED_FILES.size === 0) {
173
+ console.log(chalk_1.default.yellow(`No files were modified. Verify the folder "${baseDir}" or check your .kolibri.config.json tasks.`));
174
+ }
166
175
  if (reuse_1.MODIFIED_FILES.size > 0 && options.format) {
167
176
  console.log(`
168
177
  We try to format the modified files with prettier...`);
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.POST_MESSAGES = exports.findIndexHtml = exports.resolveIndexHtmlPath = exports.getVersionOfPublicUiKoliBriCli = exports.getVersionOfPublicUiComponents = exports.getContentOfProjectPkgJson = exports.MODIFIED_FILES = exports.isPropertyKebabCaseRegExp = exports.isTagKebabCaseRegExp = exports.isKebabCaseRegExp = void 0;
7
7
  exports.logAndCreateError = logAndCreateError;
8
8
  exports.filterFilesByExt = filterFilesByExt;
9
+ exports.hasKoliBriTags = hasKoliBriTags;
9
10
  exports.getPackageManagerCommand = getPackageManagerCommand;
10
11
  exports.kebabToCapitalCase = kebabToCapitalCase;
11
12
  exports.kebabToCamelCase = kebabToCamelCase;
@@ -14,6 +15,7 @@ exports.getRemoveMode = getRemoveMode;
14
15
  const chalk_1 = __importDefault(require("chalk"));
15
16
  const fs_1 = __importDefault(require("fs"));
16
17
  const path_1 = __importDefault(require("path"));
18
+ const types_1 = require("../../types");
17
19
  /**
18
20
  * This function is used to exit the process with an error message.
19
21
  * @param {string} msg The error message
@@ -55,6 +57,44 @@ function filterFilesByExt(dir, ext) {
55
57
  });
56
58
  return files;
57
59
  }
60
+ /**
61
+ * Checks if the specified directory contains any files with KoliBri tags.
62
+ * Files are streamed in chunks to avoid loading entire files into memory.
63
+ * @param {string} dir The directory to search in
64
+ * @returns {boolean} True if at least one file contains KoliBri component tags (web or React)
65
+ */
66
+ function hasKoliBriTags(dir) {
67
+ const regexes = [types_1.WEB_TAG_REGEX, types_1.REACT_TAG_REGEX];
68
+ const files = filterFilesByExt(dir, types_1.MARKUP_EXTENSIONS);
69
+ for (const file of files) {
70
+ let fd;
71
+ try {
72
+ fd = fs_1.default.openSync(file, 'r');
73
+ const buffer = Buffer.alloc(65536);
74
+ let bytesRead;
75
+ let content = '';
76
+ while ((bytesRead = fs_1.default.readSync(fd, buffer, 0, buffer.length, null)) > 0) {
77
+ content += buffer.toString('utf8', 0, bytesRead);
78
+ if (regexes.some((regex) => regex.test(content))) {
79
+ fs_1.default.closeSync(fd);
80
+ return true;
81
+ }
82
+ if (content.length > 1024) {
83
+ content = content.slice(-1024);
84
+ }
85
+ }
86
+ }
87
+ catch (err) {
88
+ console.error(`Error reading file ${file}, skipping file due to read error:`, err);
89
+ }
90
+ finally {
91
+ if (fd !== undefined) {
92
+ fs_1.default.closeSync(fd);
93
+ }
94
+ }
95
+ }
96
+ return false;
97
+ }
58
98
  /**
59
99
  * This function is used to get the version of the package.json as string.
60
100
  * @param {string} offsetPath The offset path to the package.json
package/dist/types.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MARKUP_EXTENSIONS = exports.CUSTOM_ELEMENT_FILE_EXTENSIONS = exports.COMPONENT_FILE_EXTENSIONS = exports.FILE_EXTENSIONS = void 0;
3
+ exports.REACT_TAG_REGEX = exports.WEB_TAG_REGEX = exports.MARKUP_EXTENSIONS = exports.CUSTOM_ELEMENT_FILE_EXTENSIONS = exports.COMPONENT_FILE_EXTENSIONS = exports.FILE_EXTENSIONS = void 0;
4
4
  exports.FILE_EXTENSIONS = ['html', 'xhtml', 'js', 'json', 'jsx', 'ts', 'tsx', 'vue'];
5
5
  exports.COMPONENT_FILE_EXTENSIONS = ['jsx', 'tsx', 'vue'];
6
6
  exports.CUSTOM_ELEMENT_FILE_EXTENSIONS = ['html', 'xhtml', 'jsx', 'tsx', 'vue'];
7
7
  exports.MARKUP_EXTENSIONS = exports.COMPONENT_FILE_EXTENSIONS.concat(exports.CUSTOM_ELEMENT_FILE_EXTENSIONS);
8
+ exports.WEB_TAG_REGEX = /\b<kol-[a-z-]+/i;
9
+ exports.REACT_TAG_REGEX = /\b<Kol[A-Z][A-Za-z]*/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/kolibri-cli",
3
- "version": "3.0.2-rc.1",
3
+ "version": "3.0.2-rc.3",
4
4
  "license": "EUPL-1.2",
5
5
  "homepage": "https://public-ui.github.io",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "prettier": "3.5.3",
30
30
  "semver": "7.7.2",
31
31
  "typed-bem": "1.0.0-rc.7",
32
- "@public-ui/components": "3.0.2-rc.1"
32
+ "@public-ui/components": "3.0.2-rc.3"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "24.0.1",
@@ -63,6 +63,8 @@
63
63
  "start": "rimraf test && cpy \"../../samples/react/src/components\" test/src && cpy \"../../samples/react/public/*.html\" test/ && ts-node src/index.ts migrate --ignore-uncommitted-changes --test-tasks test",
64
64
  "restart": "pnpm reset && pnpm start",
65
65
  "unused": "knip",
66
- "watch": "nodemon --ignore package.json src/index.ts migrate --ignore-uncommitted-changes --test-tasks test"
66
+ "watch": "nodemon --ignore package.json src/index.ts migrate --ignore-uncommitted-changes --test-tasks test",
67
+ "test": "pnpm test:unit",
68
+ "test:unit": "TS_NODE_PROJECT=tsconfig.test.json mocha --require ts-node/register test/**/*.ts"
67
69
  }
68
70
  }