@public-ui/kolibri-cli 1.7.0-rc.1 → 1.7.0-rc.11
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 +41 -16
- package/dist/index.js +7 -5
- package/dist/migrate/index.js +16 -18
- package/dist/migrate/runner/abstract-task.js +2 -1
- package/dist/migrate/runner/task-runner.js +19 -8
- package/dist/migrate/runner/tasks/common/GenericRenamePropertyTask.js +9 -11
- package/dist/migrate/runner/tasks/common/GenericRenameSlotNameTask.js +44 -0
- package/dist/migrate/runner/tasks/common/GitIgnoreAddRuleTask.js +40 -0
- package/dist/migrate/runner/tasks/common/LabelExpertSlot.js +68 -0
- package/dist/migrate/runner/tasks/common/MarkRemovedSlotTask.js +17 -0
- package/dist/migrate/runner/tasks/common/RemovePropertyNameTask.js +8 -7
- package/dist/migrate/runner/tasks/common/RenamePropertyNameTask.js +1 -4
- package/dist/migrate/runner/tasks/common/RenameSlotNameTask.js +17 -0
- package/dist/migrate/runner/tasks/common/TsConfigReconfigureTask.js +48 -0
- package/dist/migrate/runner/tasks/common/VsCodeSettingsReconfigureTask.js +49 -0
- package/dist/migrate/runner/tasks/index.js +12 -16
- package/dist/migrate/runner/tasks/test/index.js +4 -10
- package/dist/migrate/runner/tasks/test/test-version-next-99.js +10 -0
- package/dist/migrate/runner/tasks/v1/index.js +29 -1
- package/dist/migrate/runner/tasks/v1/input-number.js +1 -1
- package/dist/migrate/runner/tasks/v1/link-group.js +3 -2
- package/dist/migrate/runner/tasks/v1/split-button.js +3 -1
- package/dist/migrate/runner/tasks/v1/toast.js +3 -1
- package/dist/migrate/shares/reuse.js +70 -10
- package/dist/migrate/types.js +4 -0
- package/dist/types.js +2 -1
- package/package.json +17 -14
- package/dist/migrate/runner/tasks/test/test-version-next-2.js +0 -10
- package/dist/migrate/runner/tasks/test/test-version-next-3.js +0 -10
- package/dist/migrate/runner/tasks/test-tasks.js +0 -12
- package/dist/migrate/runner/tasks/v1/abbr-property-renaming-title-to-label.js +0 -30
- package/dist/migrate/runner/tasks/v1/accordion-property-renaming-heading-to-label.js +0 -30
- package/dist/migrate/runner/tasks/v1/test-version-1.3.js +0 -17
- package/dist/migrate/runner/tasks/v1/test-version-current.js +0 -17
- package/dist/migrate/runner/tasks/v1/test-version-next-2.js +0 -17
- package/dist/migrate/runner/tasks/v1/test-version-next-3.js +0 -17
- package/dist/migrate/runner/tasks/v1/test-version-zero.js +0 -17
- package/dist/runner/abstract-task.js +0 -48
- package/dist/runner/task-runner.js +0 -28
- package/dist/runner/tasks/abbr-property-renaming-title-to-label.js +0 -27
- package/dist/runner/tasks/index.js +0 -6
- package/dist/runner/types.js +0 -4
- package/dist/shares/reuse.js +0 -48
package/README.md
CHANGED
|
@@ -16,12 +16,33 @@ yarn add -g @public-ui/kolibri-cli
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
Use the `kolibri` command to start the CLI.
|
|
19
|
+
The `KoliBri` CLI is intended to be executed in your project root directory. Use the `kolibri` command to start the CLI.
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
kolibri --help
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
```bash
|
|
26
|
+
,--. ,--. ,--. ,--. ,-----. ,--.
|
|
27
|
+
| .' / ,---. | | `--' | |) /_ ,--.--. `--'
|
|
28
|
+
| . ' | .-. | | | ,--. | .-. \ | .--' ,--.
|
|
29
|
+
| |\ \ | '-' | | | | | | '--' / | | | |
|
|
30
|
+
`--' `--´ `---´ `--' `--' `------´ `--' `--'
|
|
31
|
+
🚹 The accessible HTML-Standard | 👉 https://public-ui.github.io
|
|
32
|
+
|
|
33
|
+
Usage: kolibri [options] [command]
|
|
34
|
+
|
|
35
|
+
CLI for executing some helpful commands for KoliBri projects.
|
|
36
|
+
|
|
37
|
+
Options:
|
|
38
|
+
-V, --version output the version number
|
|
39
|
+
-h, --help display help for command
|
|
40
|
+
|
|
41
|
+
Commands:
|
|
42
|
+
migrate [options] <string> This command migrates KoliBri code to the current version.
|
|
43
|
+
help [command] display help for command
|
|
44
|
+
```
|
|
45
|
+
|
|
25
46
|
### Migrate
|
|
26
47
|
|
|
27
48
|
With the `migrate` command you can migrate your project to the latest version of `KoliBri`.
|
|
@@ -29,25 +50,27 @@ With the `migrate` command you can migrate your project to the latest version of
|
|
|
29
50
|
Actually the following migrations are available:
|
|
30
51
|
|
|
31
52
|
- Component renaming ✓
|
|
32
|
-
- Component removal
|
|
53
|
+
- Component removal (no one yet)
|
|
33
54
|
- Property renaming ✓
|
|
34
55
|
- Property removal ✓
|
|
35
|
-
- Property type change ⏰
|
|
36
|
-
-
|
|
56
|
+
- Property type change (`_label={false}`) ⏰
|
|
57
|
+
- Slots renaming (`content`) ✓
|
|
58
|
+
- Slots removal (`footer`, `header`) ✓
|
|
59
|
+
- Logic refactoring (no one yet)
|
|
37
60
|
- Expert-Slot refactoring ⏰
|
|
38
|
-
- `.vscode/settings.json` add IntelliSense for HTML
|
|
39
|
-
- `.gitignore` exclude `.kolibri.migrate.json`
|
|
40
|
-
- `.tsconfig` add `@public-ui/components` to `types` array
|
|
61
|
+
- `.vscode/settings.json` add IntelliSense for HTML ✓
|
|
62
|
+
- `.gitignore` exclude `.kolibri.migrate.json` ✓
|
|
63
|
+
- `.tsconfig` add `@public-ui/components` to `types` array ✓
|
|
41
64
|
|
|
42
65
|
#### How does it work?
|
|
43
66
|
|
|
44
|
-
1. The migration command will check your project for clear `git history` and the `installed version` of `KoliBri`. Now it
|
|
45
|
-
2.
|
|
67
|
+
1. The migration command will check your project for clear `git history` and the `installed version` of `KoliBri`. Now it loads all available migration tasks.
|
|
68
|
+
2. Tasks in the correct version range will be executed one by one. Otherwise they will be skipped.
|
|
46
69
|
3. After that the `package.json` will be updated with the new version of `KoliBri` and execute the `npm install` command.
|
|
47
|
-
4.
|
|
70
|
+
4. If there are any pending tasks, the migration command will be executed again. Otherwise the migration is finished.
|
|
48
71
|
5. Now you can check the result and commit the changes.
|
|
49
72
|
|
|
50
|
-
> **Note:** You can reset the migration with `git reset --hard HEAD~1
|
|
73
|
+
> **Note:** You can reset the migration with `git reset --hard HEAD~1` or by discarding the affected files.
|
|
51
74
|
|
|
52
75
|
#### Help
|
|
53
76
|
|
|
@@ -63,10 +86,10 @@ kolibri migrate <path>
|
|
|
63
86
|
|
|
64
87
|
#### Options
|
|
65
88
|
|
|
66
|
-
| Option | Description
|
|
67
|
-
| ------------------------------ |
|
|
68
|
-
| `--ignore-uncommitted-changes` | Allows execution with uncommitted changes
|
|
69
|
-
| `--remove-mode` |
|
|
89
|
+
| Option | Description | Type | Default |
|
|
90
|
+
| ------------------------------ | ----------------------------------------- | :------------------: | :------: |
|
|
91
|
+
| `--ignore-uncommitted-changes` | Allows execution with uncommitted changes | boolean | false |
|
|
92
|
+
| `--remove-mode` | Prefix property name or delete property | `delete` \| `prefix` | `prefix` |
|
|
70
93
|
|
|
71
94
|
#### Configuration
|
|
72
95
|
|
|
@@ -132,6 +155,8 @@ If the migration failed, you can reset the migration with `git reset --hard HEAD
|
|
|
132
155
|
|
|
133
156
|
Use the configuration (`.kolibri.config.json`) to exclude some tasks.
|
|
134
157
|
|
|
158
|
+
If there are multiple obsolete properties that have been migrated to just one new property, the new property may appear multiple times in the tag. You can then decide which variant to use and remove all other variants accordingly.
|
|
159
|
+
|
|
135
160
|
Maybe it can help to prepare your code in the tricky places for migration.
|
|
136
161
|
|
|
137
162
|
Please give us feedback, if you have problems with the migration: [GitHub Issues](https://github.com/public-ui/kolibri/issues/new?assignees=&labels=useful+hint&projects=&template=7_feedback.md&title=%F0%9F%92%A1+CLI%3A+)
|
|
@@ -142,4 +167,4 @@ You have always the possibility of a dry run. Because before the migration will
|
|
|
142
167
|
|
|
143
168
|
After the migration you can check the result with `git status` and `git diff`.
|
|
144
169
|
|
|
145
|
-
Is anything wrong, you can reset the migration with `git reset --hard HEAD~1
|
|
170
|
+
Is anything wrong, you can reset the migration with `git reset --hard HEAD~1` or by discarding the affected files.
|
package/dist/index.js
CHANGED
|
@@ -5,21 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
const migrate_1 = __importDefault(require("./migrate"));
|
|
9
8
|
const gradient_string_1 = __importDefault(require("gradient-string"));
|
|
10
|
-
const
|
|
9
|
+
const migrate_1 = __importDefault(require("./migrate"));
|
|
10
|
+
const reuse_1 = require("./migrate/shares/reuse");
|
|
11
|
+
const versionOfPublicUiKoliBriCli = (0, reuse_1.getVersionOfPublicUiKoliBriCli)();
|
|
12
|
+
const banner = gradient_string_1.default.atlas.multiline(`
|
|
11
13
|
,--. ,--. ,--. ,--. ,-----. ,--.
|
|
12
14
|
| .' / ,---. | | \`--' | |) /_ ,--.--. \`--'
|
|
13
15
|
| . ' | .-. | | | ,--. | .-. \\ | .--' ,--.
|
|
14
16
|
| |\\ \\ | '-' | | | | | | '--' / | | | |
|
|
15
17
|
\`--' \`--´ \`---´ \`--' \`--' \`------´ \`--' \`--'
|
|
16
|
-
🚹 The accessible HTML-Standard | 👉 https://public-ui.github.io |
|
|
18
|
+
🚹 The accessible HTML-Standard | 👉 https://public-ui.github.io | ${versionOfPublicUiKoliBriCli}
|
|
17
19
|
`, {
|
|
18
20
|
interpolation: 'hsv',
|
|
19
21
|
});
|
|
20
|
-
console.log(
|
|
22
|
+
console.log(banner);
|
|
21
23
|
const program = new commander_1.Command();
|
|
22
|
-
program.name('kolibri').description('CLI for executing some helpful commands for KoliBri projects.').version(
|
|
24
|
+
program.name('kolibri').description('CLI for executing some helpful commands for KoliBri projects.').version(versionOfPublicUiKoliBriCli);
|
|
23
25
|
// Add commands
|
|
24
26
|
(0, migrate_1.default)(program);
|
|
25
27
|
program.parse();
|
package/dist/migrate/index.js
CHANGED
|
@@ -11,6 +11,8 @@ const task_runner_1 = require("./runner/task-runner");
|
|
|
11
11
|
const test_1 = require("./runner/tasks/test");
|
|
12
12
|
const v1_1 = require("./runner/tasks/v1");
|
|
13
13
|
const reuse_1 = require("./shares/reuse");
|
|
14
|
+
const types_1 = require("./types");
|
|
15
|
+
const tasks_1 = require("./runner/tasks");
|
|
14
16
|
/**
|
|
15
17
|
* This function is used to register the migrate command.
|
|
16
18
|
* @param {Command} program The program object to register the command
|
|
@@ -19,10 +21,10 @@ function default_1(program) {
|
|
|
19
21
|
program
|
|
20
22
|
.command('migrate')
|
|
21
23
|
.description('This command migrates KoliBri code to the current version.')
|
|
22
|
-
.argument('
|
|
23
|
-
.
|
|
24
|
-
.addOption(new commander_1.Option('--remove-mode <mode>', '
|
|
25
|
-
.
|
|
24
|
+
.argument('[string]', 'Source code folder to migrate', 'src')
|
|
25
|
+
.addOption(new commander_1.Option('--ignore-uncommitted-changes', 'Allows execution with uncommitted changes').default(false))
|
|
26
|
+
.addOption(new commander_1.Option('--remove-mode <mode>', 'Prefix property name or delete property').choices(types_1.REMOVE_MODE).default('prefix'))
|
|
27
|
+
.addOption(new commander_1.Option('--test-tasks', 'Run additional test tasks').default(false).hideHelp())
|
|
26
28
|
.action((baseDir, options) => {
|
|
27
29
|
(0, child_process_1.exec)('git status --porcelain', (err, stdout) => {
|
|
28
30
|
if (err) {
|
|
@@ -30,11 +32,11 @@ function default_1(program) {
|
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
34
|
if (!options.ignoreUncommittedChanges && stdout) {
|
|
33
|
-
throw
|
|
35
|
+
throw (0, reuse_1.logAndCreateError)('There are uncommitted changes');
|
|
34
36
|
}
|
|
35
37
|
(0, reuse_1.setRemoveMode)(options.removeMode);
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
+
const versionOfPublicUiComponents = (0, reuse_1.getVersionOfPublicUiComponents)();
|
|
39
|
+
const versionOfPublicUiKoliBriCli = (0, reuse_1.getVersionOfPublicUiKoliBriCli)();
|
|
38
40
|
console.log(`
|
|
39
41
|
Current version of @public-ui/components: ${versionOfPublicUiComponents}
|
|
40
42
|
Source folder to migrate: ${baseDir}
|
|
@@ -50,6 +52,7 @@ Source folder to migrate: ${baseDir}
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
const runner = new task_runner_1.TaskRunner(baseDir, versionOfPublicUiKoliBriCli, versionOfPublicUiComponents, config);
|
|
55
|
+
runner.registerTasks(tasks_1.commonTasks);
|
|
53
56
|
runner.registerTasks(v1_1.v1Tasks);
|
|
54
57
|
if (options.testTasks) {
|
|
55
58
|
runner.registerTasks(test_1.testTasks);
|
|
@@ -62,7 +65,7 @@ Source folder to migrate: ${baseDir}
|
|
|
62
65
|
runner.run();
|
|
63
66
|
if (version !== runner.getPendingMinVersion()) {
|
|
64
67
|
version = runner.getPendingMinVersion();
|
|
65
|
-
let packageJson = (0, reuse_1.
|
|
68
|
+
let packageJson = (0, reuse_1.getContentOfProjectPkgJson)();
|
|
66
69
|
packageJson = packageJson.replace(/"(@public-ui\/[^"]+)":\s*".*"/g, `"$1": "${version}"`);
|
|
67
70
|
fs_1.default.writeFileSync(path_1.default.resolve(process.cwd(), 'package.json'), packageJson);
|
|
68
71
|
runner.setProjectVersion(version);
|
|
@@ -77,7 +80,7 @@ Source folder to migrate: ${baseDir}
|
|
|
77
80
|
}
|
|
78
81
|
else {
|
|
79
82
|
console.log(`
|
|
80
|
-
|
|
83
|
+
Status of all executed Tasks:`);
|
|
81
84
|
const status = runner.getStatus(true);
|
|
82
85
|
fs_1.default.writeFileSync(configFile, JSON.stringify(status.config, null, 2));
|
|
83
86
|
console.log(`
|
|
@@ -86,21 +89,16 @@ Modified files: ${reuse_1.MODIFIED_FILES.size}`);
|
|
|
86
89
|
console.log(`- ${file}`);
|
|
87
90
|
});
|
|
88
91
|
console.log(`
|
|
89
|
-
After the code migration has gone through, the code formatting may no longer
|
|
90
|
-
be as desired. Therefore, please reformat your code afterwards if necessary.
|
|
92
|
+
After the code migration has gone through, the code formatting may no longer be as desired. Therefore, please reformat your code afterwards if necessary.
|
|
91
93
|
|
|
92
|
-
Afterwards, it may be that functions or themes in newer major versions have
|
|
93
|
-
changed or are no longer included. This should be checked finally and corrected
|
|
94
|
-
manually if necessary.
|
|
94
|
+
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.
|
|
95
95
|
|
|
96
|
-
Is anything wrong, you can reset the migration with "git reset --hard HEAD~1"
|
|
97
|
-
read the troubleshooting section in the readme.
|
|
98
|
-
`);
|
|
96
|
+
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.`);
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
const status = runner.getStatus();
|
|
102
100
|
console.log(`
|
|
103
|
-
|
|
101
|
+
Execute ${status.total} registered tasks...`);
|
|
104
102
|
runLoop();
|
|
105
103
|
});
|
|
106
104
|
});
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AbstractTask = void 0;
|
|
7
7
|
const semver_1 = __importDefault(require("semver"));
|
|
8
8
|
const types_1 = require("../../types");
|
|
9
|
+
const reuse_1 = require("../shares/reuse");
|
|
9
10
|
class AbstractTask {
|
|
10
11
|
constructor(identifier, title, extensions, versionRange, dependentTasks = [], options = {}) {
|
|
11
12
|
this.identifier = identifier;
|
|
@@ -17,7 +18,7 @@ class AbstractTask {
|
|
|
17
18
|
this.description = options.description;
|
|
18
19
|
this.extensions = this.extensions.filter((ext) => types_1.FILE_EXTENSIONS.includes(ext));
|
|
19
20
|
if (!semver_1.default.validRange(this.versionRange)) {
|
|
20
|
-
throw
|
|
21
|
+
throw (0, reuse_1.logAndCreateError)(`[${this.identifier}] Invalid semver range version: ${this.versionRange}`);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
getDependentTasks() {
|
|
@@ -4,16 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TaskRunner = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const semver_1 = __importDefault(require("semver"));
|
|
11
|
+
const reuse_1 = require("../shares/reuse");
|
|
10
12
|
class TaskRunner {
|
|
11
13
|
constructor(baseDir, cliVersion, projectVersion, config) {
|
|
12
14
|
this.tasks = new Map();
|
|
13
15
|
this.baseDir = '/';
|
|
14
16
|
this.cliVersion = '0.0.0';
|
|
15
17
|
this.projectVersion = '0.0.0';
|
|
16
|
-
this.openRun = true;
|
|
17
18
|
this.config = {
|
|
18
19
|
migrate: {
|
|
19
20
|
tasks: {},
|
|
@@ -26,23 +27,22 @@ class TaskRunner {
|
|
|
26
27
|
}
|
|
27
28
|
setBaseDir(baseDir) {
|
|
28
29
|
if (!fs_1.default.existsSync(path_1.default.resolve(process.cwd(), baseDir))) {
|
|
29
|
-
throw
|
|
30
|
+
throw (0, reuse_1.logAndCreateError)(`Base directory "${baseDir}" does not exist`);
|
|
30
31
|
}
|
|
31
32
|
this.baseDir = baseDir;
|
|
32
33
|
}
|
|
33
34
|
setCliVersion(version) {
|
|
34
35
|
if (semver_1.default.valid(version) === null) {
|
|
35
|
-
throw
|
|
36
|
+
throw (0, reuse_1.logAndCreateError)(`Invalid CLI version: ${version}`);
|
|
36
37
|
}
|
|
37
38
|
this.cliVersion = version;
|
|
38
39
|
}
|
|
39
40
|
setProjectVersion(version) {
|
|
40
41
|
if (semver_1.default.valid(version) === null) {
|
|
41
|
-
throw
|
|
42
|
+
throw (0, reuse_1.logAndCreateError)(`Invalid project version: ${version}`);
|
|
42
43
|
}
|
|
43
44
|
if (this.projectVersion !== version) {
|
|
44
45
|
this.projectVersion = version;
|
|
45
|
-
this.openRun = true;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
setConfig(config) {
|
|
@@ -59,12 +59,20 @@ class TaskRunner {
|
|
|
59
59
|
console.log(`Task "${task.getTitle()}" will be excluded. The current version (${this.projectVersion}) is greater than the task version range (${task.getVersionRange()}).`);
|
|
60
60
|
this.config.migrate.tasks[task.getIdentifier()] = false;
|
|
61
61
|
}
|
|
62
|
+
else if (semver_1.default.ltr(this.cliVersion, task.getVersionRange(), {
|
|
63
|
+
includePrerelease: true,
|
|
64
|
+
})) {
|
|
65
|
+
console.log(`Task "${task.getTitle()}" will be excluded. The target version (${this.cliVersion}) is lower than the task version range (${task.getVersionRange()}).`);
|
|
66
|
+
this.config.migrate.tasks[task.getIdentifier()] = false;
|
|
67
|
+
}
|
|
62
68
|
else {
|
|
63
69
|
this.tasks.set(task.getIdentifier(), task);
|
|
64
|
-
this.openRun = true;
|
|
65
70
|
}
|
|
66
71
|
});
|
|
67
72
|
}
|
|
73
|
+
registerTask(task) {
|
|
74
|
+
this.registerTasks([task]);
|
|
75
|
+
}
|
|
68
76
|
runTask(task) {
|
|
69
77
|
var _a;
|
|
70
78
|
if (((_a = this.config.migrate) === null || _a === void 0 ? void 0 : _a.tasks[task.getIdentifier()]) === false) {
|
|
@@ -77,6 +85,9 @@ class TaskRunner {
|
|
|
77
85
|
includePrerelease: true,
|
|
78
86
|
})) {
|
|
79
87
|
// task.setStatus('running'); only of the task is async
|
|
88
|
+
if (!this.tasks.has(task.getIdentifier())) {
|
|
89
|
+
this.registerTask(task);
|
|
90
|
+
}
|
|
80
91
|
task.run(this.baseDir);
|
|
81
92
|
task.setStatus('done');
|
|
82
93
|
}
|
|
@@ -94,7 +105,6 @@ class TaskRunner {
|
|
|
94
105
|
this.tasks.forEach((task) => {
|
|
95
106
|
this.dependentTaskRun(task, task.getDependentTasks());
|
|
96
107
|
});
|
|
97
|
-
this.openRun = false;
|
|
98
108
|
}
|
|
99
109
|
getPendingMinVersion() {
|
|
100
110
|
let version = this.cliVersion;
|
|
@@ -122,7 +132,8 @@ class TaskRunner {
|
|
|
122
132
|
break;
|
|
123
133
|
}
|
|
124
134
|
if (outline) {
|
|
125
|
-
|
|
135
|
+
const status = task.getStatus();
|
|
136
|
+
console.log(`- ${task.getTitle()}:`, status === 'done' ? chalk_1.default.green(status) : chalk_1.default.yellow(status));
|
|
126
137
|
}
|
|
127
138
|
});
|
|
128
139
|
return {
|
|
@@ -8,25 +8,23 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const types_1 = require("../../../../types");
|
|
9
9
|
const reuse_1 = require("../../../shares/reuse");
|
|
10
10
|
const abstract_task_1 = require("../../abstract-task");
|
|
11
|
-
const
|
|
12
|
-
const DATA_REMOVED_REGEXP = /DataRemoved_/g; // not /DataRemoved-_/g
|
|
11
|
+
const DATA_REMOVED_REGEXP = /DataRemoved_/gi; // not /DataRemoved-_/g
|
|
13
12
|
const DATA_REMOVEDS_REGEXP = /(data-removed-){2,}/g;
|
|
14
13
|
class GenericRenamePropertyTask extends abstract_task_1.AbstractTask {
|
|
15
14
|
constructor(identifier, description, tag, oldProperty, newProperty, versionRange, dependentTasks = [], options = {}) {
|
|
16
|
-
super(identifier, description,
|
|
15
|
+
super(identifier, description, types_1.MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
|
|
16
|
+
this.newProperty = newProperty;
|
|
17
17
|
if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
|
|
18
|
-
throw
|
|
18
|
+
throw (0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
|
|
19
19
|
}
|
|
20
20
|
if (!reuse_1.isPropertyKebabCaseRegExp.test(oldProperty)) {
|
|
21
|
-
throw
|
|
21
|
+
throw (0, reuse_1.logAndCreateError)(`Old property "${oldProperty}" is not in kebab case.`);
|
|
22
22
|
}
|
|
23
23
|
if (!reuse_1.isPropertyKebabCaseRegExp.test(newProperty)) {
|
|
24
|
-
throw
|
|
24
|
+
throw (0, reuse_1.logAndCreateError)(`New property "${newProperty}" is not in kebab case.`);
|
|
25
25
|
}
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.newPropertyInCamelCase = (0, reuse_1.kebabToCapitalCase)(newProperty);
|
|
29
|
-
this.componentRegExp = new RegExp(`(<${(0, reuse_1.kebabToCapitalCase)(tag)}[^>]+)${this.oldPropertyInCamelCase}([ >=])`, 'g');
|
|
26
|
+
this.newPropertyInCamelCase = (0, reuse_1.kebabToCamelCase)(newProperty);
|
|
27
|
+
this.componentRegExp = new RegExp(`(<${(0, reuse_1.kebabToCapitalCase)(tag)}[^>]+)${(0, reuse_1.kebabToCapitalCase)(oldProperty)}([ >=])`, 'g');
|
|
30
28
|
this.customElementRegExp = new RegExp(`(<${tag}[^>]+)${oldProperty}([ >=])`, 'g');
|
|
31
29
|
}
|
|
32
30
|
run(baseDir) {
|
|
@@ -48,7 +46,7 @@ class GenericRenamePropertyTask extends abstract_task_1.AbstractTask {
|
|
|
48
46
|
});
|
|
49
47
|
}
|
|
50
48
|
transpileCustomElementFileRename(baseDir) {
|
|
51
|
-
(0, reuse_1.filterFilesByExt)(baseDir, types_1.
|
|
49
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
|
|
52
50
|
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
53
51
|
const newContent = content
|
|
54
52
|
// Replacements
|
|
@@ -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,68 @@
|
|
|
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.LabelExpertSlot = 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
|
+
const removeLineBreaksAndSpaces = (match) => {
|
|
12
|
+
return match.replace(/\r?\n/g, ' ').replace(/>\s+/g, '>').replace(/\s+</g, '<');
|
|
13
|
+
};
|
|
14
|
+
class LabelExpertSlot extends abstract_task_1.AbstractTask {
|
|
15
|
+
constructor(identifier, tag, property, versionRange, dependentTasks, options) {
|
|
16
|
+
super(identifier, `Move innerText of "${tag}" component to property "${property}"`, types_1.MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
|
|
17
|
+
this.property = property;
|
|
18
|
+
if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
|
|
19
|
+
throw (0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
|
|
20
|
+
}
|
|
21
|
+
if (!reuse_1.isPropertyKebabCaseRegExp.test(property)) {
|
|
22
|
+
throw (0, reuse_1.logAndCreateError)(`Property "${property}" is not in kebab case.`);
|
|
23
|
+
}
|
|
24
|
+
const tagCapitalCase = (0, reuse_1.kebabToCapitalCase)(tag);
|
|
25
|
+
this.propertyInCamelCase = (0, reuse_1.kebabToCamelCase)(property);
|
|
26
|
+
// https://regex101.com/r/WkEKxu/1
|
|
27
|
+
this.componentRegExp = new RegExp(`(<${tagCapitalCase}[^>]*)>([^<]+(\\n\\s*)*)(<\\/${tagCapitalCase}>)`, 'g');
|
|
28
|
+
this.customElementRegExp = new RegExp(`(<${tag}[^>]*)>([^<]+(\\n\\s*)*)(<\\/${tag}>)`, 'g');
|
|
29
|
+
}
|
|
30
|
+
static getInstance(tag, property, versionRange, dependentTasks = [], options = {}) {
|
|
31
|
+
const identifier = `${tag}-move-innerText-to-property-${property}`;
|
|
32
|
+
if (!this.instances.has(identifier)) {
|
|
33
|
+
this.instances.set(identifier, new LabelExpertSlot(identifier, tag, property, versionRange, dependentTasks, options));
|
|
34
|
+
}
|
|
35
|
+
return this.instances.get(identifier);
|
|
36
|
+
}
|
|
37
|
+
run(baseDir) {
|
|
38
|
+
this.transpileComponentFileDelete(baseDir);
|
|
39
|
+
this.transpileCustomElementFileDelete(baseDir);
|
|
40
|
+
}
|
|
41
|
+
transpileComponentFileDelete(baseDir) {
|
|
42
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
43
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
44
|
+
const newContent = content
|
|
45
|
+
// Replacements
|
|
46
|
+
.replace(this.componentRegExp, removeLineBreaksAndSpaces)
|
|
47
|
+
.replace(this.componentRegExp, `$1 ${this.propertyInCamelCase}="$2">$4`);
|
|
48
|
+
if (content !== newContent) {
|
|
49
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
50
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
transpileCustomElementFileDelete(baseDir) {
|
|
55
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
56
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
57
|
+
const newContent = content
|
|
58
|
+
// Replacements
|
|
59
|
+
.replace(this.customElementRegExp, removeLineBreaksAndSpaces)
|
|
60
|
+
.replace(this.customElementRegExp, `$1 ${this.property}="$2">$4`);
|
|
61
|
+
if (content !== newContent) {
|
|
62
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
63
|
+
// fs.writeFileSync(file, newContent);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.LabelExpertSlot = LabelExpertSlot;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MarkRemovedSlotTask = void 0;
|
|
4
|
+
const GenericRenameSlotNameTask_1 = require("./GenericRenameSlotNameTask");
|
|
5
|
+
class MarkRemovedSlotTask extends GenericRenameSlotNameTask_1.GenericRenameSlotNameTask {
|
|
6
|
+
constructor(identifier, tag, slotName, versionRange, dependentTasks, options) {
|
|
7
|
+
super(identifier, `Mark removed slot "${slotName}" of "${tag}" component`, tag, slotName, `${slotName}`, 'data-removed-slot', versionRange, dependentTasks, options);
|
|
8
|
+
}
|
|
9
|
+
static getInstance(tag, slotName, versionRange, dependentTasks = [], options = {}) {
|
|
10
|
+
const identifier = `${tag}-mark-removed-slot-${slotName}`;
|
|
11
|
+
if (!this.instances.has(identifier)) {
|
|
12
|
+
this.instances.set(identifier, new MarkRemovedSlotTask(identifier, tag, slotName, versionRange, dependentTasks, options));
|
|
13
|
+
}
|
|
14
|
+
return this.instances.get(identifier);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.MarkRemovedSlotTask = MarkRemovedSlotTask;
|
|
@@ -13,15 +13,16 @@ class RemovePropertyNameTask extends GenericRenamePropertyTask_1.GenericRenamePr
|
|
|
13
13
|
constructor(identifier, tag, property, versionRange, dependentTasks, options) {
|
|
14
14
|
super(identifier, `Remove property "${property}" of "${tag}" component`, tag, property, `data-removed-${property}`, versionRange, dependentTasks, options);
|
|
15
15
|
if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
|
|
16
|
-
throw
|
|
16
|
+
throw (0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
|
|
17
17
|
}
|
|
18
18
|
if (!reuse_1.isPropertyKebabCaseRegExp.test(property)) {
|
|
19
|
-
throw
|
|
19
|
+
throw (0, reuse_1.logAndCreateError)(`Property "${property}" is not in kebab case.`);
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
21
|
+
const tagCapitalCase = (0, reuse_1.kebabToCapitalCase)(tag);
|
|
22
|
+
const propertyInCamelCase = (0, reuse_1.kebabToCamelCase)(property);
|
|
23
|
+
this.componentRegExpBoolean = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}([ >])`, 'g');
|
|
24
|
+
this.componentRegExpCurlyBrackets = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}(=\\{[^\\}]+\\})`, 'g');
|
|
25
|
+
this.componentRegExpQuotationMarks = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}(="[^"]+")`, 'g');
|
|
25
26
|
this.customElementRegExpBoolean = new RegExp(`(<${tag}[^>]+)${property}([ >])`, 'g');
|
|
26
27
|
this.customElementRegExpCurlyBrackets = new RegExp(`(<${tag}[^>]+)${property}(=\\{[^\\}]+\\})`, 'g');
|
|
27
28
|
this.customElementRegExpQuotationMarks = new RegExp(`(<${tag}[^>]+)${property}(="[^"]+")`, 'g');
|
|
@@ -59,7 +60,7 @@ class RemovePropertyNameTask extends GenericRenamePropertyTask_1.GenericRenamePr
|
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
transpileCustomElementFileDelete(baseDir) {
|
|
62
|
-
(0, reuse_1.filterFilesByExt)(baseDir, types_1.
|
|
63
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
|
|
63
64
|
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
64
65
|
const newContent = content
|
|
65
66
|
// Replacements
|
|
@@ -3,14 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RenamePropertyNameTask = void 0;
|
|
4
4
|
const GenericRenamePropertyTask_1 = require("./GenericRenamePropertyTask");
|
|
5
5
|
class RenamePropertyNameTask extends GenericRenamePropertyTask_1.GenericRenamePropertyTask {
|
|
6
|
-
constructor(identifier, tag, oldProperty, newProperty, versionRange, dependentTasks = [], options = {}) {
|
|
7
|
-
super(identifier, `Rename property "${oldProperty}" to "${newProperty}" of "${tag}" component`, tag, oldProperty, newProperty, versionRange, dependentTasks, options);
|
|
8
|
-
}
|
|
9
6
|
static getInstance(tag, oldProperty, newProperty, versionRange, dependentTasks = [], options = {}) {
|
|
10
7
|
var _a;
|
|
11
8
|
const identifier = `${tag}-rename-property-${oldProperty}-to-${newProperty}`;
|
|
12
9
|
if (!this.instances.has(identifier)) {
|
|
13
|
-
(_a = this.instances) === null || _a === void 0 ? void 0 : _a.set(identifier, new RenamePropertyNameTask(identifier, tag, oldProperty, newProperty, versionRange, dependentTasks, options));
|
|
10
|
+
(_a = this.instances) === null || _a === void 0 ? void 0 : _a.set(identifier, new RenamePropertyNameTask(identifier, `Rename property "${oldProperty}" to "${newProperty}" of "${tag}" component`, tag, oldProperty, newProperty, versionRange, dependentTasks, options));
|
|
14
11
|
}
|
|
15
12
|
return this.instances.get(identifier);
|
|
16
13
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RenameSlotNameTask = void 0;
|
|
4
|
+
const GenericRenameSlotNameTask_1 = require("./GenericRenameSlotNameTask");
|
|
5
|
+
class RenameSlotNameTask extends GenericRenameSlotNameTask_1.GenericRenameSlotNameTask {
|
|
6
|
+
constructor(identifier, tag, oldSlotName, newSlotName, versionRange, dependentTasks, options) {
|
|
7
|
+
super(identifier, `Rename slot "${oldSlotName}" to "${newSlotName}" of "${tag}" component`, tag, oldSlotName, newSlotName, 'slot', versionRange, dependentTasks, options);
|
|
8
|
+
}
|
|
9
|
+
static getInstance(tag, oldSlotName, newSlotName, versionRange, dependentTasks = [], options = {}) {
|
|
10
|
+
const identifier = `${tag}-rename-slot-${oldSlotName}-to-${newSlotName}`;
|
|
11
|
+
if (!this.instances.has(identifier)) {
|
|
12
|
+
this.instances.set(identifier, new RenameSlotNameTask(identifier, tag, oldSlotName, newSlotName, versionRange, dependentTasks, options));
|
|
13
|
+
}
|
|
14
|
+
return this.instances.get(identifier);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.RenameSlotNameTask = RenameSlotNameTask;
|