@infomaximum/package-cli 2.10.1 → 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 +8 -0
- package/dist/widget/commands/common.js +7 -16
- package/dist/widget/commands/release.js +1 -5
- package/dist/widget/scripts/release/release.js +5 -71
- 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 +1 -2
- package/schemas/widgetManifestSchema.json +3 -9
- package/dist/widget/scripts/release/const.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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
|
+
|
|
5
13
|
### [2.10.1](https://github.com/Infomaximum/package-cli/compare/v2.10.0...v2.10.1) (2024-09-30)
|
|
6
14
|
|
|
7
15
|
|
|
@@ -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,25 +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
|
-
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
25
|
return [
|
|
43
26
|
{
|
|
44
27
|
filename: "package.json",
|
|
@@ -49,75 +32,26 @@ const getBumpFiles = (manifestWidgetPath) => {
|
|
|
49
32
|
writeVersion: writeVersionPackageJson,
|
|
50
33
|
},
|
|
51
34
|
},
|
|
52
|
-
{
|
|
53
|
-
filename: manifestWidgetPath,
|
|
54
|
-
readVersion: readVersionManifest,
|
|
55
|
-
writeVersion: writeVersionManifest,
|
|
56
|
-
updater: {
|
|
57
|
-
readVersion: readVersionManifest,
|
|
58
|
-
writeVersion: writeVersionManifest,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
35
|
];
|
|
62
36
|
};
|
|
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
37
|
export const runReleaseWidget = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
38
|
var _a;
|
|
103
|
-
const { first,
|
|
39
|
+
const { first, dryRun } = options;
|
|
104
40
|
const config = getConfigFromFile();
|
|
105
41
|
const globalPaths = generateGlobalPaths({
|
|
106
42
|
buildDirPath: (_a = config === null || config === void 0 ? void 0 : config.buildDir) !== null && _a !== void 0 ? _a : DEFAULT_BUILD_DIR_NAME,
|
|
107
43
|
});
|
|
108
|
-
const manifestWidgetPath = getWidgetManifestPath(widgetManifest);
|
|
109
44
|
const changelogFile = path.resolve(globalPaths.appPath, "CHANGELOG.md");
|
|
110
45
|
const isFirstRelease = first || !(yield isExist(changelogFile));
|
|
111
46
|
yield standardVersion({
|
|
112
|
-
releaseAs: yield getVersionOnRelease({ globalPaths, manifestWidgetPath }),
|
|
113
47
|
header: "",
|
|
114
48
|
dryRun,
|
|
115
49
|
path: globalPaths.appPath,
|
|
116
|
-
bumpFiles: getBumpFiles(
|
|
50
|
+
bumpFiles: getBumpFiles(),
|
|
117
51
|
firstRelease: isFirstRelease,
|
|
118
52
|
infile: changelogFile,
|
|
119
53
|
skip: getSkipOptions(options),
|
|
120
|
-
packageFiles: [path.basename(globalPaths.appPackageJson)
|
|
54
|
+
packageFiles: [path.basename(globalPaths.appPackageJson)],
|
|
121
55
|
verify: false,
|
|
122
56
|
});
|
|
123
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",
|
|
@@ -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";
|