@infomaximum/package-cli 2.24.0-2 → 2.25.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +8 -8
  2. package/dist/application/applicationPaths.d.ts +15 -0
  3. package/dist/application/applicationPaths.js +9 -0
  4. package/dist/application/commands/build.d.ts +21 -0
  5. package/dist/application/commands/build.js +18 -0
  6. package/dist/application/commands/common.d.ts +16 -0
  7. package/dist/application/commands/common.js +28 -0
  8. package/dist/application/commands/init.d.ts +2 -0
  9. package/dist/application/commands/init.js +15 -0
  10. package/dist/application/commands/start.d.ts +18 -0
  11. package/dist/application/commands/start.js +23 -0
  12. package/dist/application/commands.d.ts +2 -0
  13. package/dist/application/commands.js +9 -0
  14. package/dist/application/configs/file.d.ts +10 -0
  15. package/dist/application/configs/file.js +11 -0
  16. package/dist/application/configs/webpack/common.d.ts +4 -0
  17. package/dist/application/configs/webpack/common.js +139 -0
  18. package/dist/application/configs/webpack/sections/devServer.d.ts +21 -0
  19. package/dist/application/configs/webpack/sections/devServer.js +19 -0
  20. package/dist/application/configs/webpack/sections/devtool.d.ts +3 -0
  21. package/dist/application/configs/webpack/sections/devtool.js +3 -0
  22. package/dist/application/configs/webpack/sections/loaders/cssLoaders.d.ts +8 -0
  23. package/dist/application/configs/webpack/sections/loaders/cssLoaders.js +16 -0
  24. package/dist/application/configs/webpack/sections/plugins/minimizer.d.ts +9 -0
  25. package/dist/application/configs/webpack/sections/plugins/minimizer.js +23 -0
  26. package/dist/application/configs/webpack/sections/plugins/modifyManifestApplication.d.ts +10 -0
  27. package/dist/application/configs/webpack/sections/plugins/modifyManifestApplication.js +35 -0
  28. package/dist/application/configs/webpack/sections/plugins/reactRefresh.d.ts +2 -0
  29. package/dist/application/configs/webpack/sections/plugins/reactRefresh.js +4 -0
  30. package/dist/application/configs/webpack/sections/plugins/zipApplication.d.ts +6 -0
  31. package/dist/application/configs/webpack/sections/plugins/zipApplication.js +11 -0
  32. package/dist/application/const.d.ts +10 -0
  33. package/dist/application/const.js +11 -0
  34. package/dist/application/index.d.ts +1 -0
  35. package/dist/application/index.js +1 -0
  36. package/dist/application/scripts/build.d.ts +2 -0
  37. package/dist/application/scripts/build.js +63 -0
  38. package/dist/application/scripts/init.d.ts +23 -0
  39. package/dist/application/scripts/init.js +60 -0
  40. package/dist/application/scripts/start.d.ts +2 -0
  41. package/dist/application/scripts/start.js +61 -0
  42. package/dist/application/templates/applicationConfigs.d.ts +3 -0
  43. package/dist/application/templates/applicationConfigs.js +60 -0
  44. package/dist/application/templates/applicationManifest.d.ts +1 -0
  45. package/dist/application/templates/applicationManifest.js +11 -0
  46. package/dist/application/templates/applicationPackageJson.d.ts +1 -0
  47. package/dist/application/templates/applicationPackageJson.js +29 -0
  48. package/dist/application/templates/applicationRCConfig.d.ts +1 -0
  49. package/dist/application/templates/applicationRCConfig.js +14 -0
  50. package/dist/application/templates/src/applicationContent.d.ts +1 -0
  51. package/dist/application/templates/src/applicationContent.js +11 -0
  52. package/dist/application/templates/src/applicationIndex.d.ts +1 -0
  53. package/dist/application/templates/src/applicationIndex.js +34 -0
  54. package/dist/arguments.js +2 -0
  55. package/dist/index.d.ts +0 -1
  56. package/dist/integration/scripts/init.d.ts +0 -5
  57. package/dist/integration/scripts/init.js +10 -5
  58. package/dist/integration/templates/integrationConfigs.d.ts +3 -2
  59. package/dist/integration/templates/integrationConfigs.js +134 -19
  60. package/dist/integration/templates/integrationIndex.d.ts +1 -1
  61. package/dist/integration/templates/integrationIndex.js +2 -2
  62. package/dist/integration/templates/integrationPackageJson.d.ts +1 -1
  63. package/dist/integration/templates/integrationPackageJson.js +7 -1
  64. package/dist/types.d.ts +1 -1
  65. package/dist/widget/commands.js +0 -2
  66. package/dist/widget/configs/file.d.ts +0 -2
  67. package/dist/widget/configs/webpack/common.d.ts +1 -1
  68. package/dist/widget/configs/webpack/common.js +6 -4
  69. package/dist/widget/configs/webpack/sections/plugins/minimizer.d.ts +1 -1
  70. package/dist/widget/scripts/init/actions.js +1 -1
  71. package/dist/widget/templates/src/widgetIndex.d.ts +1 -1
  72. package/dist/widget/templates/src/widgetIndex.js +1 -3
  73. package/dist/widget/templates/widgetPackageJson.d.ts +1 -1
  74. package/dist/widget/templates/widgetPackageJson.js +5 -10
  75. package/dist/widget/templates/widgetRCConfig.js +11 -15
  76. package/dist/widget/widgetPaths.d.ts +1 -2
  77. package/package.json +3 -6
  78. package/schemas/applicationConfigSchema.json +48 -0
  79. package/schemas/applicationManifestSchema.json +29 -0
  80. package/schemas/widgetConfigSchema.json +0 -5
  81. package/dist/widget/commands/build_script.d.ts +0 -7
  82. package/dist/widget/commands/build_script.js +0 -12
  83. package/dist/widget/scripts/build_script.d.ts +0 -3
  84. package/dist/widget/scripts/build_script.js +0 -39
