@public-ui/kolibri-cli 1.7.0-rc.9 → 1.7.1

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.
Files changed (47) hide show
  1. package/README.md +108 -16
  2. package/dist/index.js +0 -0
  3. package/dist/migrate/index.js +110 -23
  4. package/dist/migrate/runner/task-runner.js +13 -1
  5. package/dist/migrate/runner/tasks/common/ExecTask.js +30 -0
  6. package/dist/migrate/runner/tasks/common/GenericRenameSlotNameTask.js +44 -0
  7. package/dist/migrate/runner/tasks/common/GitIgnoreAddRuleTask.js +40 -0
  8. package/dist/migrate/runner/tasks/common/HandleDependencyTask.js +56 -0
  9. package/dist/migrate/runner/tasks/common/JsonTask.js +47 -0
  10. package/dist/migrate/runner/tasks/common/LabelExpertSlot.js +20 -3
  11. package/dist/migrate/runner/tasks/common/MarkRemovedSlotTask.js +17 -0
  12. package/dist/migrate/runner/tasks/common/MergeHtmlTask.js +36 -0
  13. package/dist/migrate/runner/tasks/common/NpmRcAddRuleTask.js +40 -0
  14. package/dist/migrate/runner/tasks/common/RefactorPropertyLabelReplaceFalse.js +53 -0
  15. package/dist/migrate/runner/tasks/common/RemoveTask.js +18 -0
  16. package/dist/migrate/runner/tasks/common/RenameSlotNameTask.js +17 -0
  17. package/dist/migrate/runner/tasks/common/TsConfigReconfigureTask.js +51 -0
  18. package/dist/migrate/runner/tasks/common/VsCodeSettingsReconfigureTask.js +57 -0
  19. package/dist/migrate/runner/tasks/index.js +17 -0
  20. package/dist/migrate/runner/tasks/test/index.js +2 -4
  21. package/dist/migrate/runner/tasks/test/test-version-next-99.js +10 -0
  22. package/dist/migrate/runner/tasks/v1/abbr.js +2 -1
  23. package/dist/migrate/runner/tasks/v1/assets.js +41 -0
  24. package/dist/migrate/runner/tasks/v1/button.js +2 -1
  25. package/dist/migrate/runner/tasks/v1/icon.js +2 -1
  26. package/dist/migrate/runner/tasks/v1/index.js +52 -22
  27. package/dist/migrate/runner/tasks/v1/input-checkbox.js +2 -1
  28. package/dist/migrate/runner/tasks/v1/input-color.js +2 -1
  29. package/dist/migrate/runner/tasks/v1/input-date.js +2 -1
  30. package/dist/migrate/runner/tasks/v1/input-email.js +2 -1
  31. package/dist/migrate/runner/tasks/v1/input-file.js +5 -0
  32. package/dist/migrate/runner/tasks/v1/input-number.js +2 -1
  33. package/dist/migrate/runner/tasks/v1/input-password.js +5 -0
  34. package/dist/migrate/runner/tasks/v1/input-range.js +2 -1
  35. package/dist/migrate/runner/tasks/v1/input-text.js +2 -1
  36. package/dist/migrate/runner/tasks/v1/input.js +5 -0
  37. package/dist/migrate/runner/tasks/v1/nav.js +3 -2
  38. package/dist/migrate/runner/tasks/v1/pagination.js +4 -1
  39. package/dist/migrate/runner/tasks/v1/select.js +2 -1
  40. package/dist/migrate/runner/tasks/v1/span.js +2 -1
  41. package/dist/migrate/runner/tasks/v1/split-button.js +3 -1
  42. package/dist/migrate/runner/tasks/v1/tabs.js +2 -1
  43. package/dist/migrate/runner/tasks/v1/toast.js +3 -1
  44. package/dist/migrate/shares/reuse.js +22 -7
  45. package/package.json +64 -62
  46. package/dist/migrate/runner/tasks/test/test-version-next-2.js +0 -10
  47. package/dist/migrate/runner/tasks/test/test-version-next-3.js +0 -10
package/README.md CHANGED
@@ -50,15 +50,23 @@ With the `migrate` command you can migrate your project to the latest version of
50
50
  Actually the following migrations are available:
51
51
 
52
52
  - Component renaming ✓
53
- - Component removal
53
+ - Component removal (no one yet)
54
54
  - Property renaming ✓
55
55
  - Property removal ✓
