@infomaximum/package-cli 2.0.1 → 2.1.0

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 CHANGED
@@ -2,6 +2,22 @@
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.1.0](https://github.com/Infomaximum/package-cli/compare/v2.0.1...v2.1.0) (2024-03-05)
6
+
7
+
8
+ ### Features
9
+
10
+ * добавление api_version в манифест при сборке для обратной совместимости ([7d2a9d8](https://github.com/Infomaximum/package-cli/commit/7d2a9d8ea1bf9bf6399057df89bbb8fe02fc51e7))
11
+ * новый путь регистрации виджета ([1b2cf4a](https://github.com/Infomaximum/package-cli/commit/1b2cf4a71ba101a3e16f16d9fede3b64f3a546c8))
12
+ * sdk_version -> manifest.json ([ee5aa42](https://github.com/Infomaximum/package-cli/commit/ee5aa42b1a71db5c3ed96b5ed6ea18b9f68c770f))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * 10 секунд ожидание ([f829632](https://github.com/Infomaximum/package-cli/commit/f829632b7c314aa806d506a9bbcc0433c91a1104))
18
+ * без дополнительных свойств ([8a2b08d](https://github.com/Infomaximum/package-cli/commit/8a2b08d74171ed9b5c94e43292d1032f4ed75e90))
19
+ * типизация ([c7482c5](https://github.com/Infomaximum/package-cli/commit/c7482c50647c0f6461fb42de521bd511f87cc08a))
20
+
5
21
  ### [2.0.1](https://github.com/Infomaximum/package-cli/compare/v2.0.0...v2.0.1) (2024-03-05)
6
22
 
7
23
 
package/dist/utils.js CHANGED
@@ -29,7 +29,7 @@ export function safeWriteFile(pathToFile, contents, options) {
29
29
  export function getLatestVersionOfLibrary(libraryName) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  const { stdout } = yield execPromise(`npm show -j -p ${libraryName} version`, {
32
- timeout: 5000,
32
+ timeout: 10000,
33
33
  });
34
34
  return JSON.parse(stdout);
35
35
  });
@@ -1,7 +1,9 @@
1
1
  import { JsonModifyWebpackPlugin } from "@infomaximum/json-modify-webpack-plugin";
2
2
  import { DEV_POSTFIX } from "../../../../../const.js";
3
3
  import { removeServiceFieldsForDevelopment } from "../../../../../utils.js";
4
- export const getModifyManifestWidgetPlugin = ({ host, port, isBuildDevMode, }) => {
4
+ import { WIDGET_SDK_VERSION_FIELD_NAME } from "../../../../const.js";
5
+ import { getSdkVersionFromPackageJson } from "../../../../utils.js";
6
+ export const getModifyManifestWidgetPlugin = ({ host, port, isBuildDevMode, WIDGET_PATHS, }) => {
5
7
  return new JsonModifyWebpackPlugin({
6
8
  matchers: [
7
9
  {
@@ -18,6 +20,9 @@ export const getModifyManifestWidgetPlugin = ({ host, port, isBuildDevMode, }) =
18
20
  });
19
21
  }
20
22
  }
23
+ const sdkVersion = getSdkVersionFromPackageJson(WIDGET_PATHS.appPackageJson);
24
+ currentJsonContent[WIDGET_SDK_VERSION_FIELD_NAME] = sdkVersion;
25
+ currentJsonContent["api_version"] = sdkVersion;
21
26
  removeServiceFieldsForDevelopment(currentJsonContent);
22
27
  return currentJsonContent;
23
28
  },
@@ -6,3 +6,4 @@ export const WIDGET_ARCHIVE_NAME = "widget";
6
6
  export const WIDGET_ARCHIVE_FULL_NAME = `${WIDGET_ARCHIVE_NAME}.${BUILD_ARCHIVE_EXT}`;
7
7
  export const WIDGET_DEFAULT_HOST = "localhost";
8
8
  export const WIDGET_DEFAULT_PORT = "5555";
9
+ export const WIDGET_SDK_VERSION_FIELD_NAME = "sdk_version";
@@ -15,7 +15,7 @@ import { generatePackagePaths } from "../../package/packagePaths.js";
15
15
  import { checkLatestLibsVersion } from "../utils.js";
16
16
  export const runBuild = (args) => __awaiter(void 0, void 0, void 0, function* () {
17
17
  const mode = "production";
18
- const { buildDir, host, port, dev: isBuildDevMode, packageDir, packageManifest, assetsDir, } = args;
18
+ const { buildDir, host, port, dev: isBuildDevMode, packageDir, packageManifest, } = args;
19
19
  const WIDGET_PATHS = generateWidgetPaths(args);
20
20
  const sections = {
21
21
  plugins: [
@@ -27,6 +27,7 @@ export const runBuild = (args) => __awaiter(void 0, void 0, void 0, function* ()
27
27
  isBuildDevMode,
28
28
  host,
29
29
  port,
30
+ WIDGET_PATHS,
30
31
  }),
31
32
  ],
32
33
  };
@@ -23,7 +23,7 @@ export const runDevServer = (options) => __awaiter(void 0, void 0, void 0, funct
23
23
  process.exit(1);
24
24
  }
25
25
  });
26
- const run = (PATHS, options) => __awaiter(void 0, void 0, void 0, function* () {
26
+ const run = (WIDGET_PATHS, options) => __awaiter(void 0, void 0, void 0, function* () {
27
27
  const { host, port } = options;
28
28
  const mode = "development";
29
29
  const pluginsSection = {
@@ -32,12 +32,13 @@ const run = (PATHS, options) => __awaiter(void 0, void 0, void 0, function* () {
32
32
  isBuildDevMode: true,
33
33
  host,
34
34
  port,
35
+ WIDGET_PATHS,
35
36
  }),
36
37
  getReactRefresh(),
37
38
  ],
38
39
  };
39
40
  const configWebpack = [
40
- getCommonWidgetConfig(mode, PATHS),
41
+ getCommonWidgetConfig(mode, WIDGET_PATHS),
41
42
  pluginsSection,
42
43
  devtoolSection,
43
44
  ];
@@ -49,5 +49,5 @@ class CustomWidget implements IWidget<WidgetSettings> {
49
49
  }
50
50
  }
51
51
 
52
- window.im.defineWidget(manifest.uuid, CustomWidget);
52
+ window.im.widget.defineWidget(manifest.uuid, CustomWidget);
53
53
  `;
@@ -5,8 +5,8 @@ export const WIDGET_RC_CONFIG = `\
5
5
  "$schema": "node_modules/${CUSTOM_PACKAGE_CLI_LIB_NAME}/schemas/widgetConfigSchema.json",
6
6
  "entry": "src/index.tsx",
7
7
  "widgetManifest": "${MANIFEST_JSON_FILE_NAME}",
8
- "packageManifest": "package/${MANIFEST_JSON_FILE_NAME}",
9
8
  "packageDir": "package",
9
+ "packageManifest": "package/${MANIFEST_JSON_FILE_NAME}",
10
10
  "assetsDir": "_resources",
11
11
  "buildDir": "${DEFAULT_BUILD_DIR_NAME}",
12
12
  "port": ${+WIDGET_DEFAULT_PORT},
@@ -1,7 +1,7 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import semver from "semver";
3
3
  import chalk from "chalk";
4
- import { getLatestVersionOfLibrary, getLibraryVersionInProject, } from "../utils.js";
4
+ import { getLatestVersionOfLibrary, getLibraryVersionInProject, systemRequire, } from "../utils.js";
5
5
  import { WIDGET_SDK_LIB_NAME } from "./const.js";
6
6
  import { CUSTOM_PACKAGE_CLI_LIB_NAME } from "../const.js";
7
7
  export function checkLatestVersion(libName) {
@@ -39,3 +39,20 @@ export function checkLatestLibsVersion() {
39
39
  catch (error) { }
40
40
  });
41
41
  }
42
+ export function getSdkVersionFromPackageJson(appPackageJsonPath) {
43
+ var _a;
44
+ const packageJson = systemRequire(appPackageJsonPath);
45
+ let version = 0;
46
+ for (const field of ["dependencies", "devDependencies"]) {
47
+ const tempVersion = (_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson[field]) === null || _a === void 0 ? void 0 : _a[WIDGET_SDK_LIB_NAME];
48
+ if (tempVersion && semver.valid(tempVersion)) {
49
+ version = semver.major(tempVersion);
50
+ break;
51
+ }
52
+ if (tempVersion && semver.validRange(tempVersion)) {
53
+ version = semver.major(semver.minVersion(tempVersion) || "0.0.0");
54
+ break;
55
+ }
56
+ }
57
+ return version;
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/package-cli",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "exports": "./dist/index.js",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "type": "object",
4
+ "additionalProperties": false,
4
5
  "properties": {
6
+ "$schema": {
7
+ "type": "string"
8
+ },
5
9
  "entry": {
6
10
  "type": "string",
7
11
  "description": "файл который является точкой входа"
@@ -14,9 +14,6 @@
14
14
  "pattern": "\\w+\\.js$",
15
15
  "examples": ["index.js", "main.js"]
16
16
  },
17
- "api_version": {
18
- "type": "integer"
19
- },
20
17
  "name": {
21
18
  "type": "object",
22
19
  "title": "Локализованное имя виджета",
@@ -52,5 +49,5 @@
52
49
  }
53
50
  }
54
51
  },
55
- "required": ["uuid", "entry", "api_version", "name"]
52
+ "required": ["uuid", "entry", "name"]
56
53
  }