@infomaximum/package-cli 2.23.0 → 2.24.0-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 +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/integration/commands/build.js +0 -1
- package/dist/integration/configs/webpack/FetchCodeToServerPlugin.d.ts +1 -0
- package/dist/integration/configs/webpack/FetchCodeToServerPlugin.js +4 -3
- package/dist/integration/scripts/build.js +1 -4
- package/dist/integration/scripts/init.d.ts +5 -0
- package/dist/integration/scripts/init.js +31 -1
- package/dist/integration/templates/integrationConfigs.d.ts +4 -2
- package/dist/integration/templates/integrationConfigs.js +11 -2
- package/dist/integration/templates/integrationIndex.d.ts +1 -1
- package/dist/integration/templates/integrationIndex.js +6 -8
- package/dist/integration/templates/integrationPackageJson.d.ts +1 -1
- package/dist/integration/templates/integrationPackageJson.js +4 -2
- package/dist/widget/commands/build_script.d.ts +7 -0
- package/dist/widget/commands/build_script.js +12 -0
- package/dist/widget/commands.js +2 -0
- package/dist/widget/configs/file.d.ts +2 -0
- package/dist/widget/configs/webpack/sections/plugins/minimizer.d.ts +1 -1
- package/dist/widget/scripts/build_script.d.ts +3 -0
- package/dist/widget/scripts/build_script.js +39 -0
- package/dist/widget/scripts/init/actions.js +1 -1
- package/dist/widget/templates/src/widgetIndex.d.ts +1 -1
- package/dist/widget/templates/src/widgetIndex.js +3 -1
- package/dist/widget/templates/widgetPackageJson.d.ts +1 -1
- package/dist/widget/templates/widgetPackageJson.js +10 -5
- package/dist/widget/templates/widgetRCConfig.js +15 -11
- package/dist/widget/widgetPaths.d.ts +2 -1
- package/package.json +6 -4
- package/schemas/widgetConfigSchema.json +5 -0
- package/dist/integration/configs/webpack/ASTIntegrationPreamblePlugin.d.ts +0 -10
- package/dist/integration/configs/webpack/ASTIntegrationPreamblePlugin.js +0 -67
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.24.0-0](https://github.com/Infomaximum/package-cli/compare/v2.23.1...v2.24.0-0) (2025-06-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* добавлена команда по сборки скрипта виджета ([2810b69](https://github.com/Infomaximum/package-cli/commit/2810b69d7637947f1b143eec064439338057f508))
|
|
11
|
+
* добавлена поддержка externals ([897eb0c](https://github.com/Infomaximum/package-cli/commit/897eb0cba2b3921f47c6d10d02de860b50d4c151))
|
|
12
|
+
|
|
13
|
+
### [2.23.1](https://github.com/Infomaximum/package-cli/compare/v2.23.0...v2.23.1) (2025-06-02)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* Изменение структуры ПИ, отключение флага experementa-transform ([1505f16](https://github.com/Infomaximum/package-cli/commit/1505f165cf8cfb1afc284f07543b0104724f014f))
|
|
19
|
+
|
|
5
20
|
## [2.23.0](https://github.com/Infomaximum/package-cli/compare/v2.22.6...v2.23.0) (2025-04-09)
|
|
6
21
|
|
|
7
22
|
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export const registerIntegrationBuildCommand = (integrationCommand) => {
|
|
|
16
16
|
.option("--copy", "копирование скрипта интеграции в буфер обмена", false)
|
|
17
17
|
.option("--fetchToServer", `отправка изменений на сервер (должен быть настроен файл ${INTEGRATION_CONFIG_RC_FILE_NAME}${INTEGRATION_CONFIG_RC_EXT})`, false)
|
|
18
18
|
.option("--beautify", `отформатировать код после сборки`, false)
|
|
19
|
-
.option("--experimental-transform", `эксперементальная функция по переносу общего кода в функции executePagination'`, false)
|
|
20
19
|
.action((options) => {
|
|
21
20
|
if (options.fetchToServer && typeof (config === null || config === void 0 ? void 0 : config.fetcher) !== "function") {
|
|
22
21
|
throw new Error("Не настроен конфиг или нет функции fetcher в конфиге");
|
|
@@ -3,14 +3,15 @@ import fs from "fs";
|
|
|
3
3
|
import crypto from "crypto";
|
|
4
4
|
export class FetchCodeToServerPlugin {
|
|
5
5
|
constructor({ fetcher }) {
|
|
6
|
+
this.name = "FetchCodeToServerPlugin";
|
|
6
7
|
this.fetcher = fetcher;
|
|
7
8
|
}
|
|
8
9
|
apply(compiler) {
|
|
9
|
-
compiler.hooks.afterEmit.tap(
|
|
10
|
+
compiler.hooks.afterEmit.tap(FetchCodeToServerPlugin.name, () => {
|
|
10
11
|
const outputPath = compiler.options.output.path || "";
|
|
11
12
|
let filename = compiler.options.output.filename;
|
|
12
13
|
if (typeof filename !== "string") {
|
|
13
|
-
console.warn(
|
|
14
|
+
console.warn(`⚠️ [${FetchCodeToServerPlugin.name}] Динамические имена файлов не поддерживаются.`);
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
const filePath = path.resolve(outputPath, filename);
|
|
@@ -39,7 +40,7 @@ export class FetchCodeToServerPlugin {
|
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
else {
|
|
42
|
-
console.warn(`⚠️ [FetchCodeToServerPlugin]
|
|
43
|
+
console.warn(`⚠️ [${FetchCodeToServerPlugin.name}] Файл ${filename} не найден.`);
|
|
43
44
|
}
|
|
44
45
|
});
|
|
45
46
|
}
|
|
@@ -9,9 +9,8 @@ import path from "path";
|
|
|
9
9
|
import { merge } from "webpack-merge";
|
|
10
10
|
import { CopyToClipboardPlugin } from "../configs/webpack/CopyToClipboardPlugin.js";
|
|
11
11
|
import { FetchCodeToServerPlugin } from "../configs/webpack/FetchCodeToServerPlugin.js";
|
|
12
|
-
import { ASTIntegrationPreamblePlugin } from "../configs/webpack/ASTIntegrationPreamblePlugin.js";
|
|
13
12
|
export const runBuildIntegration = (options, rcConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
const { entry, buildDir, packageDir, packageManifest, type, watch, copy, beautify: isBeautifyCode,
|
|
13
|
+
const { entry, buildDir, packageDir, packageManifest, type, watch, copy, beautify: isBeautifyCode, } = options;
|
|
15
14
|
const INTEGRATION_PATHS = generateIntegrationPaths({
|
|
16
15
|
entry,
|
|
17
16
|
buildDir,
|
|
@@ -33,8 +32,6 @@ export const runBuildIntegration = (options, rcConfig) => __awaiter(void 0, void
|
|
|
33
32
|
{
|
|
34
33
|
plugins: [
|
|
35
34
|
copy && new CopyToClipboardPlugin(),
|
|
36
|
-
experimentalTransform &&
|
|
37
|
-
new ASTIntegrationPreamblePlugin({ isBeautifyCode }),
|
|
38
35
|
options.fetchToServer &&
|
|
39
36
|
typeof fetcherFromConfig === "function" &&
|
|
40
37
|
new FetchCodeToServerPlugin({
|
|
@@ -12,6 +12,11 @@ declare const getInitIntegrationActions: () => Promise<(data: Answers) => ({
|
|
|
12
12
|
path: string;
|
|
13
13
|
template: string;
|
|
14
14
|
data?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
type: "add";
|
|
17
|
+
path: string;
|
|
18
|
+
template: undefined;
|
|
19
|
+
data?: undefined;
|
|
15
20
|
} | {
|
|
16
21
|
type: "add";
|
|
17
22
|
path: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { INTEGRATION_BABEL_CONFIG, INTEGRATION_ENV_EXAMPLE_CONFIG, INTEGRATION_ESLINTRC, INTEGRATION_GITIGNORE, INTEGRATION_RC_CONFIG, INTEGRATION_TSCONFIG_JSON, INTEGRATION_VITEST_CONFIG, INTEGRATION_VSCODE_EXTENSIONS, INTEGRATION_VSCODE_LAUNCH, INTEGRATION_VSCODE_SETTINGS, } from "../templates/integrationConfigs.js";
|
|
2
|
+
import { INTEGRATION_BABEL_CONFIG, INTEGRATION_ENV_EXAMPLE_CONFIG, INTEGRATION_ESLINTRC, INTEGRATION_GITIGNORE, INTEGRATION_HUSKY_COMMITMSG, INTEGRATION_HUSKY_PRECOMMIT, INTEGRATION_RC_CONFIG, INTEGRATION_TSCONFIG_JSON, INTEGRATION_VITEST_CONFIG, INTEGRATION_VSCODE_EXTENSIONS, INTEGRATION_VSCODE_LAUNCH, INTEGRATION_VSCODE_SETTINGS, } from "../templates/integrationConfigs.js";
|
|
3
3
|
import { getPackageActions } from "../../package/scripts/actions.js";
|
|
4
4
|
import { INTEGRATION_INDEX_TEMPLATE } from "../templates/integrationIndex.js";
|
|
5
5
|
import { INTEGRATION_PACKAGE_JSON_TEMPLATE } from "../templates/integrationPackageJson.js";
|
|
@@ -13,6 +13,26 @@ const actions = ({ packageCliVersion, integrationSdkVersion }) => {
|
|
|
13
13
|
path: "src/index.ts",
|
|
14
14
|
template: INTEGRATION_INDEX_TEMPLATE,
|
|
15
15
|
},
|
|
16
|
+
{
|
|
17
|
+
type: "add",
|
|
18
|
+
path: "src/types/common.d.ts",
|
|
19
|
+
template: undefined
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: "add",
|
|
23
|
+
path: "src/utils/index.ts",
|
|
24
|
+
template: ""
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "add",
|
|
28
|
+
path: "src/modules/template.ts",
|
|
29
|
+
template: ""
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "add",
|
|
33
|
+
path: "src/connections/base.ts",
|
|
34
|
+
template: ""
|
|
35
|
+
},
|
|
16
36
|
{
|
|
17
37
|
type: "add",
|
|
18
38
|
path: "tsconfig.json",
|
|
@@ -69,6 +89,16 @@ const actions = ({ packageCliVersion, integrationSdkVersion }) => {
|
|
|
69
89
|
path: ".vscode/extensions.json",
|
|
70
90
|
template: INTEGRATION_VSCODE_EXTENSIONS,
|
|
71
91
|
},
|
|
92
|
+
{
|
|
93
|
+
type: "add",
|
|
94
|
+
path: ".husky/commit-msg",
|
|
95
|
+
template: INTEGRATION_HUSKY_COMMITMSG,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "add",
|
|
99
|
+
path: ".husky/pre-commit",
|
|
100
|
+
template: INTEGRATION_HUSKY_PRECOMMIT,
|
|
101
|
+
},
|
|
72
102
|
];
|
|
73
103
|
};
|
|
74
104
|
const getInitIntegrationActions = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const INTEGRATION_TSCONFIG_JSON = "{\n \"compilerOptions\": {\n \"target\": \"
|
|
2
|
-
export declare const INTEGRATION_GITIGNORE = "# dependencies\n/node_modules\n/.pnp\n.pnp.js\n\n# testing\n/coverage\n\n# production\n/dist\n\n#documentation\n/docs\n\n# misc\n.DS_Store\n.env\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n/build\n.ultra.cache.json\n*.tsbuildinfo\n.node-xmlhttprequest-content-*\n.node-xmlhttprequest-sync-*\n";
|
|
1
|
+
export declare const INTEGRATION_TSCONFIG_JSON = "{\n \"compilerOptions\": {\n \"target\": \"ES2024\",\n \"lib\": [\"ES2024\",\"DOM\"],\n \"types\": [\"@infomaximum/integration-sdk\"],\n \"module\": \"Preserve\",\n \"esModuleInterop\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"strict\": true,\n \"skipLibCheck\": true,\n \"isolatedModules\": false\n },\n \"include\": [\"src\"]\n}\n";
|
|
2
|
+
export declare const INTEGRATION_GITIGNORE = "# dependencies\n/node_modules\n/.pnp\n.pnp.js\n\n# testing\n/coverage\n\n# production\n/dist\n\n#documentation\n/docs\n\n#package\n/package\n\n# misc\n.DS_Store\n.env\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n/build\n.ultra.cache.json\n*.tsbuildinfo\n.node-xmlhttprequest-content-*\n.node-xmlhttprequest-sync-*\n";
|
|
3
3
|
export declare const INTEGRATION_BABEL_CONFIG = "module.exports = {\n sourceType: \"unambiguous\",\n presets: [],\n plugins: [\"@babel/plugin-transform-block-scoping\"],\n};\n";
|
|
4
4
|
export declare const INTEGRATION_ESLINTRC = "const js = require(\"@eslint/js\");\nconst globals = require(\"globals\");\nconst tseslint = require(\"typescript-eslint\");\n\nmodule.exports = tseslint.config(\n { ignores: [\"dist\", \"build\", \"node_modules\"] },\n {\n extends: [js.configs.recommended, ...tseslint.configs.recommended],\n files: [\"**/*.{ts,tsx}\"],\n languageOptions: {\n ecmaVersion: 2020,\n globals: globals.browser,\n },\n plugins: {},\n rules: {\n \"@typescript-eslint/no-explicit-any\": \"warn\",\n },\n }\n);\n";
|
|
5
5
|
export declare const INTEGRATION_VITEST_CONFIG = "import { defineConfig } from 'vitest/config';\n\nexport default defineConfig({\n test: {\n coverage: {\n provider:'v8',\n exclude: [\n '**/*.config.*',\n 'src/index.ts',\n ],\n },\n },\n});\n";
|
|
@@ -8,3 +8,5 @@ export declare const INTEGRATION_ENV_EXAMPLE_CONFIG = "INTEGRATION_ID=0\nGRAPHQL
|
|
|
8
8
|
export declare const INTEGRATION_VSCODE_LAUNCH: string;
|
|
9
9
|
export declare const INTEGRATION_VSCODE_SETTINGS = "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\",\n \"integration-debugger.isEnabled\": true,\n \"integration-debugger.debugConfigurationName\": \"Debug Integration\",\n \"integration-debugger.functionNames\": {\n \"single\": [\"executePagination\", \"execute\"],\n \"series\": [\"executePagination\"]\n }\n}\n";
|
|
10
10
|
export declare const INTEGRATION_VSCODE_EXTENSIONS = "{\n \"recommendations\": [\"Jokerok.integration-debugger\"]\n}\n";
|
|
11
|
+
export declare const INTEGRATION_HUSKY_PRECOMMIT = "yarn lint\n";
|
|
12
|
+
export declare const INTEGRATION_HUSKY_COMMITMSG = "yarn commitlint --edit $1\n";
|
|
@@ -3,8 +3,8 @@ import { INTEGRATION_SDK_LIB_NAME } from "../const.js";
|
|
|
3
3
|
export const INTEGRATION_TSCONFIG_JSON = `\
|
|
4
4
|
{
|
|
5
5
|
"compilerOptions": {
|
|
6
|
-
"target": "
|
|
7
|
-
"lib": ["
|
|
6
|
+
"target": "ES2024",
|
|
7
|
+
"lib": ["ES2024","DOM"],
|
|
8
8
|
"types": ["${INTEGRATION_SDK_LIB_NAME}"],
|
|
9
9
|
"module": "Preserve",
|
|
10
10
|
"esModuleInterop": true,
|
|
@@ -31,6 +31,9 @@ export const INTEGRATION_GITIGNORE = `\
|
|
|
31
31
|
#documentation
|
|
32
32
|
/docs
|
|
33
33
|
|
|
34
|
+
#package
|
|
35
|
+
/package
|
|
36
|
+
|
|
34
37
|
# misc
|
|
35
38
|
.DS_Store
|
|
36
39
|
.env
|
|
@@ -184,3 +187,9 @@ export const INTEGRATION_VSCODE_EXTENSIONS = `\
|
|
|
184
187
|
"recommendations": ["Jokerok.integration-debugger"]
|
|
185
188
|
}
|
|
186
189
|
`;
|
|
190
|
+
export const INTEGRATION_HUSKY_PRECOMMIT = `\
|
|
191
|
+
yarn lint
|
|
192
|
+
`;
|
|
193
|
+
export const INTEGRATION_HUSKY_COMMITMSG = `\
|
|
194
|
+
yarn commitlint --edit $1
|
|
195
|
+
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const INTEGRATION_INDEX_TEMPLATE = "
|
|
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,12 +1,10 @@
|
|
|
1
1
|
export const INTEGRATION_INDEX_TEMPLATE = `\
|
|
2
|
-
|
|
2
|
+
const app = {
|
|
3
3
|
schema: 1,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
blocks: [],
|
|
10
|
-
connections: [],
|
|
4
|
+
version:"0.0.1",
|
|
5
|
+
label:"Integration_template",
|
|
6
|
+
description:"",
|
|
7
|
+
blocks: {},
|
|
8
|
+
connections: {},
|
|
11
9
|
};
|
|
12
10
|
`;
|
|
@@ -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 },\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 }\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 }\n}\n";
|
|
@@ -14,7 +14,8 @@ export const INTEGRATION_PACKAGE_JSON_TEMPLATE = `\
|
|
|
14
14
|
"test": "vitest --run",
|
|
15
15
|
"test:coverage": "vitest --run --coverage",
|
|
16
16
|
"test:ui": "vitest --ui",
|
|
17
|
-
"debug": "node --import tsx ./node_modules/.bin/im-package-cli integration debug"
|
|
17
|
+
"debug": "node --import tsx ./node_modules/.bin/im-package-cli integration debug",
|
|
18
|
+
"prepare": "husky"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@babel/plugin-transform-block-scoping": "^7.25.9",
|
|
@@ -30,7 +31,8 @@ export const INTEGRATION_PACKAGE_JSON_TEMPLATE = `\
|
|
|
30
31
|
"typescript-eslint": "^8.29.0",
|
|
31
32
|
"vitest": "^3.0.4",
|
|
32
33
|
"@vitest/coverage-v8": "3.0.7",
|
|
33
|
-
"@vitest/ui": "3.0.7"
|
|
34
|
+
"@vitest/ui": "3.0.7",
|
|
35
|
+
"husky": "^9.1.7"
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
};
|
package/dist/widget/commands.js
CHANGED
|
@@ -2,10 +2,12 @@ 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";
|
|
5
6
|
export const registerWidgetCommands = (cli) => {
|
|
6
7
|
const widgetCommand = cli.command("widget");
|
|
7
8
|
registerWidgetBuildCommand(widgetCommand);
|
|
8
9
|
registerWidgetStartCommand(widgetCommand);
|
|
9
10
|
registerWidgetInitCommand(widgetCommand);
|
|
10
11
|
registerWidgetReleaseCommand(widgetCommand);
|
|
12
|
+
registerWidgetBuildScriptCommand(widgetCommand);
|
|
11
13
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SystemWidgetExternals } from "@infomaximum/widget-sdk";
|
|
1
2
|
export type WidgetRCConfig = {
|
|
2
3
|
entry: string;
|
|
3
4
|
widgetManifest: string;
|
|
@@ -7,5 +8,6 @@ export type WidgetRCConfig = {
|
|
|
7
8
|
buildDir: string;
|
|
8
9
|
port: number;
|
|
9
10
|
host: string;
|
|
11
|
+
externals?: Partial<SystemWidgetExternals>;
|
|
10
12
|
};
|
|
11
13
|
export declare const getConfigFromFile: () => WidgetRCConfig | undefined;
|
|
@@ -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:
|
|
6
|
+
splitChunks: false;
|
|
7
7
|
minimizer: (TerserWebpackPlugin<import("terser").MinifyOptions> | CssMinimizerPlugin<CssMinimizerPlugin.CssNanoOptionsExtended>)[];
|
|
8
8
|
};
|
|
9
9
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
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),
|
|
23
|
+
{
|
|
24
|
+
externals: (_a = config === null || config === void 0 ? void 0 : config.externals) !== 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
|
+
});
|
|
@@ -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";
|
|
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 +1 @@
|
|
|
1
|
-
export declare const WIDGET_PACKAGE_JSON_TEMPLATE = "{\n \"name\": \"template_widget\",\n \"version\": \"1.0.0\",\n \"
|
|
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,19 +1,24 @@
|
|
|
1
|
-
import { CUSTOM_PACKAGE_CLI_LIB_NAME } from "../../const.js";
|
|
2
|
-
import { WIDGET_SDK_LIB_NAME } from "../const.js";
|
|
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";
|
|
3
3
|
export const WIDGET_PACKAGE_JSON_TEMPLATE = `\
|
|
4
4
|
{
|
|
5
5
|
"name": "template_widget",
|
|
6
6
|
"version": "1.0.0",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"main": "${DEFAULT_BUILD_DIR_NAME}/${WIDGET_OUTPUT_FULL_FILE_NAME}",
|
|
8
|
+
"files": [
|
|
9
|
+
"build",
|
|
10
|
+
"manifest.json"
|
|
11
|
+
],
|
|
9
12
|
"scripts": {
|
|
10
13
|
"build": "im-package-cli widget build",
|
|
14
|
+
"build:script": "im-package-cli widget build-script",
|
|
11
15
|
"build:dev": "im-package-cli widget build --dev",
|
|
12
16
|
"start": "im-package-cli widget start",
|
|
13
17
|
"lint": "tsc --noEmit && eslint src/ --ext .ts,.tsx --quiet",
|
|
14
18
|
"test": "jest --passWithNoTests",
|
|
15
19
|
"release": "im-package-cli widget release",
|
|
16
|
-
"changelog":"im-package-cli widget release --dry-run"
|
|
20
|
+
"changelog":"im-package-cli widget release --dry-run",
|
|
21
|
+
"prepublishOnly": "npm run build:script"
|
|
17
22
|
},
|
|
18
23
|
"dependencies": {
|
|
19
24
|
"${WIDGET_SDK_LIB_NAME}": "{{widgetSDKVersion}}",
|
|
@@ -1,15 +1,19 @@
|
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
}
|
|
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;
|
|
15
19
|
`;
|
|
@@ -1,7 +1,8 @@
|
|
|
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";
|
|
3
4
|
export type WidgetPaths = ReturnType<typeof generateWidgetPaths>;
|
|
4
|
-
type Options = MergedBuildOptions | MergedStartOptions;
|
|
5
|
+
type Options = MergedBuildOptions | MergedStartOptions | MergedBuildScriptOptions;
|
|
5
6
|
export declare function generateWidgetPaths({ entry, assetsDir, widgetManifest, buildDir, }: Options): {
|
|
6
7
|
moduleIndex: string;
|
|
7
8
|
widgetManifestJsonPath: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infomaximum/package-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0-0",
|
|
4
4
|
"exports": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -18,9 +18,11 @@
|
|
|
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
|
|
21
|
+
"release": "tsc --noEmit && standard-version",
|
|
22
|
+
"release:rc": "standard-version -p",
|
|
22
23
|
"lint": "tsc --noEmit",
|
|
23
|
-
"prettier": "prettier --find-config-path --write 'lib/**/*'"
|
|
24
|
+
"prettier": "prettier --find-config-path --write 'lib/**/*'",
|
|
25
|
+
"prepublishOnly": "npm run lint && npm run build"
|
|
24
26
|
},
|
|
25
27
|
"dependencies": {
|
|
26
28
|
"@babel/core": "^7.23.6",
|
|
@@ -29,7 +31,6 @@
|
|
|
29
31
|
"@infomaximum/integration-debugger": "^1.7.0",
|
|
30
32
|
"@infomaximum/json-modify-webpack-plugin": "^1.1.0",
|
|
31
33
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
|
32
|
-
"@saneksa/babel-plugin-function-transform": "^1.0.0",
|
|
33
34
|
"@svgr/webpack": "^8.1.0",
|
|
34
35
|
"autoprefixer": "^10.4.16",
|
|
35
36
|
"babel-loader": "^9.1.3",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
74
75
|
"@infomaximum/integration-sdk": "^2.3.0",
|
|
76
|
+
"@infomaximum/widget-sdk": "5.26.0-0",
|
|
75
77
|
"@types/babel__core": "^7.20.5",
|
|
76
78
|
"@types/fs-extra": "^11.0.4",
|
|
77
79
|
"@types/node": "^20.9.0",
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"host": {
|
|
40
40
|
"type": "string",
|
|
41
41
|
"description": "хост по которому будет доступен сервер разработки"
|
|
42
|
+
},
|
|
43
|
+
"externals": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"additionalProperties": true,
|
|
46
|
+
"description": "исключает указанные зависимости из сборки, предполагая их наличие в окружении. Используется для уменьшения размера бандла. Актуально только при сборке скрипта. (https://webpack.js.org/configuration/externals/)"
|
|
42
47
|
}
|
|
43
48
|
},
|
|
44
49
|
"required": [
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Compiler } from "webpack";
|
|
2
|
-
type ASTIntegrationPreamblePluginParams = {
|
|
3
|
-
isBeautifyCode: boolean;
|
|
4
|
-
};
|
|
5
|
-
export declare class ASTIntegrationPreamblePlugin {
|
|
6
|
-
private isBeautifyCode;
|
|
7
|
-
constructor({ isBeautifyCode }: ASTIntegrationPreamblePluginParams);
|
|
8
|
-
apply(compiler: Compiler): void;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { __asyncValues, __awaiter } from "tslib";
|
|
2
|
-
import { systemRequire } from "../../../utils.js";
|
|
3
|
-
import { transformSync } from "@babel/core";
|
|
4
|
-
import webpack, {} from "webpack";
|
|
5
|
-
import { minify } from "terser";
|
|
6
|
-
import { TERSER_OPTIONS } from "./utils.js";
|
|
7
|
-
const { Compilation } = webpack;
|
|
8
|
-
function minifyCode(code, isBeautifyCode) {
|
|
9
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
10
|
-
const result = yield minify(code, TERSER_OPTIONS(isBeautifyCode));
|
|
11
|
-
if (result.code) {
|
|
12
|
-
return result.code;
|
|
13
|
-
}
|
|
14
|
-
throw new Error("Минификация не удалась");
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export class ASTIntegrationPreamblePlugin {
|
|
18
|
-
constructor({ isBeautifyCode }) {
|
|
19
|
-
this.isBeautifyCode = isBeautifyCode;
|
|
20
|
-
}
|
|
21
|
-
apply(compiler) {
|
|
22
|
-
compiler.hooks.compilation.tap("ASTIntegrationPreamblePlugin", (compilation) => {
|
|
23
|
-
compilation.hooks.processAssets.tapPromise({
|
|
24
|
-
name: "ASTIntegrationPreamblePlugin",
|
|
25
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_REPORT,
|
|
26
|
-
}, (assets) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
var _a, e_1, _b, _c;
|
|
28
|
-
var _d, _e;
|
|
29
|
-
try {
|
|
30
|
-
for (var _f = true, _g = __asyncValues(Object.entries(assets)), _h; _h = yield _g.next(), _a = _h.done, !_a; _f = true) {
|
|
31
|
-
_c = _h.value;
|
|
32
|
-
_f = false;
|
|
33
|
-
const [filename, source] = _c;
|
|
34
|
-
if (!filename.endsWith(".js"))
|
|
35
|
-
return;
|
|
36
|
-
const { RawSource } = compiler.webpack.sources;
|
|
37
|
-
const output = (_e = (_d = transformSync(source.source().toString(), {
|
|
38
|
-
sourceType: "unambiguous",
|
|
39
|
-
babelrc: false,
|
|
40
|
-
configFile: false,
|
|
41
|
-
plugins: [
|
|
42
|
-
[
|
|
43
|
-
systemRequire.resolve("@saneksa/babel-plugin-function-transform"),
|
|
44
|
-
{
|
|
45
|
-
functionName: "executePagination",
|
|
46
|
-
fieldName: "integration",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
],
|
|
50
|
-
})) === null || _d === void 0 ? void 0 : _d.code) === null || _e === void 0 ? void 0 : _e.trim();
|
|
51
|
-
if (output) {
|
|
52
|
-
const outputCode = yield minifyCode(output, this.isBeautifyCode);
|
|
53
|
-
compilation.updateAsset(filename, new RawSource(outputCode));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
58
|
-
finally {
|
|
59
|
-
try {
|
|
60
|
-
if (!_f && !_a && (_b = _g.return)) yield _b.call(_g);
|
|
61
|
-
}
|
|
62
|
-
finally { if (e_1) throw e_1.error; }
|
|
63
|
-
}
|
|
64
|
-
}));
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|