56
- - Property type change
57
- - Logic refactoring
58
- - Expert-Slot refactoring
59
- - `.vscode/settings.json` add IntelliSense for HTML ⏰
60
- - `.gitignore` exclude `.kolibri.migrate.json`
61
- - `.tsconfig` add `@public-ui/components` to `types` array ⏰
56
+ - Slots renaming (`content`)
57
+ - Slots removal (`footer`, `header`) ✓
58
+ - Logic refactoring (no one yet)
59
+ - Expert-Slot refactoring
60
+ - Move `innerText` to property
61
+ - Property type change (remove `_label={false}`)
62
+ - Set `_label=""` to activate the expert slot ([#5396](https://github.com/public-ui/kolibri/issues/5396)) ✓
63
+ - `.vscode/settings.json` add IntelliSense for HTML ✓
64
+ - `.gitignore` exclude `.kolibri.migrate.json` ✓
65
+ - `.tsconfig` add `@public-ui/components` to `types` array ✓
66
+ - Format modified files (`prettier@^3`) ✓
67
+ - Copy and integrate new assets ✓
68
+ - Handles `_icon-align` with a refactoring tasks ([#5397](https://github.com/public-ui/kolibri/issues/5397)) ⏰
69
+ - Detection of `_iconOnly` in TSX is not stable ([#5404](https://github.com/public-ui/kolibri/issues/5404)) ⏰
62
70
 
63
71
  #### How does it work?
64
72
 
@@ -84,10 +92,12 @@ kolibri migrate <path>
84
92
 
85
93
  #### Options
86
94
 
87
- | Option | Description | Type | Default |
88
- | ------------------------------ | ----------------------------------------- | :------------------: | :------: |
89
- | `--ignore-uncommitted-changes` | Allows execution with uncommitted changes | boolean | false |
90
- | `--remove-mode` | Prefix property name or delete property | `delete` \| `prefix` | `prefix` |
95
+ | Option | Description | Type | Default |
96
+ | ------------------------------ | ---------------------------------------------- | :------------------: | :------: |
97
+ | `--format` | Try to format the modified files with prettier | boolean | true |
98
+ | `--ignore-greater-version` | Allows execution with greater versions | boolean | false |
99
+ | `--ignore-uncommitted-changes` | Allows execution with uncommitted changes | boolean | false |
100
+ | `--remove-mode` | Prefix property name or delete property | `delete` \| `prefix` | `prefix` |
91
101
 
92
102
  #### Configuration
93
103
 
@@ -99,6 +109,17 @@ You can configure the migration with the `.kolibri.config.json` file in your pro
99
109
  {
100
110
  "migrate": {
101
111
  "tasks": {
112
+ ".gitignore-add-rule-.kolibri.migrate.json": true,
113
+ "vscode-settings-reconfigure-html.customData": true,
114
+ "tsconfig-reconfigure-compilerOptions.types": true,
115
+ "remove--cpy-cli,rimraf": true,
116
+ "add--cpy-cli,rimraf": true,
117
+ "package.json-reconfigure-scripts.postinstall": true,
118
+ "merge-html-codicon-in-index.html": true,
119
+ "remove-public/assets/codicons": true,
120
+ "exec-npx cpy \"node_modules/@public-ui/components/assets/**/*\" \"public/assets\" --dot": true,
121
+ ".npmrc-add-rule-save-exact=true": true,
122
+ "kol-abbr-rename-property-_align-to-_tooltip-align": true,
102
123
  "kol-abbr-rename-property-_title-to-_label": true,
103
124
  "kol-accordion-rename-property-_heading-to-_label": true,
104
125
  "kol-badge-rename-property-_icon-only-to-_hide-label": true,
@@ -110,38 +131,99 @@ You can configure the migration with the `.kolibri.config.json` file in your pro
110
131
  "kol-button-link-rename-property-_icon-only-to-_hide-label": true,
111
132
  "kol-button-remove-property-_aria-current": true,
112
133
  "kol-button-remove-property-_aria-label": true,
134
+ "kol-button-remove-property-_icon-align": true,
113
135
  "kol-button-rename-property-_icon-only-to-_hide-label": true,
136
+ "kol-button-rename-property-_icon-to-_icons": true,
114
137
  "kol-card-rename-property-_heading-to-_label": true,
115
138
  "kol-card-rename-property-_headline-to-_label": true,
116
139
  "kol-details-rename-property-_summary-to-_label": true,
117
140
  "kol-icon-remove-property-_part": true,
118
141
  "kol-icon-rename-property-_aria-label-to-_label": true,
142
+ "kol-icon-rename-property-_icon-to-_icons": true,
143
+ "kol-input-checkbox-rename-property-_icon-to-_icons": true,
119
144
  "kol-checkbox-rename-property-_type-to-_variant": true,
145
+ "kol-color-rename-property-_icon-to-_icons": true,
120
146
  "kol-color-rename-property-_list-to-_suggestions": true,
147
+ "kol-input-date-rename-property-_icon-to-_icons": true,
121
148
  "kol-date-rename-property-_list-to-_suggestions": true,
149
+ "kol-input-email-rename-property-_icon-to-_icons": true,
122
150
  "kol-input-email-rename-property-_list-to-_suggestions": true,
151
+ "kol-input-file-rename-property-_icon-to-_icons": true,
152
+ "kol-input-number-rename-property-_icon-to-_icons": true,
123
153
  "kol-input-number-rename-property-_list-to-_suggestions": true,
154
+ "kol-input-password-rename-property-_icon-to-_icons": true,
124
155
  "kol-input-radio-rename-property-_list-to-_options": true,
156
+ "kol-input-range-rename-property-_icon-to-_icons": true,
125
157
  "kol-input-range-rename-property-_list-to-_suggestions": true,
158
+ "kol-input-rename-property-_icon-to-_icons": true,
159
+ "kol-input-text-rename-property-_icon-to-_icons": true,
126
160
  "kol-input-text-rename-property-_list-to-_suggestions": true,
127
- "kol-link-group-rename-property-_aria-label-to-_label": true,
161
+ "kol-link-button-remove-property-_aria-control": true,
162
+ "kol-link-button-remove-property-_aria-expanded": true,
163
+ "kol-link-button-remove-property-_aria-label": true,
164
+ "kol-link-button-remove-property-_aria-selected": true,
165
+ "kol-link-button-remove-property-_disabled": true,
166
+ "kol-link-button-rename-property-_aria-current-to-_listen-aria-current": true,
167
+ "kol-link-button-rename-property-_icon-only-to-_hide-label": true,
168
+ "kol-link-group-rename-property-_heading-to-_label": true,
169
+ "kol-link-group-remove-property-_heading": true,
128
170
  "kol-link-group-remove-property-_ordered": true,
171
+ "kol-link-group-rename-property-_aria-label-to-_label": true,
172
+ "kol-link-remove-property-_aria-control": true,
173
+ "kol-link-remove-property-_aria-expanded": true,
174
+ "kol-link-remove-property-_aria-label": true,
175
+ "kol-link-remove-property-_aria-selected": true,
176
+ "kol-link-remove-property-_disabled": true,
177
+ "kol-link-remove-property-_icon-align": true,
178
+ "kol-link-remove-property-_selector": true,
179
+ "kol-link-remove-property-_stealth": true,
180
+ "kol-link-remove-property-_use-case": true,
181
+ "kol-link-rename-property-_aria-current-to-_listen-aria-current": true,
182
+ "kol-link-rename-property-_icon-only-to-_hide-label": true,
183
+ "kol-logo-rename-property-_abbr-to-_org": true,
184
+ "kol-modal-rename-property-_aria-label-to-_label": true,
185
+ "kol-nav-remove-property-_variant": true,
129
186
  "kol-nav-rename-property-_aria-label-to-_label": true,
130
187
  "kol-nav-rename-property-_compact-to-_hide-label": true,
131
- "kol-nav-remove-property-_has-compact-button": true,
132
188
  "kol-pagination-rename-property-_count-to-_total": true,
189
+ "kol-pagination-rename-property-_total-to-_max": true,
133
190
  "kol-progress-rename-property-_type-to-_variant": true,
134
191
  "kol-quote-rename-property-_caption-to-_label": true,
135
- "kol-select-rename-property-_height-to-_rows": false,
136
- "kol-select-rename-property-_list-to-_options": false,
192
+ "kol-select-rename-property-_height-to-_rows": true,
193
+ "kol-select-rename-property-_icon-to-_icons": true,
194
+ "kol-select-rename-property-_list-to-_options": true,
137
195
  "kol-skip-nav-rename-property-_aria-label-to-_label": true,
138
196
  "kol-span-rename-property-_icon-only-to-_hide-label": true,
197
+ "kol-span-rename-property-_icon-to-_icons": true,
139
198
  "kol-split-button-remove-property-_aria-label": true,
199
+ "kol-split-button-rename-property-_show-dropdown-to-_show": true,
140
200
  "kol-table-rename-property-_caption-to-_label": true,
141
201
  "kol-tabs-rename-property-_aria-label-to-_label": true,
202
+ "kol-tabs-rename-property-_icon-to-_icons": true,
142
203
  "kol-tabs-rename-property-_tab-align-to-_align": true,
204
+ "kol-toast-remove-property-_show-duration": true,
143
205
  "kol-toast-rename-property-_heading-to-_label": true,
144
- "kol-version-rename-property-_version-to-_label": true
206
+ "kol-version-rename-property-_version-to-_label": true,
207
+ "kol-heading-move-innerText-to-property-_label": true,
208
+ "kol-input-checkbox-move-innerText-to-property-_label": true,
209
+ "kol-input-color-move-innerText-to-property-_label": true,
210
+ "kol-input-date-move-innerText-to-property-_label": true,
211
+ "kol-input-email-move-innerText-to-property-_label": true,
212
+ "kol-input-file-move-innerText-to-property-_label": true,
213
+ "kol-input-number-move-innerText-to-property-_label": true,
214
+ "kol-input-password-move-innerText-to-property-_label": true,
215
+ "kol-input-radio-move-innerText-to-property-_label": true,
216
+ "kol-input-range-move-innerText-to-property-_label": true,
217
+ "kol-input-text-move-innerText-to-property-_label": true,
218
+ "kol-link-move-innerText-to-property-_label": true,
219
+ "kol-select-move-innerText-to-property-_label": true,
220
+ "kol-textarea-move-innerText-to-property-_label": true,
221
+ "kol-accordion-mark-removed-slot-header": true,
222
+ "kol-card-mark-removed-slot-footer": true,
223
+ "kol-card-mark-removed-slot-header": true,
224
+ "kol-accordion-rename-slot-content-to-": true,
225
+ "kol-card-rename-slot-content-to-": true,
226
+ "refactor-property-label-replace-false": true
145
227
  }
146
228
  }
147
229
  }
@@ -166,3 +248,13 @@ You have always the possibility of a dry run. Because before the migration will
166
248
  After the migration you can check the result with `git status` and `git diff`.
167
249
 
168
250
  Is anything wrong, you can reset the migration with `git reset --hard HEAD~1` or by discarding the affected files.
251
+
252
+ ## Changelog
253
+
254
+ ### 1.7.1
255
+
256
+ - Fix version handling by adding the absolut min version 1.4.2
257
+ - Add post message feature for more details
258
+ - Add `${` support by `_label` migration
259
+ - Activate Expert-Slot refactoring for `_label` migration
260
+ - Prevents `@public-ui/kolibri-cli` from being changed by the update process
package/dist/index.js CHANGED
File without changes
@@ -3,13 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chalk_1 = __importDefault(require("chalk"));
6
7
  const child_process_1 = require("child_process");
7
8
  const commander_1 = require("commander");
8
9
  const fs_1 = __importDefault(require("fs"));
10
+ const node_child_process_1 = __importDefault(require("node:child_process"));
9
11
  const path_1 = __importDefault(require("path"));
12
+ const semver_1 = __importDefault(require("semver"));
10
13
  const task_runner_1 = require("./runner/task-runner");
14
+ const tasks_1 = require("./runner/tasks");
11
15
  const test_1 = require("./runner/tasks/test");
12
16
  const v1_1 = require("./runner/tasks/v1");
17
+ const assets_1 = require("./runner/tasks/v1/assets");
13
18
  const reuse_1 = require("./shares/reuse");
14
19
  const types_1 = require("./types");
15
20
  /**
@@ -21,6 +26,8 @@ function default_1(program) {
21
26
  .command('migrate')
22
27
  .description('This command migrates KoliBri code to the current version.')
23
28
  .argument('[string]', 'Source code folder to migrate', 'src')
29
+ .addOption(new commander_1.Option('--format', 'Try to format the modified files with prettier').default(true))
30
+ .addOption(new commander_1.Option('--ignore-greater-version', 'Allows execution with greater versions').default(false))
24
31
  .addOption(new commander_1.Option('--ignore-uncommitted-changes', 'Allows execution with uncommitted changes').default(false))
25
32
  .addOption(new commander_1.Option('--remove-mode <mode>', 'Prefix property name or delete property').choices(types_1.REMOVE_MODE).default('prefix'))
26
33
  .addOption(new commander_1.Option('--test-tasks', 'Run additional test tasks').default(false).hideHelp())
@@ -40,6 +47,9 @@ function default_1(program) {
40
47
  Current version of @public-ui/components: ${versionOfPublicUiComponents}
41
48
  Source folder to migrate: ${baseDir}
42
49
  `);
50
+ if (!options.ignoreGreaterVersion && semver_1.default.lt(versionOfPublicUiKoliBriCli, versionOfPublicUiComponents)) {
51
+ 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.');
52
+ }
43
53
  const configFile = path_1.default.resolve(process.cwd(), '.kolibri.config.json');
44
54
  let config = {};
45
55
  if (fs_1.default.existsSync(configFile)) {
@@ -51,48 +61,125 @@ Source folder to migrate: ${baseDir}
51
61
  }
52
62
  }
53
63
  const runner = new task_runner_1.TaskRunner(baseDir, versionOfPublicUiKoliBriCli, versionOfPublicUiComponents, config);
64
+ runner.registerTasks(tasks_1.commonTasks);
54
65
  runner.registerTasks(v1_1.v1Tasks);
66
+ runner.registerTasks((0, assets_1.getAssetTasks)(baseDir));
55
67
  if (options.testTasks) {
56
68
  runner.registerTasks(test_1.testTasks);
57
69
  }
58
70
  let version = versionOfPublicUiComponents;
71
+ /**
72
+ * Creates a replacer function for the package.json file.
73
+ * @param version The version to replace
74
+ * @returns The replacer function
75
+ */
76
+ function createVersionReplacer(version) {
77
+ return (...args) => {
78
+ if (args[1] === '@public-ui/kolibri-cli') {
79
+ return `"${args[1]}": "${args[2]}"`;
80
+ }
81
+ return `"${args[1]}": "${version}"`;
82
+ };
83
+ }
84
+ /**
85
+ * Sets the version of the @public-ui/* packages in the package.json file.
86
+ * @param version Version to set
87
+ * @param cb Callback function
88
+ */
89
+ function setVersionOfPublicUiPackages(version, cb) {
90
+ let packageJson = (0, reuse_1.getContentOfProjectPkgJson)();
91
+ packageJson = packageJson.replace(/"(@public-ui\/[^"]+)":\s*"(.*)"/g, createVersionReplacer(version));
92
+ fs_1.default.writeFileSync(path_1.default.resolve(process.cwd(), 'package.json'), packageJson);
93
+ runner.setProjectVersion(version);
94
+ console.log(`- Update @public-ui/* to version ${version}`);
95
+ (0, child_process_1.exec)((0, reuse_1.getPackageManagerCommand)('install'), (err) => {
96
+ if (err) {
97
+ console.error(`exec error: ${err.message}`);
98
+ return;
99
+ }
100
+ cb();
101
+ });
102
+ }
59
103
  /**
60
104
  * Runs the task runner in a loop until all tasks are completed.
61
105
  */
62
106
  function runLoop() {
63
107
  runner.run();
64
108
  if (version !== runner.getPendingMinVersion()) {
109
+ // Tasks
65
110
  version = runner.getPendingMinVersion();
66
- let packageJson = (0, reuse_1.getContentOfProjectPkgJson)();
67
- packageJson = packageJson.replace(/"(@public-ui\/[^"]+)":\s*".*"/g, `"$1": "${version}"`);
68
- fs_1.default.writeFileSync(path_1.default.resolve(process.cwd(), 'package.json'), packageJson);
69
- runner.setProjectVersion(version);
70
- console.log(`- Update @public-ui/* to version ${version}`);
71
- (0, child_process_1.exec)((0, reuse_1.getPackageManagerInstallCommand)(), (err) => {
72
- if (err) {
73
- console.error(`exec error: ${err.message}`);
74
- return;
75
- }
76
- runLoop();
77
- });
111
+ setVersionOfPublicUiPackages(version, runLoop);
112
+ }
113
+ else if (semver_1.default.lt(version, versionOfPublicUiKoliBriCli)) {
114
+ // CLI
115
+ version = versionOfPublicUiKoliBriCli;
116
+ setVersionOfPublicUiPackages(version, finish);
117
+ }
118
+ else if (semver_1.default.lt(version, versionOfPublicUiComponents)) {
119
+ // Components
120
+ version = versionOfPublicUiComponents;
121
+ setVersionOfPublicUiPackages(version, finish);
78
122
  }
79
123
  else {
80
- console.log(`
124
+ finish();
125
+ }
126
+ }
127
+ /**
128
+ * Prints the status of the task runner and the modified files.
129
+ */
130
+ function finish() {
131
+ console.log(`
81
132
  Status of all executed Tasks:`);
82
- const status = runner.getStatus(true);
83
- fs_1.default.writeFileSync(configFile, JSON.stringify(status.config, null, 2));
84
- console.log(`
133
+ const status = runner.getStatus(true);
134
+ fs_1.default.writeFileSync(configFile, JSON.stringify(status.config, null, 2));
135
+ console.log(`
85
136
  Modified files: ${reuse_1.MODIFIED_FILES.size}`);
86
- reuse_1.MODIFIED_FILES.forEach((file) => {
87
- console.log(`- ${file}`);
88
- });
137
+ reuse_1.MODIFIED_FILES.forEach((file) => {
138
+ console.log(`- ${file}`);
139
+ });
140
+ if (reuse_1.MODIFIED_FILES.size > 0 && options.format) {
141
+ console.log(`
142
+ We try to format the modified files with prettier...`);
143
+ try {
144
+ node_child_process_1.default.execFileSync('npx', ['prettier', '-w', ...Array.from(reuse_1.MODIFIED_FILES)], {
145
+ encoding: 'utf-8',
146
+ });
147
+ console.log(`Modified files have been formatted.`);
148
+ }
149
+ catch (e) {
150
+ console.log(`Modified files could not be formatted. Please format them manually: npx prettier ${baseDir} -w`);
151
+ }
152
+ console.log();
153
+ }
154
+ console.log(chalk_1.default.cyan(`
155
+ ${chalk_1.default.bold.bgCyan(`The migration is complete.`)} Please check the modified files and commit them if necessary.`));
156
+ if (reuse_1.POST_MESSAGES.size > 0) {
89
157
  console.log(`
90
- After the code migration has gone through, the code formatting may no longer be as desired. Therefore, please reformat your code afterwards if necessary.
158
+ ${chalk_1.default.bold.bgYellow(`Additional information:`)}`);
159
+ reuse_1.POST_MESSAGES.forEach((message) => {
160
+ switch (message.type) {
161
+ case 'error':
162
+ console.log(chalk_1.default.red(`- ${message.message}`));
163
+ break;
164
+ case 'warn':
165
+ console.log(chalk_1.default.yellow(`- ${message.message}`));
166
+ break;
167
+ default:
168
+ console.log(chalk_1.default.blue(`- ${message.message}`));
169
+ break;
170
+ }
171
+ });
172
+ }
173
+ console.log(chalk_1.default.magenta(`
174
+ Despite the best possible preparation of migration steps, we will certainly not be able to fully migrate every individual source code in the project. After running the migration tool, please see where you may still need to help yourself and feel free to provide feedback on what we can improve.
91
175
 
92
- Afterwards, it may be that functions or themes in newer major versions have changed or are no longer included. This should be checked finally and corrected manually if necessary.
176
+ After all the changes are made, the modified files are formatted using Prettier.
93
177
 
94
- Is anything wrong, you can reset the migration with "git reset --hard HEAD~1" or by discarding the affected files. For more information read the troubleshooting section in the README.`);
95
- }
178
+ When migrating the labels, the text (innerText) is assigned 1 to 1 to the _label property. There could be the following situation, where manual corrections have to be made: ${chalk_1.default.italic.white(`_label={\`I am {count} years old.\`}`)} -> ${chalk_1.default.italic.white(`_label={\`I am \${count} years old.\`}`)} (add a $)
179
+
180
+ Afterwards, it may be that functions or themes have changed or are no longer included in newer major versions. This should be checked finally and corrected manually if necessary.
181
+
182
+ If something is wrong, the migration can be reverted with ${chalk_1.default.italic.white(`git reset --hard HEAD~1`)} or by discarding the affected files. For more information, read the troubleshooting section in the README.`));
96
183
  }
97
184
  const status = runner.getStatus();
98
185
  console.log(`
@@ -9,6 +9,7 @@ const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const semver_1 = __importDefault(require("semver"));
11
11
  const reuse_1 = require("../shares/reuse");
12
+ const MIN_VERSION_OF_PUBLIC_UI = '1.4.2';
12
13
  class TaskRunner {
13
14
  constructor(baseDir, cliVersion, projectVersion, config) {
14
15
  this.tasks = new Map();
@@ -53,12 +54,22 @@ class TaskRunner {
53
54
  }
54
55
  registerTasks(tasks) {
55
56
  tasks.forEach((task) => {
57
+ const dependentTasks = task.getDependentTasks();
58
+ if (dependentTasks.length > 0) {
59
+ this.registerTasks(dependentTasks);
60
+ }
56
61
  if (semver_1.default.gtr(this.projectVersion, task.getVersionRange(), {
57
62
  includePrerelease: true,
58
63
  })) {
59
64
  console.log(`Task "${task.getTitle()}" will be excluded. The current version (${this.projectVersion}) is greater than the task version range (${task.getVersionRange()}).`);
60
65
  this.config.migrate.tasks[task.getIdentifier()] = false;
61
66
  }
67
+ else if (semver_1.default.ltr(this.cliVersion, task.getVersionRange(), {
68
+ includePrerelease: true,
69
+ })) {
70
+ console.log(`Task "${task.getTitle()}" will be excluded. The target version (${this.cliVersion}) is lower than the task version range (${task.getVersionRange()}).`);
71
+ this.config.migrate.tasks[task.getIdentifier()] = false;
72
+ }
62
73
  else {
63
74
  this.tasks.set(task.getIdentifier(), task);
64
75
  }
@@ -101,6 +112,7 @@ class TaskRunner {
101
112
  });
102
113
  }
103
114
  getPendingMinVersion() {
115
+ var _a;
104
116
  let version = this.cliVersion;
105
117
  this.tasks.forEach((task) => {
106
118
  var _a, _b;
@@ -111,7 +123,7 @@ class TaskRunner {
111
123
  }
112
124
  }
113
125
  });
114
- return version;
126
+ return (_a = semver_1.default.maxSatisfying([version], `>=${MIN_VERSION_OF_PUBLIC_UI}`)) !== null && _a !== void 0 ? _a : MIN_VERSION_OF_PUBLIC_UI;
115
127
  }
116
128
  getStatus(outline = false) {
117
129
  let done = 0;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecTask = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const abstract_task_1 = require("../../abstract-task");
6
+ class ExecTask extends abstract_task_1.AbstractTask {
7
+ constructor(identifier, title, command, versionRange, dependentTasks, options) {
8
+ super(identifier, title, [], versionRange, dependentTasks, options);
9
+ this.command = command;
10
+ }
11
+ static getInstance(command, versionRange, dependentTasks = [], options = {}) {
12
+ const identifier = `exec-${command}`;
13
+ const title = `Exec ${command}.`;
14
+ if (!this.instances.has(identifier)) {
15
+ this.instances.set(identifier, new ExecTask(identifier, title, command, versionRange, dependentTasks, options));
16
+ }
17
+ return this.instances.get(identifier);
18
+ }
19
+ run() {
20
+ try {
21
+ (0, child_process_1.execSync)(this.command, {
22
+ encoding: 'utf8',
23
+ });
24
+ }
25
+ catch (error) {
26
+ console.warn(error);
27
+ }
28
+ }
29
+ }
30
+ exports.ExecTask = ExecTask;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GenericRenameSlotNameTask = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const types_1 = require("../../../../types");
9
+ const reuse_1 = require("../../../shares/reuse");
10
+ const abstract_task_1 = require("../../abstract-task");
11
+ class GenericRenameSlotNameTask extends abstract_task_1.AbstractTask {
12
+ constructor(identifier, description, tag, oldSlotName, newSlotName, slotAttributeName, versionRange, dependentTasks, options) {
13
+ super(identifier, description, types_1.MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
14
+ this.newSlotName = newSlotName;
15
+ this.slotAttributeName = slotAttributeName;
16
+ if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
17
+ throw (0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
18
+ }
19
+ if (!reuse_1.isKebabCaseRegExp.test(oldSlotName)) {
20
+ throw (0, reuse_1.logAndCreateError)(`Slot name "${oldSlotName}" is not in kebab case.`);
21
+ }
22
+ if (!reuse_1.isKebabCaseRegExp.test(newSlotName)) {
23
+ throw (0, reuse_1.logAndCreateError)(`New slot name "${newSlotName}" is not in kebab case.`);
24
+ }
25
+ this.regExpCurlyBrackets = new RegExp(`(data-removed-)*slot=\\{'${oldSlotName}'\\}`, 'g');
26
+ this.regExpQuotationMarks = new RegExp(`(data-removed-)*slot="${oldSlotName}"`, 'g');
27
+ this.regExpCurlyBracketsAndQuotationMarks = new RegExp(`(data-removed-)*slot=\\{"${oldSlotName}"\\}`, 'g');
28
+ }
29
+ run(baseDir) {
30
+ (0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
31
+ const content = fs_1.default.readFileSync(file, 'utf8');
32
+ const newContent = content
33
+ // Replacements
34
+ .replace(this.regExpCurlyBrackets, `${this.slotAttributeName}="${this.newSlotName}"`)
35
+ .replace(this.regExpQuotationMarks, `${this.slotAttributeName}="${this.newSlotName}"`)
36
+ .replace(this.regExpCurlyBracketsAndQuotationMarks, `${this.slotAttributeName}="${this.newSlotName}"`);
37
+ if (content !== newContent) {
38
+ reuse_1.MODIFIED_FILES.add(file);
39
+ fs_1.default.writeFileSync(file, newContent);
40
+ }
41
+ });
42
+ }
43
+ }
44
+ exports.GenericRenameSlotNameTask = GenericRenameSlotNameTask;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GitIgnoreAddRuleTask = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const reuse_1 = require("../../../shares/reuse");
10
+ const abstract_task_1 = require("../../abstract-task");
11
+ class GitIgnoreAddRuleTask extends abstract_task_1.AbstractTask {
12
+ constructor(identifier, rule, versionRange, dependentTasks = [], options = {}) {
13
+ super(identifier, `Add the rule "${rule}" to the .gitignore of your project.`, [], versionRange, dependentTasks, options);
14
+ this.rule = rule;
15
+ if (typeof rule !== 'string') {
16
+ throw (0, reuse_1.logAndCreateError)(`Definition of task "${this.identifier}" is not a string.`);
17
+ }
18
+ }
19
+ static getInstance(rule, versionRange, dependentTasks = [], options = {}) {
20
+ const identifier = `.gitignore-add-rule-${rule}`;
21
+ if (!this.instances.has(identifier)) {
22
+ this.instances.set(identifier, new GitIgnoreAddRuleTask(identifier, rule, versionRange, dependentTasks, options));
23
+ }
24
+ return this.instances.get(identifier);
25
+ }
26
+ run() {
27
+ const gitignorePath = path_1.default.join(process.cwd(), '.gitignore');
28
+ const lineToAdd = this.rule.trim();
29
+ if (!fs_1.default.existsSync(gitignorePath)) {
30
+ fs_1.default.writeFileSync(gitignorePath, lineToAdd + '\n');
31
+ }
32
+ else {
33
+ const fileContent = fs_1.default.readFileSync(gitignorePath, 'utf8');
34
+ if (!fileContent.split('\n').includes(lineToAdd)) {
35
+ fs_1.default.appendFileSync(gitignorePath, '\n' + lineToAdd);
36
+ }
37
+ }
38
+ }
39
+ }
40
+ exports.GitIgnoreAddRuleTask = GitIgnoreAddRuleTask;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HandleDependencyTask = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const abstract_task_1 = require("../../abstract-task");
6
+ const reuse_1 = require("../../../shares/reuse");
7
+ class HandleDependencyTask extends abstract_task_1.AbstractTask {
8
+ constructor(identifier, title, command, dependencies, // Map<string, string | null>
9
+ devDependencies, // Map<string, string | null>
10
+ versionRange, dependentTasks, options) {
11
+ super(identifier, title, [], versionRange, dependentTasks, options);
12
+ this.command = command;
13
+ this.dependencies = dependencies;
14
+ this.devDependencies = devDependencies;
15
+ }
16
+ static getInstance(command, dependencies, devDependencies, versionRange, dependentTasks = [], options = {}) {
17
+ const identifier = `${command}-${Object.keys(dependencies !== null && dependencies !== void 0 ? dependencies : {}).join(',')}-${Object.keys(devDependencies !== null && devDependencies !== void 0 ? devDependencies : {}).join(',')}`;
18
+ const title = `${command === 'add' ? 'Add' : command === 'install' ? 'Install' : 'Remove'} dependency "${Object.keys(dependencies !== null && dependencies !== void 0 ? dependencies : {}).join(', ')}" and devDependency "${Object.keys(devDependencies !== null && devDependencies !== void 0 ? devDependencies : {}).join(', ')}".`;
19
+ if (!this.instances.has(identifier)) {
20
+ this.instances.set(identifier, new HandleDependencyTask(identifier, title, command, dependencies, devDependencies, versionRange, dependentTasks, options));
21
+ }
22
+ return this.instances.get(identifier);
23
+ }
24
+ run() {
25
+ var _a, _b, _c, _d;
26
+ if (Object.keys((_a = this.dependencies) !== null && _a !== void 0 ? _a : {}).length > 0) {
27
+ let command = `${(0, reuse_1.getPackageManagerCommand)(this.command)}`;
28
+ Object.keys((_b = this.dependencies) !== null && _b !== void 0 ? _b : {}).forEach((dependency) => {
29
+ command += ` ${dependency}@${this.dependencies[dependency]}`;
30
+ });
31
+ try {
32
+ (0, child_process_1.execSync)(command, {
33
+ encoding: 'utf8',
34
+ });
35
+ }
36
+ catch (error) {
37
+ console.warn(error);
38
+ }
39
+ }
40
+ if (Object.keys((_c = this.devDependencies) !== null && _c !== void 0 ? _c : {}).length > 0) {
41
+ let command = `${(0, reuse_1.getPackageManagerCommand)(this.command)} -D`;
42
+ Object.keys((_d = this.devDependencies) !== null && _d !== void 0 ? _d : {}).forEach((dependency) => {
43
+ command += ` ${dependency}`;
44
+ });
45
+ try {
46
+ (0, child_process_1.execSync)(command, {
47
+ encoding: 'utf8',
48
+ });
49
+ }
50
+ catch (error) {
51
+ console.warn(error);
52
+ }
53
+ }
54
+ }
55
+ }
56
+ exports.HandleDependencyTask = HandleDependencyTask;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JsonTask = void 0;
7
+ const deepmerge_1 = __importDefault(require("deepmerge"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const reuse_1 = require("../../../shares/reuse");
11
+ const abstract_task_1 = require("../../abstract-task");
12
+ class JsonTask extends abstract_task_1.AbstractTask {
13
+ constructor(identifier, key, json, versionRange, dependentTasks = [], options = {}) {
14
+ super(identifier, `Reconfigure "${key}" in package.json of your project.`, [], versionRange, dependentTasks, options);
15
+ this.json = json;
16
+ if (typeof key !== 'string') {
17
+ throw (0, reuse_1.logAndCreateError)(`Key of task "${this.identifier}" is not a string.`);
18
+ }
19
+ try {
20
+ JSON.stringify(json);
21
+ }
22
+ catch (_a) {
23
+ throw (0, reuse_1.logAndCreateError)(`Value of task "${this.identifier}" is not able to stringify (JSON).`);
24
+ }
25
+ }
26
+ static getInstance(key, json, versionRange, dependentTasks = [], options = {}) {
27
+ const identifier = `package.json-reconfigure-${key}`;
28
+ if (!this.instances.has(identifier)) {
29
+ this.instances.set(identifier, new JsonTask(identifier, key, json, versionRange, dependentTasks, options));
30
+ }
31
+ return this.instances.get(identifier);
32
+ }
33
+ run() {
34
+ const configPath = path_1.default.join(process.cwd(), 'package.json');
35
+ if (fs_1.default.existsSync(configPath)) {
36
+ try {
37
+ const fileContent = (0, deepmerge_1.default)(JSON.parse(fs_1.default.readFileSync(configPath, 'utf8')), this.json);
38
+ fs_1.default.writeFileSync(configPath, JSON.stringify(fileContent, null, 2));
39
+ reuse_1.MODIFIED_FILES.add(configPath);
40
+ }
41
+ catch (e) {
42
+ // empty
43
+ }
44
+ }
45
+ }
46
+ }
47
+ exports.JsonTask = JsonTask;