@infomaximum/package-cli 2.9.0 → 2.10.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.
- package/CHANGELOG.md +26 -0
- package/README.md +15 -2
- package/dist/utils.js +1 -2
- package/dist/widget/commands/build.js +18 -0
- package/dist/widget/commands/common.js +40 -0
- package/dist/widget/commands/init.js +9 -0
- package/dist/widget/commands/release.js +19 -0
- package/dist/widget/commands/start.js +23 -0
- package/dist/widget/commands.js +8 -70
- package/dist/widget/scripts/release/const.js +1 -0
- package/dist/widget/scripts/release/release.js +123 -0
- package/dist/widget/scripts/release/utils.js +40 -0
- package/dist/widget/templates/widgetManifest.js +2 -0
- package/dist/widget/templates/widgetPackageJson.js +3 -1
- package/dist/widget/widgetPaths.js +5 -2
- package/package.json +18 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.10.1](https://github.com/Infomaximum/package-cli/compare/v2.10.0...v2.10.1) (2024-09-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* запись в манифест только валидной версии ([fd07f58](https://github.com/Infomaximum/package-cli/commit/fd07f58b9eeeda5a43798160a34ce5e0590a580f))
|
|
11
|
+
|
|
12
|
+
## [2.10.0](https://github.com/Infomaximum/package-cli/compare/v2.9.0...v2.10.0) (2024-09-30)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* в шаблон добавлена команда релиза виджета ([21c3812](https://github.com/Infomaximum/package-cli/commit/21c3812f316f5527b9764d7a826dae782c2d670f))
|
|
18
|
+
* добавлена информацию о версионировании пакета с виджетом ([e53b8dc](https://github.com/Infomaximum/package-cli/commit/e53b8dc2b0ca000e2b17e806e35b98af5701e102))
|
|
19
|
+
* добавлены опции пропуска этапов ([40a8fe2](https://github.com/Infomaximum/package-cli/commit/40a8fe22647032c08a23e19c75816819d2a64066))
|
|
20
|
+
* добавлены флаги ([8305b4f](https://github.com/Infomaximum/package-cli/commit/8305b4fea02545d13a0d90d81f639669e7b31973))
|
|
21
|
+
* начальная реализация команды версионирования ([d9e5941](https://github.com/Infomaximum/package-cli/commit/d9e5941e84cd09a24fb210519b5cc8c1de2510e5))
|
|
22
|
+
* реализовано версионирование ([745780d](https://github.com/Infomaximum/package-cli/commit/745780d2aedfbb520f3759c59c185b837ffd15db))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* исправлена валидация версии системы ([5b36de8](https://github.com/Infomaximum/package-cli/commit/5b36de8714fdbfbaf42cda847104b57e994a4402))
|
|
28
|
+
* исправлены команды ([eeb24a0](https://github.com/Infomaximum/package-cli/commit/eeb24a0ee30599d9230cadaae9b1f02f95d1fd03))
|
|
29
|
+
* повышение версии ([7d9d8d1](https://github.com/Infomaximum/package-cli/commit/7d9d8d1b03ce0954e1dbffd2006a4b876a89df2d))
|
|
30
|
+
|
|
5
31
|
## [2.9.0](https://github.com/Infomaximum/package-cli/compare/v2.8.0...v2.9.0) (2024-09-25)
|
|
6
32
|
|
|
7
33
|
|
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
|
|
72
72
|
- `host`: Хост, на котором будет запущен сервер разработки
|
|
73
73
|
|
|
74
|
-
Этот файл должен называться `widgetrc.json`, но также может иметь расширение `.js`, `.yaml`. Кроме того, конфигурацию можно добавить в `package.json` в поле `widget`.
|
|
74
|
+
Этот файл должен называться `widgetrc.json`, но также может иметь расширение `.js`, `.yaml`. Кроме того, конфигурацию можно добавить в `package.json` в поле `widget`.
|
|
75
75
|
|
|
76
76
|
#### **`package.json`**
|
|
77
77
|
|
|
@@ -95,7 +95,20 @@
|
|
|
95
95
|
}
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
Эта конфигурация определяет, как
|
|
98
|
+
Эта конфигурация определяет, как будет собираться и запускаться ваш пакет с использованием `@infomaximum/package-cli`.
|
|
99
|
+
|
|
100
|
+
## Версионирование пакета `(2.10.0)`
|
|
101
|
+
|
|
102
|
+
`@infomaximum/package-cli` реализует возможность автоматизированного [семантического версионирования](https://semver.org/lang/ru/) для управления версиями пакетов. Версия пакета автоматически вычисляется на основе сообщений коммитов в репозиторий:
|
|
103
|
+
|
|
104
|
+
fix: увеличивает патч-версию (например, с 1.0.0 до 1.0.1)
|
|
105
|
+
feat: увеличивает минорную версию (например, с 1.0.0 до 1.1.0)
|
|
106
|
+
BREAKING CHANGE: увеличивает мажорную версию (например, с 1.0.0 до 2.0.0)
|
|
107
|
+
|
|
108
|
+
После вычисления новой версии автоматически генерируется CHANGELOG.md, который включает список изменений, а также создается соответствующий тег в системе контроля версий.
|
|
109
|
+
|
|
110
|
+
Создать релиз можно используя команду
|
|
111
|
+
`yarn im-package-cli widget release`
|
|
99
112
|
|
|
100
113
|
## Вывод всех доступных команд
|
|
101
114
|
|
package/dist/utils.js
CHANGED
|
@@ -4,8 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { spawn, exec } from "node:child_process";
|
|
5
5
|
import util from "node:util";
|
|
6
6
|
import Module from "node:module";
|
|
7
|
-
import {
|
|
8
|
-
import { WIDGET_SDK_LIB_NAME } from "./widget/const.js";
|
|
7
|
+
import { MANIFEST_SERVICE_FIELDS_FOR_DEVELOPMENT } from "./const.js";
|
|
9
8
|
const execPromise = util.promisify(exec);
|
|
10
9
|
export const isExist = (entityPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
10
|
try {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getConfigFromFile } from "../configs/file.js";
|
|
2
|
+
import { configMergeWithOptionsCommon, registerCommonOption, } from "./common.js";
|
|
3
|
+
import { runBuild } from "../scripts/build.js";
|
|
4
|
+
function configMergeWithOptionsBuild(options) {
|
|
5
|
+
const config = getConfigFromFile();
|
|
6
|
+
return Object.assign({ host: options.host || (config === null || config === void 0 ? void 0 : config.host), port: options.port || (config === null || config === void 0 ? void 0 : config.port), dev: options.dev }, configMergeWithOptionsCommon(config, options));
|
|
7
|
+
}
|
|
8
|
+
export const registerWidgetBuildCommand = (widgetCommand) => {
|
|
9
|
+
const widgetBuildCommand = widgetCommand.command("build");
|
|
10
|
+
registerCommonOption(widgetBuildCommand);
|
|
11
|
+
widgetBuildCommand
|
|
12
|
+
.description("Выполняет сборку пакета")
|
|
13
|
+
.option("--build-dir <buildDirPath>", "путь до директории в которую будет собран пакет")
|
|
14
|
+
.option("--dev", "собрать пакет для разработки", false)
|
|
15
|
+
.option("--host <host>", "хост который будет указан в манифесте виджета")
|
|
16
|
+
.option("--port <port>", "порт который будет указан в манифесте виджета")
|
|
17
|
+
.action((options) => runBuild(configMergeWithOptionsBuild(options)));
|
|
18
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { assertSimple } from "@infomaximum/assert";
|
|
4
|
+
import { DEFAULT_BUILD_DIR_NAME } from "../../const.js";
|
|
5
|
+
export function registerWidgetManifestOption(command) {
|
|
6
|
+
command.option("--widget-manifest <manifestPath>", "путь до файла манифеста виджета");
|
|
7
|
+
}
|
|
8
|
+
export function registerCommonOption(command) {
|
|
9
|
+
command
|
|
10
|
+
.option("--entry <path>", "путь до entrypoint")
|
|
11
|
+
.option("--assets-dir <assetsDirPath>", "путь до директории с ресурсами виджета, которые будут перенесены в архив с виджетом")
|
|
12
|
+
.option("--package-manifest <manifestPath>", "путь до файла манифеста пакета")
|
|
13
|
+
.option("--package-dir <packageDirPath>", "путь до директории с файлами пакета");
|
|
14
|
+
registerWidgetManifestOption(command);
|
|
15
|
+
}
|
|
16
|
+
export function configMergeWithWidgetManifestOptions(config, _a) {
|
|
17
|
+
var { "widget-manifest": optionWidgetManifest } = _a, rest = __rest(_a, ["widget-manifest"]);
|
|
18
|
+
const widgetManifest = optionWidgetManifest || (config === null || config === void 0 ? void 0 : config.widgetManifest);
|
|
19
|
+
assertSimple(!!widgetManifest, chalk.red("В конфигурации не задан widgetManifest"));
|
|
20
|
+
return Object.assign({ widgetManifest }, rest);
|
|
21
|
+
}
|
|
22
|
+
export function configMergeWithOptionsCommon(config, options) {
|
|
23
|
+
const entry = options.entry || (config === null || config === void 0 ? void 0 : config.entry);
|
|
24
|
+
const assetsDir = options["assets-dir"] || (config === null || config === void 0 ? void 0 : config.assetsDir);
|
|
25
|
+
const packageDir = options["package-dir"] || (config === null || config === void 0 ? void 0 : config.packageDir);
|
|
26
|
+
const buildDir = (config === null || config === void 0 ? void 0 : config.buildDir) || DEFAULT_BUILD_DIR_NAME;
|
|
27
|
+
const packageManifest = options["package-manifest"] || (config === null || config === void 0 ? void 0 : config.packageManifest);
|
|
28
|
+
assertSimple(!!entry, chalk.red("В конфигурации не задан entry"));
|
|
29
|
+
assertSimple(!!packageDir, chalk.red("В конфигурации не задан packageDir"));
|
|
30
|
+
assertSimple(!!packageManifest, chalk.red("В конфигурации не задан packageManifest"));
|
|
31
|
+
const widgetManifest = configMergeWithWidgetManifestOptions(config, options).widgetManifest;
|
|
32
|
+
return {
|
|
33
|
+
entry,
|
|
34
|
+
assetsDir,
|
|
35
|
+
packageDir,
|
|
36
|
+
packageManifest,
|
|
37
|
+
widgetManifest,
|
|
38
|
+
buildDir,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { runInitWidget } from "../scripts/init/init.js";
|
|
2
|
+
export const registerWidgetInitCommand = (widgetCommand) => {
|
|
3
|
+
const widgetInitCommand = widgetCommand.command("init <project-directory>");
|
|
4
|
+
widgetInitCommand
|
|
5
|
+
.description("Инициализация проекта виджета")
|
|
6
|
+
.action((dirName) => {
|
|
7
|
+
runInitWidget(dirName);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { runReleaseWidget } from "../scripts/release/release.js";
|
|
2
|
+
import { configMergeWithWidgetManifestOptions, registerWidgetManifestOption, } from "./common.js";
|
|
3
|
+
import { getConfigFromFile } from "../configs/file.js";
|
|
4
|
+
export const registerWidgetReleaseCommand = (widgetCommand) => {
|
|
5
|
+
const widgetReleaseCommand = widgetCommand.command("release");
|
|
6
|
+
const config = getConfigFromFile();
|
|
7
|
+
registerWidgetManifestOption(widgetReleaseCommand);
|
|
8
|
+
widgetReleaseCommand
|
|
9
|
+
.description("Создание релиза виджета")
|
|
10
|
+
.option("--first", "Первый релиз без повышения версии в package.json", false)
|
|
11
|
+
.option("--skip-tag", "Не создавать тег", false)
|
|
12
|
+
.option("--skip-changelog", "Не создавать changelog", false)
|
|
13
|
+
.option("--skip-commit", "Не создавать commit", false)
|
|
14
|
+
.option("--skip-bump", "Не увеличивать версию", false)
|
|
15
|
+
.option("--dry-run", "Посмотреть что будет сделано при релизе", false)
|
|
16
|
+
.action((options) => {
|
|
17
|
+
runReleaseWidget(configMergeWithWidgetManifestOptions(config, options));
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { assertSilent } from "@infomaximum/assert";
|
|
3
|
+
import { getConfigFromFile } from "../configs/file.js";
|
|
4
|
+
import { configMergeWithOptionsCommon, registerCommonOption, } from "./common.js";
|
|
5
|
+
import { WIDGET_DEFAULT_HOST, WIDGET_DEFAULT_PORT } from "../const.js";
|
|
6
|
+
import { runDevServer } from "../scripts/start.js";
|
|
7
|
+
function configMergeWithOptionsStart(options) {
|
|
8
|
+
const config = getConfigFromFile();
|
|
9
|
+
const host = options.host || (config === null || config === void 0 ? void 0 : config.host);
|
|
10
|
+
const port = options.port || (config === null || config === void 0 ? void 0 : config.port);
|
|
11
|
+
assertSilent(!!host, chalk.yellow(`В конфигурациях не найден host, используется host по умолчанию "${WIDGET_DEFAULT_HOST}"`));
|
|
12
|
+
assertSilent(!!port, chalk.yellow(`В конфигурациях не найден port, используется port по умолчанию "${WIDGET_DEFAULT_PORT}"`));
|
|
13
|
+
return Object.assign({ host: host || WIDGET_DEFAULT_HOST, port: port || WIDGET_DEFAULT_PORT }, configMergeWithOptionsCommon(config, options));
|
|
14
|
+
}
|
|
15
|
+
export const registerWidgetStartCommand = (widgetCommand) => {
|
|
16
|
+
const widgetStartCommand = widgetCommand.command("start");
|
|
17
|
+
registerCommonOption(widgetStartCommand);
|
|
18
|
+
widgetStartCommand
|
|
19
|
+
.description("Выполняет запуск проекта для разработки")
|
|
20
|
+
.option("--port <port>", "порт на котором будет доступен виджет")
|
|
21
|
+
.option("--host <host>", "host на котором будет доступен виджет")
|
|
22
|
+
.action((options) => runDevServer(configMergeWithOptionsStart(options)));
|
|
23
|
+
};
|
package/dist/widget/commands.js
CHANGED
|
@@ -1,73 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { assertSilent, assertSimple } from "@infomaximum/assert";
|
|
6
|
-
import chalk from "chalk";
|
|
7
|
-
import { WIDGET_DEFAULT_HOST, WIDGET_DEFAULT_PORT } from "./const.js";
|
|
8
|
-
import { DEFAULT_BUILD_DIR_NAME } from "../const.js";
|
|
9
|
-
function configMergeWithOptionsCommon(config, options) {
|
|
10
|
-
const entry = options.entry || (config === null || config === void 0 ? void 0 : config.entry);
|
|
11
|
-
const assetsDir = options["assets-dir"] || (config === null || config === void 0 ? void 0 : config.assetsDir);
|
|
12
|
-
const packageDir = options["package-dir"] || (config === null || config === void 0 ? void 0 : config.packageDir);
|
|
13
|
-
const buildDir = (config === null || config === void 0 ? void 0 : config.buildDir) || DEFAULT_BUILD_DIR_NAME;
|
|
14
|
-
const packageManifest = options["package-manifest"] || (config === null || config === void 0 ? void 0 : config.packageManifest);
|
|
15
|
-
const widgetManifest = options["widget-manifest"] || (config === null || config === void 0 ? void 0 : config.widgetManifest);
|
|
16
|
-
assertSimple(!!entry, chalk.red("В конфигурации не задан entry"));
|
|
17
|
-
assertSimple(!!packageDir, chalk.red("В конфигурации не задан packageDir"));
|
|
18
|
-
assertSimple(!!packageManifest, chalk.red("В конфигурации не задан packageManifest"));
|
|
19
|
-
assertSimple(!!widgetManifest, chalk.red("В конфигурации не задан widgetManifest"));
|
|
20
|
-
return {
|
|
21
|
-
entry,
|
|
22
|
-
assetsDir,
|
|
23
|
-
packageDir,
|
|
24
|
-
packageManifest,
|
|
25
|
-
widgetManifest,
|
|
26
|
-
buildDir,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function configMergeWithOptionsStart(options) {
|
|
30
|
-
const config = getConfigFromFile();
|
|
31
|
-
const host = options.host || (config === null || config === void 0 ? void 0 : config.host);
|
|
32
|
-
const port = options.port || (config === null || config === void 0 ? void 0 : config.port);
|
|
33
|
-
assertSilent(!!host, chalk.yellow(`В конфигурациях не найден host, используется host по умолчанию "${WIDGET_DEFAULT_HOST}"`));
|
|
34
|
-
assertSilent(!!port, chalk.yellow(`В конфигурациях не найден port, используется port по умолчанию "${WIDGET_DEFAULT_PORT}"`));
|
|
35
|
-
return Object.assign({ host: host || WIDGET_DEFAULT_HOST, port: port || WIDGET_DEFAULT_PORT }, configMergeWithOptionsCommon(config, options));
|
|
36
|
-
}
|
|
37
|
-
function configMergeWithOptionsBuild(options) {
|
|
38
|
-
const config = getConfigFromFile();
|
|
39
|
-
return Object.assign({ host: options.host || (config === null || config === void 0 ? void 0 : config.host), port: options.port || (config === null || config === void 0 ? void 0 : config.port), dev: options.dev }, configMergeWithOptionsCommon(config, options));
|
|
40
|
-
}
|
|
41
|
-
function registerCommonOption(command) {
|
|
42
|
-
command
|
|
43
|
-
.option("--entry <path>", "путь до entrypoint")
|
|
44
|
-
.option("--assets-dir <assetsDirPath>", "путь до директории с ресурсами виджета, которые будут перенесены в архив с виджетом")
|
|
45
|
-
.option("--package-manifest <manifestPath>", "путь до файла манифеста пакета")
|
|
46
|
-
.option("--package-dir <packageDirPath>", "путь до директории с файлами пакета")
|
|
47
|
-
.option("--widget-manifest <manifestPath>", "путь до файла манифеста виджета");
|
|
48
|
-
}
|
|
1
|
+
import { registerWidgetBuildCommand } from "./commands/build.js";
|
|
2
|
+
import { registerWidgetStartCommand } from "./commands/start.js";
|
|
3
|
+
import { registerWidgetInitCommand } from "./commands/init.js";
|
|
4
|
+
import { registerWidgetReleaseCommand } from "./commands/release.js";
|
|
49
5
|
export const registerWidgetCommands = (cli) => {
|
|
50
6
|
const widgetCommand = cli.command("widget");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.option("--build-dir <buildDirPath>", "путь до директории в которую будет собран пакет")
|
|
56
|
-
.option("--dev", "собрать пакет для разработки", false)
|
|
57
|
-
.option("--host <host>", "хост который будет указан в манифесте виджета")
|
|
58
|
-
.option("--port <port>", "порт который будет указан в манифесте виджета")
|
|
59
|
-
.action((options) => runBuild(configMergeWithOptionsBuild(options)));
|
|
60
|
-
const widgetStartCommand = widgetCommand.command("start");
|
|
61
|
-
registerCommonOption(widgetStartCommand);
|
|
62
|
-
widgetStartCommand
|
|
63
|
-
.description("Выполняет запуск проекта для разработки")
|
|
64
|
-
.option("--port <port>", "порт на котором будет доступен виджет")
|
|
65
|
-
.option("--host <host>", "host на котором будет доступен виджет")
|
|
66
|
-
.action((options) => runDevServer(configMergeWithOptionsStart(options)));
|
|
67
|
-
const widgetInitCommand = widgetCommand.command("init <project-directory>");
|
|
68
|
-
widgetInitCommand
|
|
69
|
-
.description("Инициализация проекта виджета")
|
|
70
|
-
.action((dirName) => {
|
|
71
|
-
runInitWidget(dirName);
|
|
72
|
-
});
|
|
7
|
+
registerWidgetBuildCommand(widgetCommand);
|
|
8
|
+
registerWidgetStartCommand(widgetCommand);
|
|
9
|
+
registerWidgetInitCommand(widgetCommand);
|
|
10
|
+
registerWidgetReleaseCommand(widgetCommand);
|
|
73
11
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME = "min_system_version";
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import semver from "semver";
|
|
5
|
+
import standardVersion, {} from "standard-version";
|
|
6
|
+
import stringifyPackage from "stringify-package";
|
|
7
|
+
import { number } from "@inquirer/prompts";
|
|
8
|
+
import { generateGlobalPaths } from "../../../paths.js";
|
|
9
|
+
import { getConfigFromFile } from "../../configs/file.js";
|
|
10
|
+
import { DEFAULT_BUILD_DIR_NAME } from "../../../const.js";
|
|
11
|
+
import { isExist } from "../../../utils.js";
|
|
12
|
+
import { getWidgetManifestPath } from "../../widgetPaths.js";
|
|
13
|
+
import { getJsonContentFile, getRecommendedReleaseType, validateSystemVersion, } from "./utils.js";
|
|
14
|
+
import { MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME } from "./const.js";
|
|
15
|
+
const getSkipOptions = ({ skipChangelog, skipBump, skipCommit, skipTag, }) => {
|
|
16
|
+
return {
|
|
17
|
+
changelog: skipChangelog,
|
|
18
|
+
bump: skipBump,
|
|
19
|
+
commit: skipCommit,
|
|
20
|
+
tag: skipTag,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const getBumpFiles = (manifestWidgetPath) => {
|
|
24
|
+
const readVersionPackageJson = (contents) => JSON.parse(contents).version;
|
|
25
|
+
const readVersionManifest = (contents) => { var _a; return (_a = JSON.parse(contents)) === null || _a === void 0 ? void 0 : _a[MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME]; };
|
|
26
|
+
const writeVersionPackageJson = (contents, version) => {
|
|
27
|
+
const { json, indent, newline } = getJsonContentFile(contents);
|
|
28
|
+
json.version = version;
|
|
29
|
+
return stringifyPackage(json, indent, newline);
|
|
30
|
+
};
|
|
31
|
+
const writeVersionManifest = (contents, version) => {
|
|
32
|
+
const { json, indent, newline } = getJsonContentFile(contents);
|
|
33
|
+
const newVersion = semver.major(version);
|
|
34
|
+
const currentMajorVersion = semver.major(readVersionManifest(contents));
|
|
35
|
+
const validator = validateSystemVersion(currentMajorVersion);
|
|
36
|
+
const isValid = validator(newVersion);
|
|
37
|
+
if (isValid === true) {
|
|
38
|
+
json[MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME] = String(newVersion);
|
|
39
|
+
}
|
|
40
|
+
return stringifyPackage(json, indent, newline);
|
|
41
|
+
};
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
filename: "package.json",
|
|
45
|
+
readVersion: readVersionPackageJson,
|
|
46
|
+
writeVersion: writeVersionPackageJson,
|
|
47
|
+
updater: {
|
|
48
|
+
readVersion: readVersionPackageJson,
|
|
49
|
+
writeVersion: writeVersionPackageJson,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
filename: manifestWidgetPath,
|
|
54
|
+
readVersion: readVersionManifest,
|
|
55
|
+
writeVersion: writeVersionManifest,
|
|
56
|
+
updater: {
|
|
57
|
+
readVersion: readVersionManifest,
|
|
58
|
+
writeVersion: writeVersionManifest,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
};
|
|
63
|
+
const getVersionOnRelease = (_a) => __awaiter(void 0, [_a], void 0, function* ({ globalPaths, manifestWidgetPath, }) {
|
|
64
|
+
const releaseType = yield getRecommendedReleaseType(globalPaths.appPath);
|
|
65
|
+
const [packageJsonContent, widgetManifestContent] = yield Promise.all([
|
|
66
|
+
fs.readFile(globalPaths.appPackageJson, {
|
|
67
|
+
encoding: "utf-8",
|
|
68
|
+
}),
|
|
69
|
+
fs.readFile(manifestWidgetPath, {
|
|
70
|
+
encoding: "utf-8",
|
|
71
|
+
}),
|
|
72
|
+
]);
|
|
73
|
+
const packageJSON = JSON.parse(packageJsonContent);
|
|
74
|
+
const currentWidgetVersion = packageJSON.version;
|
|
75
|
+
const manifestJSON = JSON.parse(widgetManifestContent);
|
|
76
|
+
const minSystemVersionFromManifest = manifestJSON === null || manifestJSON === void 0 ? void 0 : manifestJSON[MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME];
|
|
77
|
+
let newVersion = currentWidgetVersion;
|
|
78
|
+
if (releaseType === "major") {
|
|
79
|
+
const majorWidgetVersion = semver.major(currentWidgetVersion);
|
|
80
|
+
const currentMinSystemVersion = minSystemVersionFromManifest && +minSystemVersionFromManifest;
|
|
81
|
+
const isValidVersion = typeof currentMinSystemVersion === "number" &&
|
|
82
|
+
!isNaN(currentMinSystemVersion) &&
|
|
83
|
+
currentMinSystemVersion > majorWidgetVersion;
|
|
84
|
+
const minSystemVersion = isValidVersion
|
|
85
|
+
? currentMinSystemVersion
|
|
86
|
+
: yield number({
|
|
87
|
+
message: "Введите минимальную версию системы в которой работает виджет (в формате 2409): ",
|
|
88
|
+
validate: validateSystemVersion(majorWidgetVersion),
|
|
89
|
+
});
|
|
90
|
+
const version = `${minSystemVersion}.0.0`;
|
|
91
|
+
if (!semver.valid(version)) {
|
|
92
|
+
throw new Error(`Не валидная версия ${version}`);
|
|
93
|
+
}
|
|
94
|
+
newVersion = version;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
newVersion = semver.inc(currentWidgetVersion, releaseType);
|
|
98
|
+
}
|
|
99
|
+
return newVersion;
|
|
100
|
+
});
|
|
101
|
+
export const runReleaseWidget = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
var _a;
|
|
103
|
+
const { first, widgetManifest, dryRun } = options;
|
|
104
|
+
const config = getConfigFromFile();
|
|
105
|
+
const globalPaths = generateGlobalPaths({
|
|
106
|
+
buildDirPath: (_a = config === null || config === void 0 ? void 0 : config.buildDir) !== null && _a !== void 0 ? _a : DEFAULT_BUILD_DIR_NAME,
|
|
107
|
+
});
|
|
108
|
+
const manifestWidgetPath = getWidgetManifestPath(widgetManifest);
|
|
109
|
+
const changelogFile = path.resolve(globalPaths.appPath, "CHANGELOG.md");
|
|
110
|
+
const isFirstRelease = first || !(yield isExist(changelogFile));
|
|
111
|
+
yield standardVersion({
|
|
112
|
+
releaseAs: yield getVersionOnRelease({ globalPaths, manifestWidgetPath }),
|
|
113
|
+
header: "",
|
|
114
|
+
dryRun,
|
|
115
|
+
path: globalPaths.appPath,
|
|
116
|
+
bumpFiles: getBumpFiles(manifestWidgetPath),
|
|
117
|
+
firstRelease: isFirstRelease,
|
|
118
|
+
infile: changelogFile,
|
|
119
|
+
skip: getSkipOptions(options),
|
|
120
|
+
packageFiles: [path.basename(globalPaths.appPackageJson), widgetManifest],
|
|
121
|
+
verify: false,
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { Bumper } from "conventional-recommended-bump";
|
|
3
|
+
import detectIndent from "detect-indent";
|
|
4
|
+
import { detectNewline } from "detect-newline";
|
|
5
|
+
import semver, {} from "semver";
|
|
6
|
+
export const getRecommendedReleaseType = (projectPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
+
var _a;
|
|
8
|
+
const bumper = new Bumper(projectPath).loadPreset("angular");
|
|
9
|
+
const recommendation = yield bumper.bump();
|
|
10
|
+
return (_a = recommendation.releaseType) !== null && _a !== void 0 ? _a : "patch";
|
|
11
|
+
});
|
|
12
|
+
export const validateSystemVersion = (currentMajorVersion) => (version) => {
|
|
13
|
+
if (!version) {
|
|
14
|
+
return "Версия не была указана, укажите версию";
|
|
15
|
+
}
|
|
16
|
+
const versionStr = `${version}`;
|
|
17
|
+
const versionRegex = /^\d{4}$/;
|
|
18
|
+
if (!versionRegex.test(versionStr)) {
|
|
19
|
+
return `Указанная версия (${version}) не соответствует шаблону версии системы 2409`;
|
|
20
|
+
}
|
|
21
|
+
if (version <= currentMajorVersion) {
|
|
22
|
+
return `Указанная версия системы (${version}) должна быть больше текущей версии (${currentMajorVersion}) `;
|
|
23
|
+
}
|
|
24
|
+
const year = parseInt(versionStr.slice(0, 2), 10);
|
|
25
|
+
const month = parseInt(versionStr.slice(2, 4), 10);
|
|
26
|
+
if (year >= 23 && month >= 1 && month <= 12) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return `Указанная версия (${version}) не является валидной`;
|
|
30
|
+
};
|
|
31
|
+
export const getJsonContentFile = (content) => {
|
|
32
|
+
const json = JSON.parse(content);
|
|
33
|
+
const indent = detectIndent(content).indent;
|
|
34
|
+
const newline = detectNewline(content);
|
|
35
|
+
return {
|
|
36
|
+
json,
|
|
37
|
+
indent,
|
|
38
|
+
newline,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { CUSTOM_PACKAGE_CLI_LIB_NAME } from "../../const.js";
|
|
3
3
|
import { capitalizeHelperName } from "../../plopHelpers.js";
|
|
4
|
+
import { MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME } from "../scripts/release/const.js";
|
|
4
5
|
export const WIDGET_MANIFEST_TEMPLATE = `\
|
|
5
6
|
{
|
|
6
7
|
"$schema": "node_modules/${CUSTOM_PACKAGE_CLI_LIB_NAME}/schemas/widgetManifestSchema.json",
|
|
7
8
|
"uuid": "${randomUUID()}",
|
|
8
9
|
"api_version": 1,
|
|
10
|
+
"${MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME}": "2408",
|
|
9
11
|
"name": {
|
|
10
12
|
"en": "{{${capitalizeHelperName} packageName}}",
|
|
11
13
|
"ru": "{{${capitalizeHelperName} packageName}}"
|
|
@@ -11,7 +11,9 @@ export const WIDGET_PACKAGE_JSON_TEMPLATE = `\
|
|
|
11
11
|
"build:dev": "im-package-cli widget build --dev",
|
|
12
12
|
"start": "im-package-cli widget start",
|
|
13
13
|
"lint": "tsc --noEmit && eslint src/ --ext .ts,.tsx --quiet",
|
|
14
|
-
"test": "jest --passWithNoTests"
|
|
14
|
+
"test": "jest --passWithNoTests",
|
|
15
|
+
"release": "im-package-cli widget release",
|
|
16
|
+
"changelog":"im-package-cli widget release --dry-run"
|
|
15
17
|
},
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"${WIDGET_SDK_LIB_NAME}": "{{widgetSDKVersion}}",
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { _resolveApp, generateGlobalPaths, generateIndexPath, } from "../paths.js";
|
|
3
|
+
const resolveApp = _resolveApp();
|
|
3
4
|
export function generateWidgetPaths({ entry, assetsDir, widgetManifest, buildDir, }) {
|
|
4
5
|
const globalPaths = generateGlobalPaths({ buildDirPath: buildDir });
|
|
5
|
-
const resolveApp = _resolveApp();
|
|
6
6
|
return Object.assign(Object.assign({}, globalPaths), { get moduleIndex() {
|
|
7
7
|
return generateIndexPath(entry);
|
|
8
|
-
}, widgetManifestJsonPath:
|
|
8
|
+
}, widgetManifestJsonPath: getWidgetManifestPath(widgetManifest), widgetResourcesPath: assetsDir ? resolveApp(assetsDir) : null, widgetResourcesDirName: assetsDir ? path.basename(assetsDir) : null, widgetBuildDirPath: resolveApp(buildDir) });
|
|
9
|
+
}
|
|
10
|
+
export function getWidgetManifestPath(widgetManifest) {
|
|
11
|
+
return resolveApp(widgetManifest);
|
|
9
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infomaximum/package-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"exports": "./dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"dev": "tsc",
|
|
18
|
-
"dev:w": "
|
|
19
|
-
"build": "rimraf dist &&
|
|
20
|
-
"release": "tsc --noEmit && standard-version &&
|
|
18
|
+
"dev:w": "npm run dev -- -w",
|
|
19
|
+
"build": "rimraf dist && npm run dev",
|
|
20
|
+
"release": "tsc --noEmit && standard-version && npm run build",
|
|
21
21
|
"lint": "tsc --noEmit",
|
|
22
22
|
"prettier": "prettier --find-config-path --write 'lib/**/*'"
|
|
23
23
|
},
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@babel/plugin-transform-runtime": "^7.23.6",
|
|
27
27
|
"@infomaximum/assert": "^1.1.3",
|
|
28
28
|
"@infomaximum/json-modify-webpack-plugin": "^1.1.0",
|
|
29
|
+
"@inquirer/prompts": "^6.0.1",
|
|
29
30
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
|
30
31
|
"@svgr/webpack": "^8.1.0",
|
|
31
32
|
"autoprefixer": "^10.4.16",
|
|
@@ -33,10 +34,16 @@
|
|
|
33
34
|
"babel-plugin-inline-json-import": "^0.3.2",
|
|
34
35
|
"chalk": "^5.3.0",
|
|
35
36
|
"commander": "^11.1.0",
|
|
37
|
+
"conventional-changelog-angular": "^8.0.0",
|
|
38
|
+
"conventional-changelog-preset-loader": "^5.0.0",
|
|
39
|
+
"conventional-recommended-bump": "^10.0.0",
|
|
36
40
|
"copy-webpack-plugin": "^11.0.0",
|
|
37
41
|
"css-loader": "^6.8.1",
|
|
38
42
|
"css-minimizer-webpack-plugin": "^5.0.1",
|
|
43
|
+
"detect-indent": "^7.0.1",
|
|
44
|
+
"detect-newline": "^4.0.1",
|
|
39
45
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
46
|
+
"fs-extra": "^11.2.0",
|
|
40
47
|
"less": "^4.2.0",
|
|
41
48
|
"less-loader": "^11.1.3",
|
|
42
49
|
"node-plop": "^0.32.0",
|
|
@@ -48,8 +55,9 @@
|
|
|
48
55
|
"remove-files-webpack-plugin": "^1.5.0",
|
|
49
56
|
"sass": "^1.69.5",
|
|
50
57
|
"sass-loader": "^13.3.2",
|
|
51
|
-
"semver": "^7.
|
|
52
|
-
"standard-version": "
|
|
58
|
+
"semver": "^7.6.3",
|
|
59
|
+
"standard-version": "=9.5.0",
|
|
60
|
+
"stringify-package": "^1.0.1",
|
|
53
61
|
"style-loader": "^3.3.3",
|
|
54
62
|
"terser-webpack-plugin": "^5.3.9",
|
|
55
63
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
@@ -59,13 +67,15 @@
|
|
|
59
67
|
"zip-webpack-plugin": "^4.0.1"
|
|
60
68
|
},
|
|
61
69
|
"devDependencies": {
|
|
70
|
+
"@types/fs-extra": "^11.0.4",
|
|
62
71
|
"@types/node": "^20.9.0",
|
|
63
72
|
"@types/semver": "^7.5.6",
|
|
73
|
+
"@types/standard-version": "^7.1.3",
|
|
64
74
|
"@types/webpack": "^5.28.5",
|
|
65
75
|
"@types/zip-webpack-plugin": "^3.0.6",
|
|
66
|
-
"prettier": "^3.
|
|
76
|
+
"prettier": "^3.3.3",
|
|
67
77
|
"rimraf": "^5.0.5",
|
|
68
|
-
"typescript": "
|
|
78
|
+
"typescript": "5.6.2"
|
|
69
79
|
},
|
|
70
80
|
"resolutions": {
|
|
71
81
|
"wrap-ansi": "7.0.0",
|