@@ -31,8 +31,6 @@ export const INTEGRATION_GITIGNORE = `\
31
31
  #documentation
32
32
  /docs
33
33
 
34
- #package
35
- /package
36
34
 
37
35
  # misc
38
36
  .DS_Store
@@ -60,24 +58,136 @@ module.exports = {
60
58
  };
61
59
  `;
62
60
  export const INTEGRATION_ESLINTRC = `\
63
- const js = require("@eslint/js");
64
- const globals = require("globals");
65
- const tseslint = require("typescript-eslint");
66
-
67
- module.exports = tseslint.config(
68
- { ignores: ["dist", "build", "node_modules"] },
69
- {
70
- extends: [js.configs.recommended, ...tseslint.configs.recommended],
71
- files: ["**/*.{ts,tsx}"],
72
- languageOptions: {
73
- ecmaVersion: 2020,
74
- globals: globals.browser,
75
- },
76
- plugins: {},
77
- rules: {
78
- "@typescript-eslint/no-explicit-any": "warn",
61
+ import eslint from "@eslint/js";
62
+ import { defineConfig } from "eslint/config";
63
+ import tseslint from "typescript-eslint";
64
+ import fp from "eslint-plugin-fp";
65
+ import sonarPlugin from "eslint-plugin-sonarjs";
66
+ export default defineConfig(
67
+ eslint.configs.recommended,
68
+ tseslint.configs.recommended,
69
+ tseslint.configs.strict,
70
+ tseslint.configs.stylistic,
71
+
72
+ [
73
+ {
74
+ ignores: [
75
+ "**/dist/**",
76
+ "**/build/**",
77
+ "**/node_modules/**",
78
+ "**/*.config.js",
79
+ "**/*.config.cjs",
80
+ "**/*.config.mjs",
81
+ ],
82
+ files: ["**/*.ts", "**/*.tsx"],
83
+ languageOptions: {
84
+ ecmaVersion: "latest",
85
+ sourceType: "module",
86
+ parserOptions: {
87
+ project: "./tsconfig.json",
88
+ },
89
+ },
90
+ plugins: {
91
+ "@typescript-eslint": tseslint.plugin,
92
+ fp,
93
+ sonarjs: sonarPlugin,
94
+ },
95
+ rules: {
96
+ "@typescript-eslint/no-unused-vars": [
97
+ "error",
98
+ {
99
+ argsIgnorePattern: "^_",
100
+ varsIgnorePattern: "^_",
101
+ },
102
+ ],
103
+ "@typescript-eslint/no-explicit-any": "warn",
104
+ "@typescript-eslint/consistent-type-definitions": [
105
+ "error",
106
+ "interface",
107
+ ],
108
+ "@typescript-eslint/explicit-function-return-type": [
109
+ "error",
110
+ {
111
+ allowExpressions: true,
112
+ allowTypedFunctionExpressions: true,
113
+ },
114
+ ],
115
+ "@typescript-eslint/naming-convention": [
116
+ "error",
117
+ {
118
+ selector: ["variable", "function"],
119
+ format: ["camelCase"],
120
+ leadingUnderscore: "allow",
121
+ trailingUnderscore: "forbid",
122
+ },
123
+
124
+ {
125
+ selector: ["typeLike", "class"],
126
+ format: ["PascalCase"],
127
+ },
128
+ {
129
+ selector: "interface",
130
+ format: ["PascalCase"],
131
+ custom: {
132
+ regex: "^I[A-Z]",
133
+ match: true,
134
+ },
135
+ },
136
+ {
137
+ selector: "typeAlias",
138
+ format: ["PascalCase"],
139
+ custom: {
140
+ regex: "^T[A-Z]",
141
+ match: true,
142
+ },
143
+ },
144
+ {
145
+ selector: "enum",
146
+ format: ["PascalCase"],
147
+ custom: {
148
+ regex: "^E[A-Z]",
149
+ match: true,
150
+ },
151
+ },
152
+ {
153
+ selector: "enumMember",
154
+ format: ["PascalCase"],
155
+ },
156
+ {
157
+ selector: "method",
158
+ format: ["camelCase"],
159
+ },
160
+ {
161
+ selector: "parameter",
162
+ format: ["camelCase"],
163
+ leadingUnderscore: "allow",
164
+ },
165
+ ],
166
+ "@typescript-eslint/prefer-for-of": "error",
167
+ "prefer-const": "error",
168
+ "no-var": "error",
169
+ "prefer-arrow-callback": "error",
170
+
171
+ eqeqeq: ["error", "always"],
172
+ yoda: "error",
173
+ "no-lonely-if": "error",
174
+ curly: "error",
175
+ // Ограчичение на количество строк в функции, чтобы поощрять более мелкие, более управляемые функции.
176
+ "max-lines-per-function": [
177
+ "error",
178
+ { max: 100, skipComments: true, skipBlankLines: true },
179
+ ],
180
+ "max-depth": ["error", { max: 3 }],
181
+
182
+ "no-param-reassign": ["error", { props: true }],
183
+ //sonarjs правила
184
+ "sonarjs/cognitive-complexity": ["error", 10],
185
+ "sonarjs/no-identical-expressions": "error",
186
+ "sonarjs/no-ignored-return": "error",
187
+ "sonarjs/no-redundant-boolean": "error",
188
+ },
79
189
  },
80
- }
190
+ ]
81
191
  );
82
192
  `;
