@infomaximum/package-cli 2.10.0 → 2.10.2
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 +15 -0
- package/README.md +1 -1
- package/dist/widget/commands/common.js +7 -16
- package/dist/widget/commands/release.js +1 -5
- package/dist/widget/scripts/release/release.js +5 -65
- package/dist/widget/scripts/release/utils.js +0 -28
- package/dist/widget/templates/widgetManifest.js +0 -2
- package/dist/widget/widgetPaths.js +1 -4
- package/package.json +2 -3
- package/schemas/widgetManifestSchema.json +3 -9
- package/dist/widget/scripts/release/const.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
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.2](https://github.com/Infomaximum/package-cli/compare/v2.10.1...v2.10.2) (2024-10-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* возвращено стандартное семантическое версионирование ([2ba7fbc](https://github.com/Infomaximum/package-cli/commit/2ba7fbce4363bcd64957a594efb1d44d72ade484))
|
|
11
|
+
* поля в манифесте виджета 2408 ([ed269f4](https://github.com/Infomaximum/package-cli/commit/ed269f4fc726f14349c308131817e4e75eeb2b36))
|
|
12
|
+
|
|
13
|
+
### [2.10.1](https://github.com/Infomaximum/package-cli/compare/v2.10.0...v2.10.1) (2024-09-30)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* запись в манифест только валидной версии ([fd07f58](https://github.com/Infomaximum/package-cli/commit/fd07f58b9eeeda5a43798160a34ce5e0590a580f))
|
|
19
|
+
|
|
5
20
|
## [2.10.0](https://github.com/Infomaximum/package-cli/compare/v2.9.0...v2.10.0) (2024-09-30)
|
|
6
21
|
|
|
7
22
|
|
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
|
|
98
98
|
Эта конфигурация определяет, как будет собираться и запускаться ваш пакет с использованием `@infomaximum/package-cli`.
|
|
99
99
|
|
|
100
|
-
## Версионирование пакета
|
|
100
|
+
## Версионирование пакета `(2.10.0)`
|
|
101
101
|
|
|
102
102
|
`@infomaximum/package-cli` реализует возможность автоматизированного [семантического версионирования](https://semver.org/lang/ru/) для управления версиями пакетов. Версия пакета автоматически вычисляется на основе сообщений коммитов в репозиторий:
|
|
103
103
|
|
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import chalk from "chalk";
|
|
3
2
|
import { assertSimple } from "@infomaximum/assert";
|
|
4
3
|
import { DEFAULT_BUILD_DIR_NAME } from "../../const.js";
|
|
5
|
-
export function registerWidgetManifestOption(command) {
|
|
6
|
-
command.option("--widget-manifest <manifestPath>", "путь до файла манифеста виджета");
|
|
7
|
-
}
|
|
8
4
|
export function registerCommonOption(command) {
|
|
9
5
|
command
|
|
10
6
|
.option("--entry <path>", "путь до entrypoint")
|
|
11
7
|
.option("--assets-dir <assetsDirPath>", "путь до директории с ресурсами виджета, которые будут перенесены в архив с виджетом")
|
|
12
8
|
.option("--package-manifest <manifestPath>", "путь до файла манифеста пакета")
|
|
13
|
-
.option("--package-dir <packageDirPath>", "путь до директории с файлами пакета")
|
|
14
|
-
|
|
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);
|
|
9
|
+
.option("--package-dir <packageDirPath>", "путь до директории с файлами пакета")
|
|
10
|
+
.option("--widget-manifest <manifestPath>", "путь до файла манифеста виджета");
|
|
21
11
|
}
|
|
22
12
|
export function configMergeWithOptionsCommon(config, options) {
|
|
23
13
|
const entry = options.entry || (config === null || config === void 0 ? void 0 : config.entry);
|
|
24
|
-
const assetsDir = options
|
|
25
|
-
const packageDir = options
|
|
14
|
+
const assetsDir = (options === null || options === void 0 ? void 0 : options.assetsDir) || (config === null || config === void 0 ? void 0 : config.assetsDir);
|
|
15
|
+
const packageDir = (options === null || options === void 0 ? void 0 : options.packageDir) || (config === null || config === void 0 ? void 0 : config.packageDir);
|
|
26
16
|
const buildDir = (config === null || config === void 0 ? void 0 : config.buildDir) || DEFAULT_BUILD_DIR_NAME;
|
|
27
|
-
const packageManifest = options
|
|
17
|
+
const packageManifest = (options === null || options === void 0 ? void 0 : options.packageManifest) || (config === null || config === void 0 ? void 0 : config.packageManifest);
|
|
18
|
+
const widgetManifest = (options === null || options === void 0 ? void 0 : options.widgetManifest) || (config === null || config === void 0 ? void 0 : config.widgetManifest);
|
|
28
19
|
assertSimple(!!entry, chalk.red("В конфигурации не задан entry"));
|
|
29
20
|
assertSimple(!!packageDir, chalk.red("В конфигурации не задан packageDir"));
|
|
30
21
|
assertSimple(!!packageManifest, chalk.red("В конфигурации не задан packageManifest"));
|
|
31
|
-
|
|
22
|
+
assertSimple(!!widgetManifest, chalk.red("В конфигурации не задан widgetManifest"));
|
|
32
23
|
return {
|
|
33
24
|
entry,
|
|
34
25
|
assetsDir,
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { runReleaseWidget } from "../scripts/release/release.js";
|
|
2
|
-
import { configMergeWithWidgetManifestOptions, registerWidgetManifestOption, } from "./common.js";
|
|
3
|
-
import { getConfigFromFile } from "../configs/file.js";
|
|
4
2
|
export const registerWidgetReleaseCommand = (widgetCommand) => {
|
|
5
3
|
const widgetReleaseCommand = widgetCommand.command("release");
|
|
6
|
-
const config = getConfigFromFile();
|
|
7
|
-
registerWidgetManifestOption(widgetReleaseCommand);
|
|
8
4
|
widgetReleaseCommand
|
|
9
5
|
.description("Создание релиза виджета")
|
|
10
6
|
.option("--first", "Первый релиз без повышения версии в package.json", false)
|
|
@@ -14,6 +10,6 @@ export const registerWidgetReleaseCommand = (widgetCommand) => {
|
|
|
14
10
|
.option("--skip-bump", "Не увеличивать версию", false)
|
|
15
11
|
.option("--dry-run", "Посмотреть что будет сделано при релизе", false)
|
|
16
12
|
.action((options) => {
|
|
17
|
-
runReleaseWidget(
|
|
13
|
+
runReleaseWidget(options);
|
|
18
14
|
});
|
|
19
15
|
};
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
2
|
import path from "path";
|
|
4
|
-
import semver from "semver";
|
|
5
3
|
import standardVersion, {} from "standard-version";
|
|
6
4
|
import stringifyPackage from "stringify-package";
|
|
7
|
-
import { number } from "@inquirer/prompts";
|
|
8
5
|
import { generateGlobalPaths } from "../../../paths.js";
|
|
9
6
|
import { getConfigFromFile } from "../../configs/file.js";
|
|
10
7
|
import { DEFAULT_BUILD_DIR_NAME } from "../../../const.js";
|
|
11
8
|
import { isExist } from "../../../utils.js";
|
|
12
|
-
import {
|
|
13
|
-
import { getJsonContentFile, getRecommendedReleaseType, validateSystemVersion, } from "./utils.js";
|
|
14
|
-
import { MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME } from "./const.js";
|
|
9
|
+
import { getJsonContentFile } from "./utils.js";
|
|
15
10
|
const getSkipOptions = ({ skipChangelog, skipBump, skipCommit, skipTag, }) => {
|
|
16
11
|
return {
|
|
17
12
|
changelog: skipChangelog,
|
|
@@ -20,19 +15,13 @@ const getSkipOptions = ({ skipChangelog, skipBump, skipCommit, skipTag, }) => {
|
|
|
20
15
|
tag: skipTag,
|
|
21
16
|
};
|
|
22
17
|
};
|
|
23
|
-
const getBumpFiles = (
|
|
18
|
+
const getBumpFiles = () => {
|
|
24
19
|
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
20
|
const writeVersionPackageJson = (contents, version) => {
|
|
27
21
|
const { json, indent, newline } = getJsonContentFile(contents);
|
|
28
22
|
json.version = version;
|
|
29
23
|
return stringifyPackage(json, indent, newline);
|
|
30
24
|
};
|
|
31
|
-
const writeVersionManifest = (contents, version) => {
|
|
32
|
-
const { json, indent, newline } = getJsonContentFile(contents);
|
|
33
|
-
json[MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME] = String(semver.major(version));
|
|
34
|
-
return stringifyPackage(json, indent, newline);
|
|
35
|
-
};
|
|
36
25
|
return [
|
|
37
26
|
{
|
|
38
27
|
filename: "package.json",
|
|
@@ -43,75 +32,26 @@ const getBumpFiles = (manifestWidgetPath) => {
|
|
|
43
32
|
writeVersion: writeVersionPackageJson,
|
|
44
33
|
},
|
|
45
34
|
},
|
|
46
|
-
{
|
|
47
|
-
filename: manifestWidgetPath,
|
|
48
|
-
readVersion: readVersionManifest,
|
|
49
|
-
writeVersion: writeVersionManifest,
|
|
50
|
-
updater: {
|
|
51
|
-
readVersion: readVersionManifest,
|
|
52
|
-
writeVersion: writeVersionManifest,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
35
|
];
|
|
56
36
|
};
|
|
57
|
-
const getVersionOnRelease = (_a) => __awaiter(void 0, [_a], void 0, function* ({ globalPaths, manifestWidgetPath, }) {
|
|
58
|
-
const releaseType = yield getRecommendedReleaseType(globalPaths.appPath);
|
|
59
|
-
const [packageJsonContent, widgetManifestContent] = yield Promise.all([
|
|
60
|
-
fs.readFile(globalPaths.appPackageJson, {
|
|
61
|
-
encoding: "utf-8",
|
|
62
|
-
}),
|
|
63
|
-
fs.readFile(manifestWidgetPath, {
|
|
64
|
-
encoding: "utf-8",
|
|
65
|
-
}),
|
|
66
|
-
]);
|
|
67
|
-
const packageJSON = JSON.parse(packageJsonContent);
|
|
68
|
-
const currentWidgetVersion = packageJSON.version;
|
|
69
|
-
const manifestJSON = JSON.parse(widgetManifestContent);
|
|
70
|
-
const minSystemVersionFromManifest = manifestJSON === null || manifestJSON === void 0 ? void 0 : manifestJSON[MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME];
|
|
71
|
-
let newVersion = currentWidgetVersion;
|
|
72
|
-
if (releaseType === "major") {
|
|
73
|
-
const majorWidgetVersion = semver.major(currentWidgetVersion);
|
|
74
|
-
const currentMinSystemVersion = minSystemVersionFromManifest && +minSystemVersionFromManifest;
|
|
75
|
-
const isValidVersion = typeof currentMinSystemVersion === "number" &&
|
|
76
|
-
!isNaN(currentMinSystemVersion) &&
|
|
77
|
-
currentMinSystemVersion > majorWidgetVersion;
|
|
78
|
-
const minSystemVersion = isValidVersion
|
|
79
|
-
? currentMinSystemVersion
|
|
80
|
-
: yield number({
|
|
81
|
-
message: "Введите минимальную версию системы в которой работает виджет (в формате 2409): ",
|
|
82
|
-
validate: validateSystemVersion(majorWidgetVersion),
|
|
83
|
-
});
|
|
84
|
-
const version = `${minSystemVersion}.0.0`;
|
|
85
|
-
if (!semver.valid(version)) {
|
|
86
|
-
throw new Error(`Не валидная версия ${version}`);
|
|
87
|
-
}
|
|
88
|
-
newVersion = version;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
newVersion = semver.inc(currentWidgetVersion, releaseType);
|
|
92
|
-
}
|
|
93
|
-
return newVersion;
|
|
94
|
-
});
|
|
95
37
|
export const runReleaseWidget = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
38
|
var _a;
|
|
97
|
-
const { first,
|
|
39
|
+
const { first, dryRun } = options;
|
|
98
40
|
const config = getConfigFromFile();
|
|
99
41
|
const globalPaths = generateGlobalPaths({
|
|
100
42
|
buildDirPath: (_a = config === null || config === void 0 ? void 0 : config.buildDir) !== null && _a !== void 0 ? _a : DEFAULT_BUILD_DIR_NAME,
|
|
101
43
|
});
|
|
102
|
-
const manifestWidgetPath = getWidgetManifestPath(widgetManifest);
|
|
103
44
|
const changelogFile = path.resolve(globalPaths.appPath, "CHANGELOG.md");
|
|
104
45
|
const isFirstRelease = first || !(yield isExist(changelogFile));
|
|
105
46
|
yield standardVersion({
|
|
106
|
-
releaseAs: yield getVersionOnRelease({ globalPaths, manifestWidgetPath }),
|
|
107
47
|
header: "",
|
|
108
48
|
dryRun,
|
|
109
49
|
path: globalPaths.appPath,
|
|
110
|
-
bumpFiles: getBumpFiles(
|
|
50
|
+
bumpFiles: getBumpFiles(),
|
|
111
51
|
firstRelease: isFirstRelease,
|
|
112
52
|
infile: changelogFile,
|
|
113
53
|
skip: getSkipOptions(options),
|
|
114
|
-
packageFiles: [path.basename(globalPaths.appPackageJson)
|
|
54
|
+
packageFiles: [path.basename(globalPaths.appPackageJson)],
|
|
115
55
|
verify: false,
|
|
116
56
|
});
|
|
117
57
|
});
|
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { Bumper } from "conventional-recommended-bump";
|
|
3
1
|
import detectIndent from "detect-indent";
|
|
4
2
|
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
3
|
export const getJsonContentFile = (content) => {
|
|
32
4
|
const json = JSON.parse(content);
|
|
33
5
|
const indent = detectIndent(content).indent;
|
|
@@ -1,13 +1,11 @@
|
|
|
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";
|
|
5
4
|
export const WIDGET_MANIFEST_TEMPLATE = `\
|
|
6
5
|
{
|
|
7
6
|
"$schema": "node_modules/${CUSTOM_PACKAGE_CLI_LIB_NAME}/schemas/widgetManifestSchema.json",
|
|
8
7
|
"uuid": "${randomUUID()}",
|
|
9
8
|
"api_version": 1,
|
|
10
|
-
"${MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME}": "2408",
|
|
11
9
|
"name": {
|
|
12
10
|
"en": "{{${capitalizeHelperName} packageName}}",
|
|
13
11
|
"ru": "{{${capitalizeHelperName} packageName}}"
|
|
@@ -5,8 +5,5 @@ export function generateWidgetPaths({ entry, assetsDir, widgetManifest, buildDir
|
|
|
5
5
|
const globalPaths = generateGlobalPaths({ buildDirPath: buildDir });
|
|
6
6
|
return Object.assign(Object.assign({}, globalPaths), { get moduleIndex() {
|
|
7
7
|
return generateIndexPath(entry);
|
|
8
|
-
}, widgetManifestJsonPath:
|
|
9
|
-
}
|
|
10
|
-
export function getWidgetManifestPath(widgetManifest) {
|
|
11
|
-
return resolveApp(widgetManifest);
|
|
8
|
+
}, widgetManifestJsonPath: resolveApp(widgetManifest), widgetResourcesPath: assetsDir ? resolveApp(assetsDir) : null, widgetResourcesDirName: assetsDir ? path.basename(assetsDir) : null, widgetBuildDirPath: resolveApp(buildDir) });
|
|
12
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infomaximum/package-cli",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.2",
|
|
4
4
|
"exports": "./dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,7 +26,6 @@
|
|
|
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",
|
|
30
29
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
|
31
30
|
"@svgr/webpack": "^8.1.0",
|
|
32
31
|
"autoprefixer": "^10.4.16",
|
|
@@ -73,7 +72,7 @@
|
|
|
73
72
|
"@types/standard-version": "^7.1.3",
|
|
74
73
|
"@types/webpack": "^5.28.5",
|
|
75
74
|
"@types/zip-webpack-plugin": "^3.0.6",
|
|
76
|
-
"prettier": "^3.
|
|
75
|
+
"prettier": "^3.3.3",
|
|
77
76
|
"rimraf": "^5.0.5",
|
|
78
77
|
"typescript": "5.6.2"
|
|
79
78
|
},
|
|
@@ -38,15 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"default_size_percentage": {
|
|
40
40
|
"type": "object",
|
|
41
|
-
"title": "Размеры виджета по умолчанию
|
|
42
|
-
"required": ["
|
|
41
|
+
"title": "Размеры виджета по умолчанию",
|
|
42
|
+
"required": ["min_width", "min_height"],
|
|
43
43
|
"properties": {
|
|
44
|
-
"width": {
|
|
45
|
-
"type": "integer"
|
|
46
|
-
},
|
|
47
|
-
"height": {
|
|
48
|
-
"type": "integer"
|
|
49
|
-
},
|
|
50
44
|
"min_width": {
|
|
51
45
|
"type": "integer"
|
|
52
46
|
},
|
|
@@ -56,5 +50,5 @@
|
|
|
56
50
|
}
|
|
57
51
|
}
|
|
58
52
|
},
|
|
59
|
-
"required": ["uuid", "name"]
|
|
53
|
+
"required": ["uuid", "name", "min_system_version"]
|
|
60
54
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const MIN_SYSTEM_VERSION_MANIFEST_FIELD_NAME = "min_system_version";
|