@public-ui/kolibri-cli 1.7.0-rc.1 → 1.7.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.
- package/README.md +31 -10
- package/dist/index.js +7 -5
- package/dist/migrate/index.js +12 -16
- package/dist/migrate/runner/abstract-task.js +2 -1
- package/dist/migrate/runner/task-runner.js +7 -8
- package/dist/migrate/runner/tasks/common/GenericRenamePropertyTask.js +3 -3
- package/dist/migrate/runner/tasks/common/LabelExpertSlot.js +46 -0
- package/dist/migrate/runner/tasks/common/RemovePropertyNameTask.js +2 -2
- package/dist/migrate/runner/tasks/test/index.js +2 -6
- package/dist/migrate/runner/tasks/v1/index.js +3 -0
- package/dist/migrate/runner/tasks/v1/input-number.js +1 -1
- package/dist/migrate/shares/reuse.js +54 -7
- package/dist/migrate/types.js +4 -0
- package/package.json +5 -4
- package/dist/migrate/runner/tasks/index.js +0 -18
- 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`.
|
|
@@ -41,13 +62,13 @@ Actually the following migrations are available:
|
|
|
41
62
|
|
|
42
63
|
#### How does it work?
|
|
43
64
|
|
|
44
|
-
1. The migration command will check your project for clear `git history` and the `installed version` of `KoliBri`. Now it
|
|
45
|
-
2.
|
|
65
|
+
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.
|
|
66
|
+
2. Tasks in the correct version range will be executed one by one. Otherwise they will be skipped.
|
|
46
67
|
3. After that the `package.json` will be updated with the new version of `KoliBri` and execute the `npm install` command.
|
|
47
|
-
4.
|
|
68
|
+
4. If there are any pending tasks, the migration command will be executed again. Otherwise the migration is finished.
|
|
48
69
|
5. Now you can check the result and commit the changes.
|
|
49
70
|
|
|
50
|
-
> **Note:** You can reset the migration with `git reset --hard HEAD~1
|
|
71
|
+
> **Note:** You can reset the migration with `git reset --hard HEAD~1` or by discarding the affected files.
|
|
51
72
|
|
|
52
73
|
#### Help
|
|
53
74
|
|
|
@@ -63,10 +84,10 @@ kolibri migrate <path>
|
|
|
63
84
|
|
|
64
85
|
#### Options
|
|
65
86
|
|
|
66
|
-
| Option | Description
|
|
67
|
-
| ------------------------------ |
|
|
68
|
-
| `--ignore-uncommitted-changes` | Allows execution with uncommitted changes
|
|
69
|
-
| `--remove-mode` |
|
|
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` |
|
|
70
91
|
|
|
71
92
|
#### Configuration
|
|
72
93
|
|
|
@@ -142,4 +163,4 @@ You have always the possibility of a dry run. Because before the migration will
|
|
|
142
163
|
|
|
143
164
|
After the migration you can check the result with `git status` and `git diff`.
|
|
144
165
|
|
|
145
|
-
Is anything wrong, you can reset the migration with `git reset --hard HEAD~1
|
|
166
|
+
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,7 @@ 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");
|
|
14
15
|
/**
|
|
15
16
|
* This function is used to register the migrate command.
|
|
16
17
|
* @param {Command} program The program object to register the command
|
|
@@ -19,10 +20,10 @@ function default_1(program) {
|
|
|
19
20
|
program
|
|
20
21
|
.command('migrate')
|
|
21
22
|
.description('This command migrates KoliBri code to the current version.')
|
|
22
|
-
.argument('
|
|
23
|
-
.
|
|
24
|
-
.addOption(new commander_1.Option('--remove-mode <mode>', '
|
|
25
|
-
.
|
|
23
|
+
.argument('[string]', 'Source code folder to migrate', 'src')
|
|
24
|
+
.addOption(new commander_1.Option('--ignore-uncommitted-changes', 'Allows execution with uncommitted changes').default(false))
|
|
25
|
+
.addOption(new commander_1.Option('--remove-mode <mode>', 'Prefix property name or delete property').choices(types_1.REMOVE_MODE).default('prefix'))
|
|
26
|
+
.addOption(new commander_1.Option('--test-tasks', 'Run additional test tasks').default(false).hideHelp())
|
|
26
27
|
.action((baseDir, options) => {
|
|
27
28
|
(0, child_process_1.exec)('git status --porcelain', (err, stdout) => {
|
|
28
29
|
if (err) {
|
|
@@ -30,11 +31,11 @@ function default_1(program) {
|
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
if (!options.ignoreUncommittedChanges && stdout) {
|
|
33
|
-
throw
|
|
34
|
+
throw (0, reuse_1.logAndCreateError)('There are uncommitted changes');
|
|
34
35
|
}
|
|
35
36
|
(0, reuse_1.setRemoveMode)(options.removeMode);
|
|
36
|
-
const
|
|
37
|
-
const
|
|
37
|
+
const versionOfPublicUiComponents = (0, reuse_1.getVersionOfPublicUiComponents)();
|
|
38
|
+
const versionOfPublicUiKoliBriCli = (0, reuse_1.getVersionOfPublicUiKoliBriCli)();
|
|
38
39
|
console.log(`
|
|
39
40
|
Current version of @public-ui/components: ${versionOfPublicUiComponents}
|
|
40
41
|
Source folder to migrate: ${baseDir}
|
|
@@ -62,7 +63,7 @@ Source folder to migrate: ${baseDir}
|
|
|
62
63
|
runner.run();
|
|
63
64
|
if (version !== runner.getPendingMinVersion()) {
|
|
64
65
|
version = runner.getPendingMinVersion();
|
|
65
|
-
let packageJson = (0, reuse_1.
|
|
66
|
+
let packageJson = (0, reuse_1.getContentOfProjectPkgJson)();
|
|
66
67
|
packageJson = packageJson.replace(/"(@public-ui\/[^"]+)":\s*".*"/g, `"$1": "${version}"`);
|
|
67
68
|
fs_1.default.writeFileSync(path_1.default.resolve(process.cwd(), 'package.json'), packageJson);
|
|
68
69
|
runner.setProjectVersion(version);
|
|
@@ -86,16 +87,11 @@ Modified files: ${reuse_1.MODIFIED_FILES.size}`);
|
|
|
86
87
|
console.log(`- ${file}`);
|
|
87
88
|
});
|
|
88
89
|
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.
|
|
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.
|
|
91
91
|
|
|
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.
|
|
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.
|
|
95
93
|
|
|
96
|
-
Is anything wrong, you can reset the migration with "git reset --hard HEAD~1"
|
|
97
|
-
read the troubleshooting section in the readme.
|
|
98
|
-
`);
|
|
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.`);
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
97
|
const status = runner.getStatus();
|
|
@@ -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) {
|
|
@@ -61,7 +61,6 @@ class TaskRunner {
|
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
this.tasks.set(task.getIdentifier(), task);
|
|
64
|
-
this.openRun = true;
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
66
|
}
|
|
@@ -94,7 +93,6 @@ class TaskRunner {
|
|
|
94
93
|
this.tasks.forEach((task) => {
|
|
95
94
|
this.dependentTaskRun(task, task.getDependentTasks());
|
|
96
95
|
});
|
|
97
|
-
this.openRun = false;
|
|
98
96
|
}
|
|
99
97
|
getPendingMinVersion() {
|
|
100
98
|
let version = this.cliVersion;
|
|
@@ -122,7 +120,8 @@ class TaskRunner {
|
|
|
122
120
|
break;
|
|
123
121
|
}
|
|
124
122
|
if (outline) {
|
|
125
|
-
|
|
123
|
+
const status = task.getStatus();
|
|
124
|
+
console.log(`- ${task.getTitle()}:`, status === 'done' ? chalk_1.default.green(status) : chalk_1.default.yellow(status));
|
|
126
125
|
}
|
|
127
126
|
});
|
|
128
127
|
return {
|
|
@@ -15,13 +15,13 @@ class GenericRenamePropertyTask extends abstract_task_1.AbstractTask {
|
|
|
15
15
|
constructor(identifier, description, tag, oldProperty, newProperty, versionRange, dependentTasks = [], options = {}) {
|
|
16
16
|
super(identifier, description, EXTENSIONS, versionRange, dependentTasks, options);
|
|
17
17
|
if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
|
|
18
|
-
|
|
18
|
+
(0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
|
|
19
19
|
}
|
|
20
20
|
if (!reuse_1.isPropertyKebabCaseRegExp.test(oldProperty)) {
|
|
21
|
-
|
|
21
|
+
(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
26
|
this.newProperty = newProperty;
|
|
27
27
|
this.oldPropertyInCamelCase = (0, reuse_1.kebabToCapitalCase)(oldProperty);
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
class LabelExpertSlot extends abstract_task_1.AbstractTask {
|
|
12
|
+
static getInstance(identifier, title, extensions, versionRange, dependentTasks = [], options = {}) {
|
|
13
|
+
if (!this.instances.has(identifier)) {
|
|
14
|
+
this.instances.set(identifier, new LabelExpertSlot(identifier, title, extensions, versionRange, dependentTasks, options));
|
|
15
|
+
}
|
|
16
|
+
return this.instances.get(identifier);
|
|
17
|
+
}
|
|
18
|
+
run(baseDir) {
|
|
19
|
+
this.transpileComponentFileDelete(baseDir);
|
|
20
|
+
this.transpileCustomElementFileDelete(baseDir);
|
|
21
|
+
}
|
|
22
|
+
transpileComponentFileDelete(baseDir) {
|
|
23
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
24
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
25
|
+
const newContent = content;
|
|
26
|
+
console.log(content.match(/<\/KolSelect/));
|
|
27
|
+
// Replacements
|
|
28
|
+
if (content !== newContent) {
|
|
29
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
30
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
transpileCustomElementFileDelete(baseDir) {
|
|
35
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
36
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
37
|
+
const newContent = content;
|
|
38
|
+
// Replacements
|
|
39
|
+
if (content !== newContent) {
|
|
40
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
41
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.LabelExpertSlot = LabelExpertSlot;
|
|
@@ -13,10 +13,10 @@ 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
21
|
this.propertyInCamelCase = (0, reuse_1.kebabToCapitalCase)(property);
|
|
22
22
|
this.componentRegExpBoolean = new RegExp(`(<${(0, reuse_1.kebabToCapitalCase)(tag)}[^>]+)${this.propertyInCamelCase}([ >])`, 'g');
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.testTasks = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
4
|
const reuse_1 = require("../../../shares/reuse");
|
|
9
5
|
const test_version_1_3_1 = require("./test-version-1.3");
|
|
6
|
+
const test_version_current_1 = require("./test-version-current");
|
|
10
7
|
const test_version_next_2_1 = require("./test-version-next-2");
|
|
11
8
|
const test_version_next_3_1 = require("./test-version-next-3");
|
|
12
9
|
const test_version_zero_1 = require("./test-version-zero");
|
|
13
|
-
const test_version_current_1 = require("./test-version-current");
|
|
14
10
|
exports.testTasks = [];
|
|
15
11
|
exports.testTasks.push(test_version_zero_1.TestVersionZero.getInstance());
|
|
16
12
|
exports.testTasks.push(test_version_next_2_1.TestVersionNext2.getInstance());
|
|
17
13
|
exports.testTasks.push(test_version_next_3_1.TestVersionNext3.getInstance());
|
|
18
14
|
exports.testTasks.push(test_version_1_3_1.TestVersion13.getInstance());
|
|
19
|
-
const versionOfPublicUiComponents = (0, reuse_1.
|
|
15
|
+
const versionOfPublicUiComponents = (0, reuse_1.getVersionOfPublicUiComponents)();
|
|
20
16
|
exports.testTasks.push(test_version_current_1.TestVersionCurrent.getInstance(versionOfPublicUiComponents));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.v1Tasks = void 0;
|
|
4
|
+
const types_1 = require("../../../../types");
|
|
5
|
+
const LabelExpertSlot_1 = require("../common/LabelExpertSlot");
|
|
4
6
|
const abbr_1 = require("./abbr");
|
|
5
7
|
const accordion_1 = require("./accordion");
|
|
6
8
|
const badge_1 = require("./badge");
|
|
@@ -103,3 +105,4 @@ exports.v1Tasks.push(tabs_1.TabsRenamePropertyAriaLabelToLabel);
|
|
|
103
105
|
exports.v1Tasks.push(tabs_1.TabsRenamePropertyTabAlignToAlign);
|
|
104
106
|
exports.v1Tasks.push(toast_1.ToastRenamePropertyHeadingToLabel);
|
|
105
107
|
exports.v1Tasks.push(version_1.VersionRenamePropertyVersionToLabel);
|
|
108
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('label-expert-slot', 'Label Expert Slot', types_1.COMPONENT_FILE_EXTENSIONS, '^1'));
|
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InputNumberRenamePropertyListToSuggestions = void 0;
|
|
4
4
|
const RenamePropertyNameTask_1 = require("../common/RenamePropertyNameTask");
|
|
5
5
|
exports.InputNumberRenamePropertyListToSuggestions = RenamePropertyNameTask_1.RenamePropertyNameTask.getInstance('kol-input-number', '_list', '_suggestions', '^1');
|
|
6
|
-
// export const InputNumberRemovePropertyType = RemovePropertyNameTask.getInstance('kol-input-number', '_type', '^1');
|
|
6
|
+
// @todo export const InputNumberRemovePropertyType = RemovePropertyNameTask.getInstance('kol-input-number', '_type', '^1');
|
|
@@ -3,9 +3,31 @@ 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
|
-
exports.getRemoveMode = exports.setRemoveMode = exports.MODIFIED_FILES = exports.kebabToCapitalCase = exports.isPropertyKebabCaseRegExp = exports.isTagKebabCaseRegExp = exports.getPackageManagerInstallCommand = exports.
|
|
6
|
+
exports.getVersionOfPublicUiKoliBriCli = exports.getVersionOfPublicUiComponents = exports.getContentOfProjectPkgJson = exports.getRemoveMode = exports.setRemoveMode = exports.MODIFIED_FILES = exports.kebabToCapitalCase = exports.isPropertyKebabCaseRegExp = exports.isTagKebabCaseRegExp = exports.getPackageManagerInstallCommand = exports.filterFilesByExt = exports.logAndCreateError = 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"));
|
|
10
|
+
/**
|
|
11
|
+
* This function is used to exit the process with an error message.
|
|
12
|
+
* @param {string} msg The error message
|
|
13
|
+
* @param {string} hint The hint message
|
|
14
|
+
* @returns {Error} The error object
|
|
15
|
+
*/
|
|
16
|
+
function logAndCreateError(msg, hint) {
|
|
17
|
+
const hintText = hint
|
|
18
|
+
? chalk_1.default.yellow(`
|
|
19
|
+
ℹ️ `, chalk_1.default.underline.bold(`Hinweis:`), hint, `
|
|
20
|
+
`)
|
|
21
|
+
: '';
|
|
22
|
+
console.log(chalk_1.default.red(chalk_1.default.underline.bold(`
|
|
23
|
+
Error:`), `${msg}
|
|
24
|
+
`), hintText, `
|
|
25
|
+
👉 You can report this error to`, chalk_1.default.blue(`https://github.com/public-ui/kolibri/issues/new?title=CLI:+`), `
|
|
26
|
+
`);
|
|
27
|
+
// @todo process.exit(1); // makes `hint` undefined - ?!
|
|
28
|
+
return new Error();
|
|
29
|
+
}
|
|
30
|
+
exports.logAndCreateError = logAndCreateError;
|
|
9
31
|
/**
|
|
10
32
|
* Recursively searches for files with the specified extension in the specified directory.
|
|
11
33
|
* @param {string} dir The directory to search in
|
|
@@ -36,11 +58,10 @@ exports.filterFilesByExt = filterFilesByExt;
|
|
|
36
58
|
function readPackageString(offsetPath) {
|
|
37
59
|
offsetPath = path_1.default.resolve(offsetPath, 'package.json');
|
|
38
60
|
if (!fs_1.default.existsSync(offsetPath)) {
|
|
39
|
-
throw
|
|
61
|
+
throw logAndCreateError(`The following "package.json" does not exists: ${offsetPath}`);
|
|
40
62
|
}
|
|
41
63
|
return fs_1.default.readFileSync(offsetPath, 'utf8');
|
|
42
64
|
}
|
|
43
|
-
exports.readPackageString = readPackageString;
|
|
44
65
|
/**
|
|
45
66
|
* This function is used to get the version of the package.json.
|
|
46
67
|
* @param {string} offsetPath The offset path to the package.json
|
|
@@ -53,11 +74,10 @@ function readPackageJson(offsetPath) {
|
|
|
53
74
|
json = JSON.parse(content);
|
|
54
75
|
}
|
|
55
76
|
catch (err) {
|
|
56
|
-
throw
|
|
77
|
+
throw logAndCreateError(`The following "package.json" content could not parse: ${content}`);
|
|
57
78
|
}
|
|
58
79
|
return json;
|
|
59
80
|
}
|
|
60
|
-
exports.readPackageJson = readPackageJson;
|
|
61
81
|
/**
|
|
62
82
|
* This function is used to get the package manager install command.
|
|
63
83
|
* @param {string} baseDir The base directory to start searching for the package manager
|
|
@@ -72,7 +92,7 @@ function getPackageManagerInstallCommand(baseDir = process.cwd()) {
|
|
|
72
92
|
return 'npm i';
|
|
73
93
|
baseDir = path_1.default.resolve(baseDir, '..');
|
|
74
94
|
if (baseDir === '/') {
|
|
75
|
-
throw
|
|
95
|
+
throw logAndCreateError('Package manager could not detected.');
|
|
76
96
|
}
|
|
77
97
|
return getPackageManagerInstallCommand(baseDir);
|
|
78
98
|
}
|
|
@@ -92,7 +112,7 @@ function kebabToCapitalCase(tag) {
|
|
|
92
112
|
}
|
|
93
113
|
exports.kebabToCapitalCase = kebabToCapitalCase;
|
|
94
114
|
exports.MODIFIED_FILES = new Set();
|
|
95
|
-
let REMOVE_MODE = '
|
|
115
|
+
let REMOVE_MODE = 'prefix';
|
|
96
116
|
/**
|
|
97
117
|
* Sets the remove mode.
|
|
98
118
|
* @param {RemoveMode} mode The remove mode
|
|
@@ -109,3 +129,30 @@ function getRemoveMode() {
|
|
|
109
129
|
return REMOVE_MODE;
|
|
110
130
|
}
|
|
111
131
|
exports.getRemoveMode = getRemoveMode;
|
|
132
|
+
const getContentOfProjectPkgJson = () => {
|
|
133
|
+
try {
|
|
134
|
+
return readPackageString(path_1.default.resolve(process.cwd()));
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
throw logAndCreateError('Could not read content of project "package.json"!');
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
exports.getContentOfProjectPkgJson = getContentOfProjectPkgJson;
|
|
141
|
+
const getVersionOfPublicUiComponents = () => {
|
|
142
|
+
try {
|
|
143
|
+
return readPackageJson(path_1.default.resolve(process.cwd(), 'node_modsules/@public-ui/components')).version;
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
throw logAndCreateError('Could not get version of installed "@public-ui/components" package!', 'Check that you are in the root directory of your project and that the package "@public-ui/components" is installed.');
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
exports.getVersionOfPublicUiComponents = getVersionOfPublicUiComponents;
|
|
150
|
+
const getVersionOfPublicUiKoliBriCli = () => {
|
|
151
|
+
try {
|
|
152
|
+
return readPackageJson(path_1.default.resolve(__dirname, '..', '..', '..')).version;
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
throw logAndCreateError('Could not get version of global installed "@public-ui/kolibri-cli" package!', 'Install the package with: npm i -g @public-ui/kolibri-cli');
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
exports.getVersionOfPublicUiKoliBriCli = getVersionOfPublicUiKoliBriCli;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@public-ui/kolibri-cli",
|
|
3
|
-
"version": "1.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.3",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": "https://github.com/public-ui/kolibri",
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"format": "prettier -c src",
|
|
23
23
|
"lint": "eslint src && tsc --noEmit",
|
|
24
24
|
"prepack": "tsc",
|
|
25
|
-
"start": "ts-node src/index.ts migrate --test-tasks test",
|
|
25
|
+
"start": "ts-node src/index.ts migrate --ignore-uncommitted-changes --test-tasks test",
|
|
26
26
|
"restart": "pnpm reset && pnpm start",
|
|
27
27
|
"unused": "knip",
|
|
28
28
|
"update": "ncu -t minor -u && ncu",
|
|
29
|
-
"watch": "nodemon --ignore package.json src/index.ts migrate --test-tasks test"
|
|
29
|
+
"watch": "nodemon --ignore package.json src/index.ts migrate --ignore-uncommitted-changes --test-tasks test"
|
|
30
30
|
},
|
|
31
|
+
"type": "commonjs",
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"chalk": "
|
|
33
|
+
"chalk": "^4",
|
|
33
34
|
"commander": "11.0.0",
|
|
34
35
|
"gradient-string": "2.0.2",
|
|
35
36
|
"loglevel": "1.8.1",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./test"), exports);
|
|
18
|
-
__exportStar(require("./v1"), exports);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.testTasks = void 0;
|
|
4
|
-
const test_version_1_3_1 = require("./v1/test-version-1.3");
|
|
5
|
-
const test_version_next_2_1 = require("./v1/test-version-next-2");
|
|
6
|
-
const test_version_next_3_1 = require("./v1/test-version-next-3");
|
|
7
|
-
const test_version_zero_1 = require("./v1/test-version-zero");
|
|
8
|
-
exports.testTasks = [];
|
|
9
|
-
exports.testTasks.push(test_version_zero_1.TestVersionZero.getInstance());
|
|
10
|
-
exports.testTasks.push(test_version_next_2_1.TestVersionNext2.getInstance());
|
|
11
|
-
exports.testTasks.push(test_version_next_3_1.TestVersionNext3.getInstance());
|
|
12
|
-
exports.testTasks.push(test_version_1_3_1.TestVersion13.getInstance());
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbbrPropertyRenamingTitleToLabel = void 0;
|
|
4
|
-
const reuse_1 = require("../../../shares/reuse");
|
|
5
|
-
const types_1 = require("../../../../types");
|
|
6
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
7
|
-
class AbbrPropertyRenamingTitleToLabel extends abstract_task_1.AbstractTask {
|
|
8
|
-
constructor() {
|
|
9
|
-
super('abbr-property-renaming-title-to-label', 'Renaming property `_title` to `_label`', types_1.COMPONENT_FILE_EXTENSIONS.concat(types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS), '>=1 <2');
|
|
10
|
-
}
|
|
11
|
-
static getInstance() {
|
|
12
|
-
if (!(this.instance instanceof AbbrPropertyRenamingTitleToLabel)) {
|
|
13
|
-
this.instance = new AbbrPropertyRenamingTitleToLabel();
|
|
14
|
-
}
|
|
15
|
-
return this.instance;
|
|
16
|
-
}
|
|
17
|
-
run(baseDir) {
|
|
18
|
-
this.transpileComponentFile(baseDir);
|
|
19
|
-
this.transpileCustomElementFile(baseDir);
|
|
20
|
-
}
|
|
21
|
-
transpileComponentFile(baseDir) {
|
|
22
|
-
const files = (0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS);
|
|
23
|
-
this.runDummy(files);
|
|
24
|
-
}
|
|
25
|
-
transpileCustomElementFile(baseDir) {
|
|
26
|
-
const files = (0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS);
|
|
27
|
-
this.runDummy(files);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.AbbrPropertyRenamingTitleToLabel = AbbrPropertyRenamingTitleToLabel;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccordionPropertyRenamingHeadingToLabel = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
const types_1 = require("../../../../types");
|
|
6
|
-
const reuse_1 = require("../../../shares/reuse");
|
|
7
|
-
class AccordionPropertyRenamingHeadingToLabel extends abstract_task_1.AbstractTask {
|
|
8
|
-
constructor() {
|
|
9
|
-
super('accordion-property-renaming-heading-to-label copy', 'Renaming property `_heading` to `_label`', types_1.COMPONENT_FILE_EXTENSIONS.concat(types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS), '>=1 <2');
|
|
10
|
-
}
|
|
11
|
-
static getInstance() {
|
|
12
|
-
if (!(this.instance instanceof AccordionPropertyRenamingHeadingToLabel)) {
|
|
13
|
-
this.instance = new AccordionPropertyRenamingHeadingToLabel();
|
|
14
|
-
}
|
|
15
|
-
return this.instance;
|
|
16
|
-
}
|
|
17
|
-
run(baseDir) {
|
|
18
|
-
this.transpileComponentFile(baseDir);
|
|
19
|
-
this.transpileCustomElementFile(baseDir);
|
|
20
|
-
}
|
|
21
|
-
transpileComponentFile(baseDir) {
|
|
22
|
-
const files = (0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS);
|
|
23
|
-
this.runDummy(files);
|
|
24
|
-
}
|
|
25
|
-
transpileCustomElementFile(baseDir) {
|
|
26
|
-
const files = (0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS);
|
|
27
|
-
this.runDummy(files);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.AccordionPropertyRenamingHeadingToLabel = AccordionPropertyRenamingHeadingToLabel;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersion13 = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersion13 extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('test-version-1.3', 'Test version 1.3', [], '1.3');
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!(this.instance instanceof TestVersion13)) {
|
|
11
|
-
this.instance = new TestVersion13();
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersion13 = TestVersion13;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersionCurrent = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersionCurrent extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor(version) {
|
|
7
|
-
super('test-version-current', 'Test version current', [], version);
|
|
8
|
-
}
|
|
9
|
-
static getInstance(version) {
|
|
10
|
-
if (!(this.instance instanceof TestVersionCurrent)) {
|
|
11
|
-
this.instance = new TestVersionCurrent(version);
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersionCurrent = TestVersionCurrent;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersionNext2 = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersionNext2 extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('test-version-next-2', 'Test version next v2', [], '^2');
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!(this.instance instanceof TestVersionNext2)) {
|
|
11
|
-
this.instance = new TestVersionNext2();
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersionNext2 = TestVersionNext2;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersionNext3 = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersionNext3 extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('test-version-next-3', 'Test version next v3', [], '^3');
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!(this.instance instanceof TestVersionNext3)) {
|
|
11
|
-
this.instance = new TestVersionNext3();
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersionNext3 = TestVersionNext3;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersionZero = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersionZero extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('test-version-zero', 'Test version zero', [], '<1');
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!(this.instance instanceof TestVersionZero)) {
|
|
11
|
-
this.instance = new TestVersionZero();
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersionZero = TestVersionZero;
|
|
@@ -1,48 +0,0 @@
|
|
|
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.AbstractTask = void 0;
|
|
7
|
-
const types_1 = require("../types");
|
|
8
|
-
const semver_1 = __importDefault(require("semver"));
|
|
9
|
-
const reuse_1 = require("../shares/reuse");
|
|
10
|
-
class AbstractTask {
|
|
11
|
-
constructor(identifier, title, extensions, version, options = {}) {
|
|
12
|
-
this.identifier = identifier;
|
|
13
|
-
this.title = title;
|
|
14
|
-
this.extensions = extensions;
|
|
15
|
-
this.version = version;
|
|
16
|
-
this.status = 'pending';
|
|
17
|
-
this.description = options.description;
|
|
18
|
-
this.extensions = this.extensions.filter((ext) => types_1.FILE_EXTENSIONS.includes(ext));
|
|
19
|
-
if (this.version && !semver_1.default.valid(this.version)) {
|
|
20
|
-
throw new Error(`[${this.identifier}] Invalid semver version: ${this.version}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
getDescription() {
|
|
24
|
-
return this.description;
|
|
25
|
-
}
|
|
26
|
-
getFiles(baseDir) {
|
|
27
|
-
return (0, reuse_1.filterFilesByExt)(baseDir, this.extensions);
|
|
28
|
-
}
|
|
29
|
-
getIdentifier() {
|
|
30
|
-
return this.identifier;
|
|
31
|
-
}
|
|
32
|
-
getStatus() {
|
|
33
|
-
return this.status;
|
|
34
|
-
}
|
|
35
|
-
getTitle() {
|
|
36
|
-
return this.title;
|
|
37
|
-
}
|
|
38
|
-
getVersion() {
|
|
39
|
-
return this.version;
|
|
40
|
-
}
|
|
41
|
-
setStatus(status) {
|
|
42
|
-
this.status = status;
|
|
43
|
-
}
|
|
44
|
-
static getInstance() {
|
|
45
|
-
throw new Error('not implemented');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.AbstractTask = AbstractTask;
|
|
@@ -1,28 +0,0 @@
|
|
|
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.TaskRunner = void 0;
|
|
7
|
-
const semver_1 = __importDefault(require("semver"));
|
|
8
|
-
class TaskRunner {
|
|
9
|
-
constructor(baseDir, version) {
|
|
10
|
-
this.baseDir = baseDir;
|
|
11
|
-
this.version = version;
|
|
12
|
-
this.tasks = [];
|
|
13
|
-
if (semver_1.default.valid(version) === null) {
|
|
14
|
-
throw new Error(`Invalid semver version: ${version}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
registerTask(task) {
|
|
18
|
-
this.tasks.concat(Array.isArray(task) ? task : [task]);
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
run() {
|
|
22
|
-
this.tasks.forEach((task) => {
|
|
23
|
-
console.log(task.getFiles(this.baseDir));
|
|
24
|
-
// task.run();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.TaskRunner = TaskRunner;
|
|
@@ -1,27 +0,0 @@
|
|
|
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.AbbrPropertyRenamingTitleToLabel = void 0;
|
|
7
|
-
const abstract_task_1 = require("../abstract-task");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
class AbbrPropertyRenamingTitleToLabel extends abstract_task_1.AbstractTask {
|
|
10
|
-
constructor() {
|
|
11
|
-
super('abbr-property-renaming-title-to-label', 'Renaming property `_title` to `_label`', ['html', 'jsx', 'tsx', 'vue'], '^1');
|
|
12
|
-
}
|
|
13
|
-
static getInstance() {
|
|
14
|
-
if (!(this.instance instanceof AbbrPropertyRenamingTitleToLabel)) {
|
|
15
|
-
this.instance = new AbbrPropertyRenamingTitleToLabel();
|
|
16
|
-
}
|
|
17
|
-
return this.instance;
|
|
18
|
-
}
|
|
19
|
-
run(files) {
|
|
20
|
-
for (const file of files) {
|
|
21
|
-
let content = fs_1.default.readFileSync(file, 'utf8');
|
|
22
|
-
content = content.replace(/_title="([^"]+)"/g, '_label="$1"');
|
|
23
|
-
fs_1.default.writeFileSync(file, content);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.AbbrPropertyRenamingTitleToLabel = AbbrPropertyRenamingTitleToLabel;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tasks = void 0;
|
|
4
|
-
const abbr_property_renaming_title_to_label_1 = require("./abbr-property-renaming-title-to-label");
|
|
5
|
-
exports.tasks = [];
|
|
6
|
-
exports.tasks.push(abbr_property_renaming_title_to_label_1.AbbrPropertyRenamingTitleToLabel.getInstance());
|
package/dist/runner/types.js
DELETED
package/dist/shares/reuse.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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.getPublicUiVersions = exports.filterFilesByExt = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
/**
|
|
10
|
-
* Recursively searches for files with the specified extension in the specified.
|
|
11
|
-
* @param {string} dir The directory to search in
|
|
12
|
-
* @param {FileExtension | FileExtension[]} ext The extension to search for
|
|
13
|
-
* @returns {string[]} The found files
|
|
14
|
-
*/
|
|
15
|
-
function filterFilesByExt(dir, ext) {
|
|
16
|
-
ext = Array.isArray(ext) ? ext : [ext];
|
|
17
|
-
let files = [];
|
|
18
|
-
const dirPath = path_1.default.resolve(process.cwd(), dir);
|
|
19
|
-
fs_1.default.readdirSync(dirPath).forEach((file) => {
|
|
20
|
-
const fullPath = path_1.default.resolve(dir, file);
|
|
21
|
-
if (fs_1.default.lstatSync(fullPath).isDirectory()) {
|
|
22
|
-
files = files.concat(filterFilesByExt(fullPath, ext));
|
|
23
|
-
}
|
|
24
|
-
else if (ext.includes(path_1.default.extname(fullPath).replace('.', ''))) {
|
|
25
|
-
files.push(fullPath);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return files;
|
|
29
|
-
}
|
|
30
|
-
exports.filterFilesByExt = filterFilesByExt;
|
|
31
|
-
/**
|
|
32
|
-
* This function is used to get the versions of @public-ui in the package.json.
|
|
33
|
-
* @param {Record<string, unknown>} packageJson The package.json as object
|
|
34
|
-
* @returns {Map<string, string>} The versions of @public-ui packages
|
|
35
|
-
*/
|
|
36
|
-
function getPublicUiVersions(packageJson) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const publicUiVersions = new Map();
|
|
39
|
-
const dependencies = (_a = packageJson.dependencies) !== null && _a !== void 0 ? _a : {};
|
|
40
|
-
const devDependencies = (_b = packageJson.devDependencies) !== null && _b !== void 0 ? _b : {};
|
|
41
|
-
for (const [name, version] of Object.entries(Object.assign(Object.assign({}, dependencies), devDependencies))) {
|
|
42
|
-
if (name.startsWith('@public-ui/')) {
|
|
43
|
-
publicUiVersions.set(name, version);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return publicUiVersions;
|
|
47
|
-
}
|
|
48
|
-
exports.getPublicUiVersions = getPublicUiVersions;
|