83
193
  export const INTEGRATION_VITEST_CONFIG = `\
@@ -193,3 +303,8 @@ yarn lint
193
303
  export const INTEGRATION_HUSKY_COMMITMSG = `\
194
304
  yarn commitlint --edit $1
195
305
  `;
306
+ export const INTEGRATION_COMMITLINT_CONFIG = `\
307
+ {
308
+ "extends": ["@commitlint/config-conventional"]
309
+ }
310
+ `;
@@ -1 +1 @@
1
- export declare const INTEGRATION_INDEX_TEMPLATE = "const app = {\n schema: 1,\n version:\"0.0.1\",\n label:\"Integration_template\",\n description:\"\",\n blocks: {},\n connections: {},\n};\n";
1
+ export declare const INTEGRATION_INDEX_TEMPLATE = "app = {\n schema: 2,\n version:\"0.0.1\",\n label:\"Integration_template\",\n description:\"\",\n blocks: {},\n connections: {},\n};\n";
@@ -1,6 +1,6 @@
1
1
  export const INTEGRATION_INDEX_TEMPLATE = `\
2
- const app = {
3
- schema: 1,
2
+ app = {
3
+ schema: 2,
4
4
  version:"0.0.1",
5
5
  label:"Integration_template",
6
6
  description:"",
@@ -1 +1 @@
1
- export declare const INTEGRATION_PACKAGE_JSON_TEMPLATE = "{\n \"name\": \"template_integration\",\n \"version\": \"1.0.0\",\n \"main\": \"src/index.ts\",\n \"scripts\": {\n \"build\": \"im-package-cli integration build\",\n \"build:script\": \"im-package-cli integration build --type=script --beautify\",\n \"dev\": \"im-package-cli integration build --watch --beautify\",\n \"serve\": \"im-package-cli integration build --watch --fetchToServer --beautify\",\n \"lint\": \"tsc --noEmit && eslint src/ --ext .ts,.tsx --quiet\",\n \"test\": \"vitest --run\",\n \"test:coverage\": \"vitest --run --coverage\",\n \"test:ui\": \"vitest --ui\",\n \"debug\": \"node --import tsx ./node_modules/.bin/im-package-cli integration debug\",\n \"prepare\": \"husky\"\n },\n \"devDependencies\": {\n \"@babel/plugin-transform-block-scoping\": \"^7.25.9\",\n \"@eslint/js\": \"^9.23.0\",\n \"@infomaximum/integration-sdk\": \"^{{integrationSdkVersion}}\",\n \"@infomaximum/package-cli\": \"^{{packageCliVersion}}\",\n \"@types/node\": \"^0\",\n \"dotenv\": \"^16.4.7\",\n \"eslint\": \"^9.23.0\",\n \"globals\": \"^15.14.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.2\",\n \"typescript-eslint\": \"^8.29.0\",\n \"vitest\": \"^3.0.4\",\n \"@vitest/coverage-v8\": \"3.0.7\",\n \"@vitest/ui\": \"3.0.7\",\n \"husky\": \"^9.1.7\"\n }\n}\n";
1
+ export declare const INTEGRATION_PACKAGE_JSON_TEMPLATE = "{\n \"name\": \"template_integration\",\n \"version\": \"1.0.0\",\n \"main\": \"src/index.ts\",\n \"scripts\": {\n \"build\": \"im-package-cli integration build\",\n \"build:script\": \"im-package-cli integration build --type=script --beautify\",\n \"dev\": \"im-package-cli integration build --watch --beautify\",\n \"serve\": \"im-package-cli integration build --watch --fetchToServer --beautify\",\n \"lint\": \"tsc --noEmit && eslint src/ --ext .ts,.tsx --quiet\",\n \"test\": \"vitest --run\",\n \"test:coverage\": \"vitest --run --coverage\",\n \"test:ui\": \"vitest --ui\",\n \"debug\": \"node --import tsx ./node_modules/.bin/im-package-cli integration debug\",\n \"prepare\": \"husky\"\n },\n \"devDependencies\": {\n \"@babel/plugin-transform-block-scoping\": \"^7.25.9\",\n \"@eslint/js\": \"^9.23.0\",\n \"@infomaximum/integration-sdk\": \"^{{integrationSdkVersion}}\",\n \"@infomaximum/package-cli\": \"^{{packageCliVersion}}\",\n \"@types/node\": \"^0\",\n \"dotenv\": \"^16.4.7\",\n \"eslint\": \"^9.23.0\",\n \"globals\": \"^15.14.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.2\",\n \"typescript-eslint\": \"^8.29.0\",\n \"vitest\": \"^3.0.4\",\n \"@vitest/coverage-v8\": \"3.0.7\",\n \"@vitest/ui\": \"3.0.7\",\n \"husky\": \"^9.1.7\",\n \"eslint-plugin-fp\": \"^2.3.0\",\n \"eslint-plugin-sonarjs\": \"^3.0.5\",\n \"@commitlint/cli\": \"^19.8.1\",\n \"@commitlint/config-conventional\": \"^19.8.1\",\n \"@infomaximum/config\": \"^2.7.0\",\n \"commitlint\": \"^19.8.1\"\n }\n}\n";
@@ -32,7 +32,13 @@ export const INTEGRATION_PACKAGE_JSON_TEMPLATE = `\
32
32
  "vitest": "^3.0.4",
33
33
  "@vitest/coverage-v8": "3.0.7",
34
34
  "@vitest/ui": "3.0.7",
35
- "husky": "^9.1.7"
35
+ "husky": "^9.1.7",
36
+ "eslint-plugin-fp": "^2.3.0",
37
+ "eslint-plugin-sonarjs": "^3.0.5",
38
+ "@commitlint/cli": "^19.8.1",
39
+ "@commitlint/config-conventional": "^19.8.1",
40
+ "@infomaximum/config": "^2.7.0",
41
+ "commitlint": "^19.8.1"
36
42
  }
37
43
  }
38
44
  `;
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- export type PackageType = "widget" | "integration";
1
+ export type PackageType = "widget" | "integration" | "application";
@@ -2,12 +2,10 @@ import { registerWidgetBuildCommand } from "./commands/build.js";
2
2
  import { registerWidgetStartCommand } from "./commands/start.js";
3
3
  import { registerWidgetInitCommand } from "./commands/init.js";
4
4
  import { registerWidgetReleaseCommand } from "./commands/release.js";
5
- import { registerWidgetBuildScriptCommand } from "./commands/build_script.js";
6
5
  export const registerWidgetCommands = (cli) => {
7
6
  const widgetCommand = cli.command("widget");
8
7
  registerWidgetBuildCommand(widgetCommand);
9
8
  registerWidgetStartCommand(widgetCommand);
10
9
  registerWidgetInitCommand(widgetCommand);
11
10
  registerWidgetReleaseCommand(widgetCommand);
12
- registerWidgetBuildScriptCommand(widgetCommand);
13
11
  };
@@ -1,4 +1,3 @@
1
- import type { SystemWidgetExternals } from "@infomaximum/widget-sdk";
2
1
  export type WidgetRCConfig = {
3
2
  entry: string;
4
3
  widgetManifest: string;
@@ -8,6 +7,5 @@ export type WidgetRCConfig = {
8
7
  buildDir: string;
9
8
  port: number;
10
9
  host: string;
11
- externalsLib?: Partial<SystemWidgetExternals>;
12
10
  };
13
11
  export declare const getConfigFromFile: () => WidgetRCConfig | undefined;
@@ -1,4 +1,4 @@
1
1
  import { type Configuration } from "webpack";
2
2
  import type { Mode } from "../../../paths.js";
3
3
  import type { WidgetPaths } from "../../widgetPaths.js";
4
- export declare const getCommonWidgetConfig: (mode: Mode, PATHS: WidgetPaths, isCopyResources?: boolean) => Configuration;
4
+ export declare const getCommonWidgetConfig: (mode: Mode, PATHS: WidgetPaths) => Configuration;
@@ -9,7 +9,7 @@ import { WIDGET_OUTPUT_FILE_NAME, WIDGET_OUTPUT_FULL_FILE_NAME, } from "../../co
9
9
  const { ProgressPlugin } = webpack;
10
10
  const isProduction = (mode) => mode === "production";
11
11
  const isDevelopment = (mode) => mode === "development";
12
- export const getCommonWidgetConfig = (mode, PATHS, isCopyResources = true) => {
12
+ export const getCommonWidgetConfig = (mode, PATHS) => {
13
13
  const manifestEntry = systemRequire(PATHS.widgetManifestJsonPath).entry;
14
14
  const filename = isProduction(mode)
15
15
  ? `${WIDGET_OUTPUT_FILE_NAME}.[contenthash].js`
@@ -34,8 +34,7 @@ export const getCommonWidgetConfig = (mode, PATHS, isCopyResources = true) => {
34
34
  },
35
35
  },
36
36
  }),
37
- isCopyResources &&
38
- PATHS.widgetResourcesPath &&
37
+ PATHS.widgetResourcesPath &&
39
38
  PATHS.widgetResourcesDirName &&
40
39
  new CopyWebpackPlugin({
41
40
  patterns: [
@@ -116,9 +115,12 @@ export const getCommonWidgetConfig = (mode, PATHS, isCopyResources = true) => {
116
115
  resourceQuery: /url/,
117
116
  parser: {
118
117
  dataUrlCondition: {
119
- maxSize: Infinity,
118
+ maxSize: 64 * 1024,
120
119
  },
121
120
  },
121
+ generator: {
122
+ filename: "build/static/[hash][ext][query]",
123
+ },
122
124
  },
123
125
  {
124
126
  type: "asset/source",
@@ -3,7 +3,7 @@ import TerserWebpackPlugin from "terser-webpack-plugin";
3
3
  export declare const getMinimizer: () => {
4
4
  optimization: {
5
5
  minimize: boolean;
6
- splitChunks: false;
6
+ splitChunks: boolean;
7
7
  minimizer: (TerserWebpackPlugin<import("terser").MinifyOptions> | CssMinimizerPlugin<CssMinimizerPlugin.CssNanoOptionsExtended>)[];
8
8
  };
9
9
  };
@@ -81,7 +81,7 @@ const actions = ({ widgetSDKVersion, packageCliVersion }) => {
81
81
  },
82
82
  {
83
83
  type: "add",
84
- path: "widgetrc.js",
84
+ path: "widgetrc.json",
85
85
  template: WIDGET_RC_CONFIG,
86
86
  },
87
87
  {
@@ -1 +1 @@
1
- export declare const WIDGET_INDEX_TEMPLATE = "import React from \"react\";\nimport ReactDOM from \"react-dom/client\";\nimport \"./index.css\";\nimport {\n type IWidget,\n type ICustomWidgetProps,\n} from \"@infomaximum/widget-sdk\";\nimport manifest from \"../manifest.json\";\nimport { type WidgetSettings } from \"./definition/settings\";\nimport { Definition } from \"./definition/definition\";\n\nclass CustomWidget implements IWidget<WidgetSettings> {\n public static definition = new Definition();\n\n private root: ReactDOM.Root | null = null;\n\n public initialize(container: HTMLElement) {\n this.root = ReactDOM.createRoot(container);\n }\n\n public update(\n container: HTMLElement,\n props: ICustomWidgetProps<WidgetSettings>\n ) {\n this.render(props);\n }\n\n public mount(\n container: HTMLElement,\n props: ICustomWidgetProps<WidgetSettings>\n ) {\n this.render(props);\n }\n\n public unmount() {\n this.root?.unmount();\n }\n\n private render(props: ICustomWidgetProps<WidgetSettings>) {\n this.root?.render(\n <React.StrictMode>\n <div>{{ capitalize packageName}}</div>\n </React.StrictMode>\n );\n }\n}\n\nwindow.im.widget.defineWidget(manifest.uuid, CustomWidget, {\n manifest,\n});\n";
1
+ export declare const WIDGET_INDEX_TEMPLATE = "import React from \"react\";\nimport ReactDOM from \"react-dom/client\";\nimport \"./index.css\";\nimport {\n type IWidget,\n type ICustomWidgetProps,\n} from \"@infomaximum/widget-sdk\";\nimport manifest from \"../manifest.json\";\nimport { type WidgetSettings } from \"./definition/settings\";\nimport { Definition } from \"./definition/definition\";\n\nclass CustomWidget implements IWidget<WidgetSettings> {\n public static definition = new Definition();\n\n private root: ReactDOM.Root | null = null;\n\n public initialize(container: HTMLElement) {\n this.root = ReactDOM.createRoot(container);\n }\n\n public update(\n container: HTMLElement,\n props: ICustomWidgetProps<WidgetSettings>\n ) {\n this.render(props);\n }\n\n public mount(\n container: HTMLElement,\n props: ICustomWidgetProps<WidgetSettings>\n ) {\n this.render(props);\n }\n\n public unmount() {\n this.root?.unmount();\n }\n\n private render(props: ICustomWidgetProps<WidgetSettings>) {\n this.root?.render(\n <React.StrictMode>\n <div>{{ capitalize packageName}}</div>\n </React.StrictMode>\n );\n }\n}\n\nwindow.im.widget.defineWidget(manifest.uuid, CustomWidget);\n";
@@ -49,7 +49,5 @@ class CustomWidget implements IWidget<WidgetSettings> {
49
49
  }
50
50
  }
51
51
 
52
- window.im.widget.defineWidget(manifest.uuid, CustomWidget, {
53
- manifest,
54
- });
52
+ window.im.widget.defineWidget(manifest.uuid, CustomWidget);
55
53
  `;
@@ -1 +1 @@
1
- export declare const WIDGET_PACKAGE_JSON_TEMPLATE = "{\n \"name\": \"template_widget\",\n \"version\": \"1.0.0\",\n \"main\": \"build/widget.js\",\n \"files\": [\n \"build\",\n \"manifest.json\"\n ],\n \"scripts\": {\n \"build\": \"im-package-cli widget build\",\n \"build:script\": \"im-package-cli widget build-script\",\n \"build:dev\": \"im-package-cli widget build --dev\",\n \"start\": \"im-package-cli widget start\",\n \"lint\": \"tsc --noEmit && eslint src/ --ext .ts,.tsx --quiet\",\n \"test\": \"jest --passWithNoTests\",\n \"release\": \"im-package-cli widget release\",\n \"changelog\":\"im-package-cli widget release --dry-run\",\n \"prepublishOnly\": \"npm run build:script\"\n },\n \"dependencies\": {\n \"@infomaximum/widget-sdk\": \"{{widgetSDKVersion}}\",\n \"react\": \"18.3.1\",\n \"react-dom\": \"18.3.1\"\n },\n \"devDependencies\": {\n \"@babel/core\": \"7.25.2\",\n \"@babel/preset-env\": \"7.25.4\",\n \"@babel/preset-react\": \"7.24.7\",\n \"@babel/preset-typescript\": \"7.24.7\",\n \"@infomaximum/package-cli\": \"^{{packageCliVersion}}\",\n \"@types/jest\": \"29.5.11\",\n \"@types/react\": \"18.3.4\",\n \"@types/react-dom\": \"18.3.0\",\n \"@typescript-eslint/eslint-plugin\": \"8.3.0\",\n \"@typescript-eslint/parser\": \"8.3.0\",\n \"eslint\": \"8.57.0\",\n \"eslint-plugin-react\": \"7.35.0\",\n \"eslint-plugin-react-hooks\": \"4.6.2\",\n \"jest\": \"29.7.0\",\n \"jest-canvas-mock\": \"2.5.2\",\n \"jest-environment-jsdom\": \"29.7.0\",\n \"jest-environment-jsdom-global\": \"4.0.0\",\n \"prettier\": \"3.1.1\",\n \"typescript\": \"5.5.4\"\n },\n \"browserslist\": [\n \"defaults and supports es6-module\"\n ]\n}\n";
1
+ export declare const WIDGET_PACKAGE_JSON_TEMPLATE = "{\n \"name\": \"template_widget\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"main\": \"src/index.tsx\",\n \"scripts\": {\n \"build\": \"im-package-cli widget build\",\n \"build:dev\": \"im-package-cli widget build --dev\",\n \"start\": \"im-package-cli widget start\",\n \"lint\": \"tsc --noEmit && eslint src/ --ext .ts,.tsx --quiet\",\n \"test\": \"jest --passWithNoTests\",\n \"release\": \"im-package-cli widget release\",\n \"changelog\":\"im-package-cli widget release --dry-run\"\n },\n \"dependencies\": {\n \"@infomaximum/widget-sdk\": \"{{widgetSDKVersion}}\",\n \"react\": \"18.3.1\",\n \"react-dom\": \"18.3.1\"\n },\n \"devDependencies\": {\n \"@babel/core\": \"7.25.2\",\n \"@babel/preset-env\": \"7.25.4\",\n \"@babel/preset-react\": \"7.24.7\",\n \"@babel/preset-typescript\": \"7.24.7\",\n \"@infomaximum/package-cli\": \"^{{packageCliVersion}}\",\n \"@types/jest\": \"29.5.11\",\n \"@types/react\": \"18.3.4\",\n \"@types/react-dom\": \"18.3.0\",\n \"@typescript-eslint/eslint-plugin\": \"8.3.0\",\n \"@typescript-eslint/parser\": \"8.3.0\",\n \"eslint\": \"8.57.0\",\n \"eslint-plugin-react\": \"7.35.0\",\n \"eslint-plugin-react-hooks\": \"4.6.2\",\n \"jest\": \"29.7.0\",\n \"jest-canvas-mock\": \"2.5.2\",\n \"jest-environment-jsdom\": \"29.7.0\",\n \"jest-environment-jsdom-global\": \"4.0.0\",\n \"prettier\": \"3.1.1\",\n \"typescript\": \"5.5.4\"\n },\n \"browserslist\": [\n \"defaults and supports es6-module\"\n ]\n}\n";
@@ -1,24 +1,19 @@
1
- import { CUSTOM_PACKAGE_CLI_LIB_NAME, DEFAULT_BUILD_DIR_NAME, } from "../../const.js";
2
- import { WIDGET_OUTPUT_FULL_FILE_NAME, WIDGET_SDK_LIB_NAME } from "../const.js";
1
+ import { CUSTOM_PACKAGE_CLI_LIB_NAME } from "../../const.js";
2
+ import { WIDGET_SDK_LIB_NAME } from "../const.js";
3
3
  export const WIDGET_PACKAGE_JSON_TEMPLATE = `\
4
4
  {
5
5
  "name": "template_widget",
6
6
  "version": "1.0.0",
7
- "main": "${DEFAULT_BUILD_DIR_NAME}/${WIDGET_OUTPUT_FULL_FILE_NAME}",
8
- "files": [
9
- "build",
10
- "manifest.json"
11
- ],
7
+ "private": true,
8
+ "main": "src/index.tsx",
12
9
  "scripts": {
13
10
  "build": "im-package-cli widget build",
14
- "build:script": "im-package-cli widget build-script",
15
11
  "build:dev": "im-package-cli widget build --dev",
16
12
  "start": "im-package-cli widget start",
17
13
  "lint": "tsc --noEmit && eslint src/ --ext .ts,.tsx --quiet",
18
14
  "test": "jest --passWithNoTests",
19
15
  "release": "im-package-cli widget release",
20
- "changelog":"im-package-cli widget release --dry-run",
21
- "prepublishOnly": "npm run build:script"
16
+ "changelog":"im-package-cli widget release --dry-run"
22
17
  },
23
18
  "dependencies": {
24
19
  "${WIDGET_SDK_LIB_NAME}": "{{widgetSDKVersion}}",
@@ -1,19 +1,15 @@
1
1
  import { CUSTOM_PACKAGE_CLI_LIB_NAME, DEFAULT_BUILD_DIR_NAME, MANIFEST_JSON_FILE_NAME, } from "../../const.js";
2
2
  import { WIDGET_DEFAULT_HOST, WIDGET_DEFAULT_PORT } from "../const.js";
3
3
  export const WIDGET_RC_CONFIG = `\
4
- //@ts-check
5
-
6
- /** @type {import("${CUSTOM_PACKAGE_CLI_LIB_NAME}").WidgetRCConfig} */
7
- const config = {
8
- entry: "src/index.tsx",
9
- widgetManifest: "${MANIFEST_JSON_FILE_NAME}",
10
- packageDir: "package",
11
- packageManifest: "package/${MANIFEST_JSON_FILE_NAME}",
12
- assetsDir: "_resources",
13
- buildDir: "${DEFAULT_BUILD_DIR_NAME}",
14
- port: ${+WIDGET_DEFAULT_PORT},
15
- host: "${WIDGET_DEFAULT_HOST}",
16
- };
17
-
18
- module.exports = config;
4
+ {
5
+ "$schema": "node_modules/${CUSTOM_PACKAGE_CLI_LIB_NAME}/schemas/widgetConfigSchema.json",
6
+ "entry": "src/index.tsx",
7
+ "widgetManifest": "${MANIFEST_JSON_FILE_NAME}",
8
+ "packageDir": "package",
9
+ "packageManifest": "package/${MANIFEST_JSON_FILE_NAME}",
10
+ "assetsDir": "_resources",
11
+ "buildDir": "${DEFAULT_BUILD_DIR_NAME}",
12
+ "port": ${+WIDGET_DEFAULT_PORT},
13
+ "host": "${WIDGET_DEFAULT_HOST}"
14
+ }
19
15
  `;
@@ -1,8 +1,7 @@
1
1
  import type { MergedBuildOptions } from "./commands/build.js";
2
2
  import type { MergedStartOptions } from "./commands/start.js";
3
- import type { MergedBuildScriptOptions } from "./commands/build_script.js";
4
3
  export type WidgetPaths = ReturnType<typeof generateWidgetPaths>;
5
- type Options = MergedBuildOptions | MergedStartOptions | MergedBuildScriptOptions;
4
+ type Options = MergedBuildOptions | MergedStartOptions;
6
5
  export declare function generateWidgetPaths({ entry, assetsDir, widgetManifest, buildDir, }: Options): {
7
6
  moduleIndex: string;
8
7
  widgetManifestJsonPath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/package-cli",
3
- "version": "2.24.0-2",
3
+ "version": "2.25.0",
4
4
  "exports": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -18,11 +18,9 @@
18
18
  "dev": "tsc",
19
19
  "dev:w": "npm run dev -- -w",
20
20
  "build": "rimraf dist && npm run dev",
21
- "release": "tsc --noEmit && standard-version",
22
- "release:rc": "standard-version -p",
21
+ "release": "tsc --noEmit && standard-version && npm run build",
23
22
  "lint": "tsc --noEmit",
24
- "prettier": "prettier --find-config-path --write 'lib/**/*'",
25
- "prepublishOnly": "npm run lint && npm run build"
23
+ "prettier": "prettier --find-config-path --write 'lib/**/*'"
26
24
  },
27
25
  "dependencies": {
28
26
  "@babel/core": "^7.23.6",
@@ -73,7 +71,6 @@
73
71
  },
74
72
  "devDependencies": {
75
73
  "@infomaximum/integration-sdk": "^2.3.0",
76
- "@infomaximum/widget-sdk": "5.26.0-0",
77
74
  "@types/babel__core": "^7.20.5",
78
75
  "@types/fs-extra": "^11.0.4",
79
76
  "@types/node": "^20.9.0",
@@ -0,0 +1,48 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "properties": {
6
+ "$schema": {
7
+ "type": "string"
8
+ },
9
+ "entry": {
10
+ "type": "string",
11
+ "description": "файл который является точкой входа"
12
+ },
13
+ "applicationManifest": {
14
+ "type": "string",
15
+ "description": "путь до файла манифеста приложения"
16
+ },
17
+ "packageManifest": {
18
+ "type": "string",
19
+ "description": "путь до файла манифеста пакета"
20
+ },
21
+ "packageDir": {
22
+ "type": "string",
23
+ "description": "директория с файлами пакета"
24
+ },
25
+ "buildDir": {
26
+ "type": "string",
27
+ "description": "директория в которую будет осуществляться сборка проекта"
28
+ },
29
+ "port": {
30
+ "type": "integer",
31
+ "minimum": 0,
32
+ "maximum": 65535,
33
+ "description": "порт по которому будет доступен сервер разработки"
34
+ },
35
+ "host": {
36
+ "type": "string",
37
+ "description": "хост по которому будет доступен сервер разработки"
38
+ }
39
+ },
40
+ "required": [
41
+ "entry",
42
+ "applicationManifest",
43
+ "packageManifest",
44
+ "packageDir",
45
+ "port",
46
+ "host"
47
+ ]
48
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "entry": {
6
+ "type": "string",
7
+ "title": "Имя файла в который будет собрано приложение",
8
+ "description": "Если не задан, то будет сгенерирован application.[contenthash].js",
9
+ "pattern": "\\w+\\.js$",
10
+ "examples": ["index.js", "main.js"]
11
+ },
12
+ "name": {
13
+ "type": "object",
14
+ "title": "Локализованное имя приложения",
15
+ "required": ["ru", "en"],
16
+ "properties": {
17
+ "en": {
18
+ "type": "string",
19
+ "minLength": 1
20
+ },
21
+ "ru": {
22
+ "type": "string",
23
+ "minLength": 1
24
+ }
25
+ }
26
+ }
27
+ },
28
+ "required": ["name"]
29
+ }
@@ -39,11 +39,6 @@
39
39
  "host": {
40
40
  "type": "string",
41
41
  "description": "хост по которому будет доступен сервер разработки"
42
- },
43
- "externalsLib": {
44
- "type": "object",
45
- "additionalProperties": true,
46
- "description": "исключает указанные зависимости из сборки, предполагая их наличие в окружении. Используется для уменьшения размера бандла. Актуально только при сборке скрипта. (https://webpack.js.org/configuration/externals/)"
47
42
  }
48
43
  },
49
44
  "required": [
@@ -1,7 +0,0 @@
1
- import type { Command } from "commander";
2
- import { configMergeWithOptionsCommon, type InputCommonOptions } from "./common.js";
3
- export type InputBuildScriptOptions = {
4
- buildDir?: string;
5
- } & InputCommonOptions;
6
- export type MergedBuildScriptOptions = ReturnType<typeof configMergeWithOptionsCommon>;
7
- export declare const registerWidgetBuildScriptCommand: (widgetCommand: Command) => void;
@@ -1,12 +0,0 @@
1
- import { getConfigFromFile } from "../configs/file.js";
2
- import { configMergeWithOptionsCommon, registerCommonOption, } from "./common.js";
3
- import { runBuildScript } from "../scripts/build_script.js";
4
- export const registerWidgetBuildScriptCommand = (widgetCommand) => {
5
- const widgetBuildScriptCommand = widgetCommand.command("build-script");
6
- const config = getConfigFromFile();
7
- registerCommonOption(widgetBuildScriptCommand);
8
- widgetBuildScriptCommand
9
- .description("Выполняет сборку js файла виджета для публикации")
10
- .option("--build-dir <buildDirPath>", "путь до директории в которую будет собран пакет")
11
- .action((options) => runBuildScript(configMergeWithOptionsCommon(config, options), config));
12
- };
@@ -1,3 +0,0 @@
1
- import type { MergedBuildScriptOptions } from "../commands/build_script.js";
2
- import type { WidgetRCConfig } from "../configs/file.js";
3
- export declare const runBuildScript: (args: MergedBuildScriptOptions, config: WidgetRCConfig | undefined) => Promise<void>;
@@ -1,39 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import {} from "webpack";
3
- import {} from "../../paths.js";
4
- import { merge } from "webpack-merge";
5
- import chalk from "chalk";
6
- import { getCommonWidgetConfig } from "../configs/webpack/common.js";
7
- import { getMinimizer } from "../configs/webpack/sections/plugins/minimizer.js";
8
- import { generateWidgetPaths } from "../widgetPaths.js";
9
- import { runWebpackBuild } from "../../utils.js";
10
- import { WIDGET_OUTPUT_FULL_FILE_NAME } from "../const.js";
11
- export const runBuildScript = (args, config) => __awaiter(void 0, void 0, void 0, function* () {
12
- var _a;
13
- const mode = "production";
14
- const WIDGET_PATHS = generateWidgetPaths(args);
15
- const sections = {
16
- entry: WIDGET_PATHS.moduleIndex,
17
- output: {
18
- filename: WIDGET_OUTPUT_FULL_FILE_NAME,
19
- },
20
- };
21
- const configSections = [
22
- getCommonWidgetConfig(mode, WIDGET_PATHS, false),
23
- {
24
- externals: (_a = config === null || config === void 0 ? void 0 : config.externalsLib) !== null && _a !== void 0 ? _a : {},
25
- externalsType: "window",
26
- },
27
- sections,
28
- getMinimizer(),
29
- ];
30
- const widgetConfig = merge(configSections);
31
- try {
32
- yield runWebpackBuild(widgetConfig);
33
- }
34
- catch (error) {
35
- console.error(chalk.red("\nFailed to compile.\n"));
36
- console.error(chalk.red(error));
37
- process.exit(1);
38
- }
39
- });