@infomaximum/package-cli 2.11.0 → 2.12.0-rc.1
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/README.md +15 -1
- package/dist/arguments.js +2 -0
- package/dist/const.js +1 -0
- package/dist/integration/commands/build.js +13 -0
- package/dist/integration/commands/init.js +15 -0
- package/dist/integration/commands.js +7 -0
- package/dist/integration/configs/webpack/common.js +50 -0
- package/dist/integration/const.js +1 -0
- package/dist/integration/index.js +1 -0
- package/dist/integration/integrationPaths.js +12 -0
- package/dist/integration/scripts/actions.js +53 -0
- package/dist/integration/scripts/build.js +48 -0
- package/dist/integration/templates/integrationConfigs.js +68 -0
- package/dist/integration/templates/integrationIndex.js +15 -0
- package/dist/integration/templates/integrationPackageJson.js +28 -0
- package/dist/package/commands.js +5 -0
- package/dist/package/configs/webpack/buildPackage.js +7 -6
- package/dist/package/packagePaths.js +2 -2
- package/dist/package/scripts/actions.js +36 -0
- package/dist/package/templates/packageManifest.js +2 -2
- package/dist/paths.js +2 -2
- package/dist/plopHelpers.js +38 -1
- package/dist/types.js +1 -0
- package/dist/utils.js +23 -0
- package/dist/widget/commands/common.js +2 -2
- package/dist/widget/commands/init.js +10 -4
- package/dist/widget/scripts/build.js +5 -24
- package/dist/widget/scripts/init/actions.js +1 -3
- package/dist/widget/scripts/release/release.js +1 -1
- package/dist/widget/templates/src/definition/definition.js +1 -10
- package/dist/widget/templates/src/widgetIndex.js +1 -1
- package/dist/widget/widgetPaths.js +1 -1
- package/package.json +1 -1
- package/schemas/packageManifestSchema.json +1 -1
- package/dist/widget/scripts/init/generators.js +0 -15
- package/dist/widget/scripts/init/init.js +0 -33
- /package/dist/{widget/scripts/init → package/scripts}/prompts.js +0 -0
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
<img alt="npm" src="https://img.shields.io/npm/v/@infomaximum/package-cli?style=for-the-badge">
|
|
7
7
|
</a>
|
|
8
8
|
|
|
9
|
+
---
|
|
10
|
+
|
|
9
11
|
## Разработка виджета
|
|
10
12
|
|
|
11
13
|
### Инициализация проекта
|
|
@@ -97,7 +99,7 @@
|
|
|
97
99
|
|
|
98
100
|
Эта конфигурация определяет, как будет собираться и запускаться ваш пакет с использованием `@infomaximum/package-cli`.
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
### Версионирование `(2.10.0)`
|
|
101
103
|
|
|
102
104
|
`@infomaximum/package-cli` реализует возможность автоматизированного [семантического версионирования](https://semver.org/lang/ru/) для управления версиями пакетов. Версия пакета автоматически вычисляется на основе сообщений коммитов в репозиторий:
|
|
103
105
|
|
|
@@ -110,6 +112,18 @@
|
|
|
110
112
|
Создать релиз можно используя команду
|
|
111
113
|
`yarn im-package-cli widget release`
|
|
112
114
|
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Разработка интеграции
|
|
118
|
+
|
|
119
|
+
### Инициализация проекта
|
|
120
|
+
|
|
121
|
+
Для создания нового пакета с интеграцией необходимо выполнить следующую команду:
|
|
122
|
+
|
|
123
|
+
`npx @infomaximum/package-cli integration init my_integration`
|
|
124
|
+
|
|
125
|
+
После выполнения данной команды будет создан шаблонный проект **my_integration** и инициализирован git репозиторий.
|
|
126
|
+
|
|
113
127
|
## Вывод всех доступных команд
|
|
114
128
|
|
|
115
129
|
Вы можете использовать флаг `-h`, чтобы просмотреть список всех доступных команд и их описаний:
|
package/dist/arguments.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { systemRequire } from "./utils.js";
|
|
2
2
|
import { registerWidgetCommands } from "./widget/index.js";
|
|
3
|
+
import { registerIntegrationCommands } from "./integration/index.js";
|
|
3
4
|
const packageJson = systemRequire("../package.json");
|
|
4
5
|
export const registerCommands = (cli) => {
|
|
5
6
|
cli.helpOption("-h", "отображает помощь по командам");
|
|
6
7
|
cli.name("im-package-cli");
|
|
7
8
|
cli.version(packageJson.version, "-v, --version", "текущая версия библиотеки");
|
|
8
9
|
registerWidgetCommands(cli);
|
|
10
|
+
registerIntegrationCommands(cli);
|
|
9
11
|
};
|
package/dist/const.js
CHANGED
|
@@ -5,3 +5,4 @@ export const MANIFEST_REG_EXP = new RegExp(`${MANIFEST_JSON_FILE_NAME}$`, "i");
|
|
|
5
5
|
export const DEV_POSTFIX = "__DEV";
|
|
6
6
|
export const DEFAULT_BUILD_DIR_NAME = "build";
|
|
7
7
|
export const MANIFEST_SERVICE_FIELDS_FOR_DEVELOPMENT = ["$schema"];
|
|
8
|
+
export const AVAILABLE_LANGUAGES = ["ru", "en"];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { runBuildIntegration } from "../scripts/build.js";
|
|
2
|
+
import { registerPackageOptions, } from "../../package/commands.js";
|
|
3
|
+
export const registerIntegrationBuildCommand = (integrationCommand) => {
|
|
4
|
+
const integrationBuildCommand = integrationCommand.command("build");
|
|
5
|
+
registerPackageOptions(integrationBuildCommand);
|
|
6
|
+
integrationBuildCommand
|
|
7
|
+
.description("Выполняет сборку пакета c интеграцией")
|
|
8
|
+
.option("--entry <path>", "путь до entrypoint", "src/index.ts")
|
|
9
|
+
.option("--build-dir <buildDirPath>", "путь до директории в которую будет собран пакет", "build")
|
|
10
|
+
.option("--type <buildType>", "тип сборки, <package> - сборка пакета (в архив), <script> - сборка в js файл", "package")
|
|
11
|
+
.option("--watch", "при изменении файлов скрипт будет пересобран", false)
|
|
12
|
+
.action((options) => runBuildIntegration(options));
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { runInitEntityScript } from "../../plopHelpers.js";
|
|
3
|
+
import { getInitIntegrationActions } from "../scripts/actions.js";
|
|
4
|
+
export const registerIntegrationInitCommand = (integrationCommand) => {
|
|
5
|
+
const widgetInitCommand = integrationCommand.command("init <project-directory>");
|
|
6
|
+
widgetInitCommand
|
|
7
|
+
.description("Инициализация проекта интеграции")
|
|
8
|
+
.action((dirName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
runInitEntityScript({
|
|
10
|
+
dirName,
|
|
11
|
+
entity: "integration",
|
|
12
|
+
actions: yield getInitIntegrationActions(),
|
|
13
|
+
});
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { registerIntegrationInitCommand } from "./commands/init.js";
|
|
2
|
+
import { registerIntegrationBuildCommand } from "./commands/build.js";
|
|
3
|
+
export const registerIntegrationCommands = (cli) => {
|
|
4
|
+
const integrationCommand = cli.command("integration");
|
|
5
|
+
registerIntegrationInitCommand(integrationCommand);
|
|
6
|
+
registerIntegrationBuildCommand(integrationCommand);
|
|
7
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import TerserPlugin from "terser-webpack-plugin";
|
|
2
|
+
import { systemRequire } from "../../../utils.js";
|
|
3
|
+
export const getCommonIntegrationConfig = (mode, PATHS) => {
|
|
4
|
+
return {
|
|
5
|
+
mode,
|
|
6
|
+
entry: PATHS.moduleIndex,
|
|
7
|
+
output: {
|
|
8
|
+
filename: PATHS.outputFile,
|
|
9
|
+
path: PATHS.appBuildPath,
|
|
10
|
+
clean: true,
|
|
11
|
+
libraryTarget: "module",
|
|
12
|
+
},
|
|
13
|
+
experiments: {
|
|
14
|
+
outputModule: true,
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
extensions: [".ts", ".js", ".json"],
|
|
18
|
+
},
|
|
19
|
+
module: {
|
|
20
|
+
rules: [
|
|
21
|
+
{
|
|
22
|
+
test: /\.(js|ts|jsx|tsx)$/i,
|
|
23
|
+
exclude: ["/node_modules/"],
|
|
24
|
+
loader: systemRequire.resolve("babel-loader"),
|
|
25
|
+
options: {
|
|
26
|
+
plugins: [
|
|
27
|
+
systemRequire.resolve("babel-plugin-inline-json-import"),
|
|
28
|
+
systemRequire.resolve("@babel/plugin-transform-runtime"),
|
|
29
|
+
].filter(Boolean),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
optimization: {
|
|
35
|
+
minimize: true,
|
|
36
|
+
concatenateModules: true,
|
|
37
|
+
splitChunks: false,
|
|
38
|
+
runtimeChunk: false,
|
|
39
|
+
minimizer: [
|
|
40
|
+
new TerserPlugin({
|
|
41
|
+
terserOptions: {
|
|
42
|
+
compress: {
|
|
43
|
+
booleans: false,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const INTEGRATION_SDK_LIB_NAME = "@infomaximum/integration-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { registerIntegrationCommands } from "./commands.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { generatePackagePaths } from "../package/packagePaths.js";
|
|
2
|
+
import { generateIndexPath } from "../paths.js";
|
|
3
|
+
export function generateIntegrationPaths({ entry, buildDir, packageDir, packageManifest, }) {
|
|
4
|
+
const packagePaths = generatePackagePaths({
|
|
5
|
+
buildDir,
|
|
6
|
+
packageDir,
|
|
7
|
+
packageManifest,
|
|
8
|
+
});
|
|
9
|
+
return Object.assign(Object.assign({}, packagePaths), { outputFile: "integration.js", get moduleIndex() {
|
|
10
|
+
return generateIndexPath(entry);
|
|
11
|
+
} });
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { CUSTOM_PACKAGE_CLI_LIB_NAME } from "../../const.js";
|
|
3
|
+
import { INTEGRATION_BABEL_CONFIG, INTEGRATION_ESLINTRC, INTEGRATION_GITIGNORE, INTEGRATION_TSCONFIG_JSON, } from "../templates/integrationConfigs.js";
|
|
4
|
+
import { getPackageActions } from "../../package/scripts/actions.js";
|
|
5
|
+
import { INTEGRATION_INDEX_TEMPLATE } from "../templates/integrationIndex.js";
|
|
6
|
+
import { INTEGRATION_PACKAGE_JSON_TEMPLATE } from "../templates/integrationPackageJson.js";
|
|
7
|
+
import { getLatestVersionOfLibrary } from "../../utils.js";
|
|
8
|
+
import { INTEGRATION_SDK_LIB_NAME } from "../const.js";
|
|
9
|
+
const actions = ({ packageCliVersion, integrationSdkVersion }) => {
|
|
10
|
+
return [
|
|
11
|
+
...getPackageActions({ packageType: "integration" }),
|
|
12
|
+
{
|
|
13
|
+
type: "add",
|
|
14
|
+
path: "src/index.ts",
|
|
15
|
+
template: INTEGRATION_INDEX_TEMPLATE,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: "add",
|
|
19
|
+
path: "tsconfig.json",
|
|
20
|
+
template: INTEGRATION_TSCONFIG_JSON,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "add",
|
|
24
|
+
path: "babel.config.js",
|
|
25
|
+
template: INTEGRATION_BABEL_CONFIG,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: "add",
|
|
29
|
+
path: ".gitignore",
|
|
30
|
+
template: INTEGRATION_GITIGNORE,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "add",
|
|
34
|
+
path: "eslint.config.js",
|
|
35
|
+
template: INTEGRATION_ESLINTRC,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: "add",
|
|
39
|
+
path: "package.json",
|
|
40
|
+
template: INTEGRATION_PACKAGE_JSON_TEMPLATE,
|
|
41
|
+
data: { packageCliVersion, integrationSdkVersion },
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
};
|
|
45
|
+
const getInitIntegrationActions = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const [packageCliVersion, integrationSdkVersion] = yield Promise.all([
|
|
47
|
+
getLatestVersionOfLibrary(CUSTOM_PACKAGE_CLI_LIB_NAME),
|
|
48
|
+
getLatestVersionOfLibrary(INTEGRATION_SDK_LIB_NAME),
|
|
49
|
+
]);
|
|
50
|
+
return (data) => actions(Object.assign(Object.assign({}, data), { packageCliVersion,
|
|
51
|
+
integrationSdkVersion }));
|
|
52
|
+
});
|
|
53
|
+
export { getInitIntegrationActions };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import webpack, {} from "webpack";
|
|
3
|
+
import { handleWebpackCallback, runWebpackBuild } from "../../utils.js";
|
|
4
|
+
import { getCommonIntegrationConfig } from "../configs/webpack/common.js";
|
|
5
|
+
import { generateIntegrationPaths } from "../integrationPaths.js";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { getPackageBuildConfig } from "../../package/configs/webpack/buildPackage.js";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { merge } from "webpack-merge";
|
|
10
|
+
export const runBuildIntegration = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
const { entry, buildDir, packageDir, packageManifest, type, watch } = options;
|
|
12
|
+
const INTEGRATION_PATHS = generateIntegrationPaths({
|
|
13
|
+
entry,
|
|
14
|
+
buildDir,
|
|
15
|
+
packageDir,
|
|
16
|
+
packageManifest,
|
|
17
|
+
});
|
|
18
|
+
const mode = "production";
|
|
19
|
+
const commonConfig = getCommonIntegrationConfig(mode, INTEGRATION_PATHS);
|
|
20
|
+
const config = merge([
|
|
21
|
+
commonConfig,
|
|
22
|
+
watch && {
|
|
23
|
+
watch: true,
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
const integrationScriptPath = path.resolve(INTEGRATION_PATHS.appBuildPath, INTEGRATION_PATHS.outputFile);
|
|
27
|
+
if (watch) {
|
|
28
|
+
webpack(config, (err, stats) => handleWebpackCallback(err, stats));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
yield runWebpackBuild(config);
|
|
33
|
+
if (type === "package" && !watch) {
|
|
34
|
+
yield runWebpackBuild(yield getPackageBuildConfig({
|
|
35
|
+
mode,
|
|
36
|
+
PATHS: INTEGRATION_PATHS,
|
|
37
|
+
isBuildDevMode: false,
|
|
38
|
+
entityArchivePath: integrationScriptPath,
|
|
39
|
+
copyFiles: [{ from: integrationScriptPath }],
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error(chalk.red("\nFailed to compile.\n"));
|
|
45
|
+
console.error(chalk.red(error));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const INTEGRATION_TSCONFIG_JSON = `\
|
|
2
|
+
{
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES5",
|
|
5
|
+
"module": "Preserve",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"isolatedModules": false
|
|
11
|
+
},
|
|
12
|
+
"include": ["src"]
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
export const INTEGRATION_BABEL_CONFIG = `\
|
|
16
|
+
module.exports = {
|
|
17
|
+
presets: [
|
|
18
|
+
"@babel/preset-env",
|
|
19
|
+
"@babel/preset-typescript",
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
`;
|
|
23
|
+
export const INTEGRATION_GITIGNORE = `\
|
|
24
|
+
# dependencies
|
|
25
|
+
/node_modules
|
|
26
|
+
/.pnp
|
|
27
|
+
.pnp.js
|
|
28
|
+
|
|
29
|
+
# testing
|
|
30
|
+
/coverage
|
|
31
|
+
|
|
32
|
+
# production
|
|
33
|
+
/dist
|
|
34
|
+
|
|
35
|
+
# misc
|
|
36
|
+
.DS_Store
|
|
37
|
+
.env.local
|
|
38
|
+
.env.development.local
|
|
39
|
+
.env.test.local
|
|
40
|
+
.env.production.local
|
|
41
|
+
|
|
42
|
+
npm-debug.log*
|
|
43
|
+
yarn-debug.log*
|
|
44
|
+
yarn-error.log*
|
|
45
|
+
|
|
46
|
+
/build
|
|
47
|
+
.ultra.cache.json
|
|
48
|
+
*.tsbuildinfo
|
|
49
|
+
`;
|
|
50
|
+
export const INTEGRATION_ESLINTRC = `\
|
|
51
|
+
import js from "@eslint/js";
|
|
52
|
+
import globals from "globals";
|
|
53
|
+
import tseslint from "typescript-eslint";
|
|
54
|
+
|
|
55
|
+
export default tseslint.config(
|
|
56
|
+
{ ignores: ["dist", "build"] },
|
|
57
|
+
{
|
|
58
|
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
59
|
+
files: ["**/*.{ts,tsx}"],
|
|
60
|
+
languageOptions: {
|
|
61
|
+
ecmaVersion: 2020,
|
|
62
|
+
globals: globals.browser,
|
|
63
|
+
},
|
|
64
|
+
plugins: {},
|
|
65
|
+
rules: {},
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { INTEGRATION_SDK_LIB_NAME } from "../const.js";
|
|
2
|
+
export const INTEGRATION_INDEX_TEMPLATE = `\
|
|
3
|
+
/// <reference types="${INTEGRATION_SDK_LIB_NAME}" />
|
|
4
|
+
|
|
5
|
+
integration = {
|
|
6
|
+
schema: 1,
|
|
7
|
+
meta: {
|
|
8
|
+
key: "integrationKey",
|
|
9
|
+
name: "",
|
|
10
|
+
description: "",
|
|
11
|
+
},
|
|
12
|
+
blocks: [],
|
|
13
|
+
connections: [],
|
|
14
|
+
};
|
|
15
|
+
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CUSTOM_PACKAGE_CLI_LIB_NAME } from "../../const.js";
|
|
2
|
+
import { INTEGRATION_SDK_LIB_NAME } from "../const.js";
|
|
3
|
+
export const INTEGRATION_PACKAGE_JSON_TEMPLATE = `\
|
|
4
|
+
{
|
|
5
|
+
"name": "template_integration",
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"main": "src/index.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "im-package-cli integration build",
|
|
10
|
+
"dev": "im-package-cli integration build --watch",
|
|
11
|
+
"lint": "tsc --noEmit && eslint src/ --ext .ts,.tsx --quiet",
|
|
12
|
+
"test": "vitest --run"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@babel/core": "^7.26.9",
|
|
16
|
+
"@babel/preset-env": "^7.26.9",
|
|
17
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
18
|
+
"@eslint/js": "^9.19.0",
|
|
19
|
+
"${INTEGRATION_SDK_LIB_NAME}": "^{{integrationSdkVersion}}",
|
|
20
|
+
"${CUSTOM_PACKAGE_CLI_LIB_NAME}": "^{{packageCliVersion}}",
|
|
21
|
+
"eslint": "^9.19.0",
|
|
22
|
+
"globals": "^15.14.0",
|
|
23
|
+
"typescript": "^5.7.2",
|
|
24
|
+
"typescript-eslint": "^8.22.0",
|
|
25
|
+
"vitest": "^3.0.4"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import ZipPlugin from "zip-webpack-plugin";
|
|
3
3
|
import RemovePlugin from "remove-files-webpack-plugin";
|
|
4
|
-
import CopyWebpackPlugin from "copy-webpack-plugin";
|
|
4
|
+
import CopyWebpackPlugin, {} from "copy-webpack-plugin";
|
|
5
5
|
import { JsonModifyWebpackPlugin } from "@infomaximum/json-modify-webpack-plugin";
|
|
6
|
-
import { isExist, removeServiceFieldsForDevelopment, systemRequire, } from "../../../utils.js";
|
|
6
|
+
import { compact, isExist, removeServiceFieldsForDevelopment, systemRequire, } from "../../../utils.js";
|
|
7
7
|
import { BUILD_ARCHIVE_EXT, DEV_POSTFIX, MANIFEST_REG_EXP, } from "../../../const.js";
|
|
8
8
|
import { assertSimple } from "@infomaximum/assert";
|
|
9
9
|
const packageFilename = "main.js";
|
|
10
|
-
export const getPackageBuildConfig = (_a) => __awaiter(void 0, [_a], void 0, function* ({ mode, PATHS, isBuildDevMode, entityArchivePath, }) {
|
|
10
|
+
export const getPackageBuildConfig = (_a) => __awaiter(void 0, [_a], void 0, function* ({ mode, PATHS, isBuildDevMode, entityArchivePath, copyFiles = [], }) {
|
|
11
11
|
const entityVersion = systemRequire(PATHS.appPackageJson).version;
|
|
12
12
|
const manifestPackageName = systemRequire(PATHS.packageManifestPath).name;
|
|
13
13
|
let entityPackageName = `${manifestPackageName}_${entityVersion}`;
|
|
14
14
|
if (isBuildDevMode)
|
|
15
15
|
entityPackageName += DEV_POSTFIX;
|
|
16
16
|
assertSimple(yield isExist(PATHS.packageManifestPath), `File ${PATHS.packageManifestPath} not found`);
|
|
17
|
-
|
|
17
|
+
entityArchivePath &&
|
|
18
|
+
assertSimple(yield isExist(entityArchivePath), `File ${entityArchivePath} not found`);
|
|
18
19
|
return {
|
|
19
20
|
mode,
|
|
20
|
-
entry: [PATHS.packageManifestPath, entityArchivePath],
|
|
21
|
+
entry: compact([PATHS.packageManifestPath, entityArchivePath]),
|
|
21
22
|
output: {
|
|
22
23
|
path: PATHS.appBuildPath,
|
|
23
24
|
filename: packageFilename,
|
|
@@ -43,7 +44,7 @@ export const getPackageBuildConfig = (_a) => __awaiter(void 0, [_a], void 0, fun
|
|
|
43
44
|
},
|
|
44
45
|
plugins: [
|
|
45
46
|
new CopyWebpackPlugin({
|
|
46
|
-
patterns: [{ from: PATHS.packagePath }],
|
|
47
|
+
patterns: [{ from: PATHS.packagePath }, ...copyFiles],
|
|
47
48
|
}),
|
|
48
49
|
new RemovePlugin({
|
|
49
50
|
after: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _resolveApp, generateGlobalPaths } from "../paths.js";
|
|
2
|
-
export function generatePackagePaths({ packageDir, packageManifest,
|
|
3
|
-
const globalPaths = generateGlobalPaths({
|
|
2
|
+
export function generatePackagePaths({ packageDir, packageManifest, buildDir, }) {
|
|
3
|
+
const globalPaths = generateGlobalPaths({ buildDir });
|
|
4
4
|
const resolveApp = _resolveApp();
|
|
5
5
|
const packagePath = resolveApp(packageDir);
|
|
6
6
|
return Object.assign(Object.assign({}, globalPaths), { packagePath, packageDirPath: resolveApp(packageDir), packageManifestPath: resolveApp(packageManifest) });
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AVAILABLE_LANGUAGES, MANIFEST_JSON_FILE_NAME } from "../../const.js";
|
|
2
|
+
import { capitalizeFirstLetter } from "../../utils.js";
|
|
3
|
+
import { GET_CHANGELOG_MD, GET_DOC_MD } from "../templates/additionalFiles.js";
|
|
4
|
+
import { PACKAGE_ICON_TEMPLATE } from "../templates/packageIcon.js";
|
|
5
|
+
import { PACKAGE_MANIFEST_TEMPLATE } from "../templates/packageManifest.js";
|
|
6
|
+
export const getPackageActions = ({ packageType }) => {
|
|
7
|
+
const packageIconName = capitalizeFirstLetter(packageType);
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
type: "add",
|
|
11
|
+
path: `package/${MANIFEST_JSON_FILE_NAME}`,
|
|
12
|
+
template: PACKAGE_MANIFEST_TEMPLATE,
|
|
13
|
+
data: {
|
|
14
|
+
packageIconName,
|
|
15
|
+
packageType: packageType,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: "add",
|
|
20
|
+
path: `package/resources/${packageIconName}.svg`,
|
|
21
|
+
template: PACKAGE_ICON_TEMPLATE,
|
|
22
|
+
},
|
|
23
|
+
...AVAILABLE_LANGUAGES.flatMap((language) => [
|
|
24
|
+
{
|
|
25
|
+
type: "add",
|
|
26
|
+
path: `package/${language}/doc.md`,
|
|
27
|
+
template: GET_DOC_MD(language),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "add",
|
|
31
|
+
path: `package/${language}/changelog.md`,
|
|
32
|
+
template: GET_CHANGELOG_MD(language),
|
|
33
|
+
},
|
|
34
|
+
]),
|
|
35
|
+
];
|
|
36
|
+
};
|
|
@@ -4,8 +4,8 @@ import { capitalizeHelperName } from "../../plopHelpers.js";
|
|
|
4
4
|
export const PACKAGE_MANIFEST_TEMPLATE = `\
|
|
5
5
|
{
|
|
6
6
|
"$schema": "../node_modules/${CUSTOM_PACKAGE_CLI_LIB_NAME}/schemas/packageManifestSchema.json",
|
|
7
|
-
"manifest_version": "
|
|
8
|
-
"min_version_platform": "1.0.0.
|
|
7
|
+
"manifest_version": "2",
|
|
8
|
+
"min_version_platform": "1.0.0.x",
|
|
9
9
|
"author": "{{author}}",
|
|
10
10
|
"guid": "${randomUUID()}",
|
|
11
11
|
"type": "{{packageType}}",
|
package/dist/paths.js
CHANGED
|
@@ -26,11 +26,11 @@ export const generateIndexPath = (entryPath) => {
|
|
|
26
26
|
process.exit(1);
|
|
27
27
|
};
|
|
28
28
|
export const generateGlobalPaths = (args) => {
|
|
29
|
-
const { cwd,
|
|
29
|
+
const { cwd, buildDir } = args || {};
|
|
30
30
|
const resolveApp = _resolveApp(cwd);
|
|
31
31
|
return {
|
|
32
32
|
appPath: resolveApp("."),
|
|
33
|
-
appBuildPath: resolveApp(
|
|
33
|
+
appBuildPath: resolveApp(buildDir),
|
|
34
34
|
appPackageJson: resolveApp("package.json"),
|
|
35
35
|
appTsConfig: resolveApp("tsconfig.json"),
|
|
36
36
|
appNodeModules: resolveApp("node_modules"),
|
package/dist/plopHelpers.js
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import nodePlop from "node-plop";
|
|
4
|
+
import { capitalizeFirstLetter, spawnCommand } from "./utils.js";
|
|
5
|
+
import { prompts } from "./package/scripts/prompts.js";
|
|
2
6
|
const capitalizeHelperName = "capitalize";
|
|
3
7
|
const addCommonHelpers = (plop) => {
|
|
4
8
|
plop.setHelper(capitalizeHelperName, capitalizeFirstLetter);
|
|
5
9
|
};
|
|
6
10
|
export { capitalizeHelperName, addCommonHelpers };
|
|
11
|
+
export const runInitEntityScript = (_a) => __awaiter(void 0, [_a], void 0, function* ({ entity, dirName, actions, }) {
|
|
12
|
+
const createPath = path.join(process.cwd(), dirName);
|
|
13
|
+
const plop = yield nodePlop(undefined, {
|
|
14
|
+
destBasePath: createPath,
|
|
15
|
+
force: false,
|
|
16
|
+
});
|
|
17
|
+
addCommonHelpers(plop);
|
|
18
|
+
const generateEntityGeneratorName = `${entity}-generate`;
|
|
19
|
+
plop.setGenerator(generateEntityGeneratorName, {
|
|
20
|
+
prompts,
|
|
21
|
+
actions,
|
|
22
|
+
});
|
|
23
|
+
const initGenerator = plop.getGenerator(generateEntityGeneratorName);
|
|
24
|
+
const answers = (yield initGenerator.runPrompts());
|
|
25
|
+
yield initGenerator.runActions(answers);
|
|
26
|
+
const packageManager = answers.packageManager;
|
|
27
|
+
try {
|
|
28
|
+
yield spawnCommand(packageManager, ["install"], {
|
|
29
|
+
cwd: createPath,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error(error);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
yield spawnCommand("git", ["init", "-b", "develop"], {
|
|
37
|
+
cwd: createPath,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error(error);
|
|
42
|
+
}
|
|
43
|
+
});
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.js
CHANGED
|
@@ -5,6 +5,7 @@ import { spawn, exec } from "node:child_process";
|
|
|
5
5
|
import util from "node:util";
|
|
6
6
|
import Module from "node:module";
|
|
7
7
|
import { MANIFEST_SERVICE_FIELDS_FOR_DEVELOPMENT } from "./const.js";
|
|
8
|
+
import webpack, {} from "webpack";
|
|
8
9
|
const execPromise = util.promisify(exec);
|
|
9
10
|
export const isExist = (entityPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
11
|
try {
|
|
@@ -61,3 +62,25 @@ export function removeServiceFieldsForDevelopment(obj) {
|
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
export const compact = (items) => items.filter(Boolean);
|
|
65
|
+
export function runWebpackBuild(config) {
|
|
66
|
+
const compiler = webpack(config);
|
|
67
|
+
return new Promise((res, rej) => {
|
|
68
|
+
compiler.run((err, stats) => handleWebpackCallback(err, stats, res, rej));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export function handleWebpackCallback(err, stats, okCb, errCb) {
|
|
72
|
+
if (err) {
|
|
73
|
+
console.error(err.stack || err);
|
|
74
|
+
if (err === null || err === void 0 ? void 0 : err.details) {
|
|
75
|
+
console.error(err.details);
|
|
76
|
+
}
|
|
77
|
+
errCb === null || errCb === void 0 ? void 0 : errCb();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
stats &&
|
|
81
|
+
console.log(stats.toString({
|
|
82
|
+
chunks: false,
|
|
83
|
+
colors: true,
|
|
84
|
+
}));
|
|
85
|
+
okCb === null || okCb === void 0 ? void 0 : okCb();
|
|
86
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { assertSimple } from "@infomaximum/assert";
|
|
3
3
|
import { DEFAULT_BUILD_DIR_NAME } from "../../const.js";
|
|
4
|
+
import { registerPackageOptions, } from "../../package/commands.js";
|
|
4
5
|
export function registerCommonOption(command) {
|
|
6
|
+
registerPackageOptions(command);
|
|
5
7
|
command
|
|
6
8
|
.option("--entry <path>", "путь до entrypoint")
|
|
7
9
|
.option("--assets-dir <assetsDirPath>", "путь до директории с ресурсами виджета, которые будут перенесены в архив с виджетом")
|
|
8
|
-
.option("--package-manifest <manifestPath>", "путь до файла манифеста пакета")
|
|
9
|
-
.option("--package-dir <packageDirPath>", "путь до директории с файлами пакета")
|
|
10
10
|
.option("--widget-manifest <manifestPath>", "путь до файла манифеста виджета");
|
|
11
11
|
}
|
|
12
12
|
export function configMergeWithOptionsCommon(config, options) {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { runInitEntityScript } from "../../plopHelpers.js";
|
|
3
|
+
import { getInitWidgetActions } from "../scripts/init/actions.js";
|
|
2
4
|
export const registerWidgetInitCommand = (widgetCommand) => {
|
|
3
5
|
const widgetInitCommand = widgetCommand.command("init <project-directory>");
|
|
4
6
|
widgetInitCommand
|
|
5
7
|
.description("Инициализация проекта виджета")
|
|
6
|
-
.action((dirName) => {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
.action((dirName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
runInitEntityScript({
|
|
10
|
+
dirName,
|
|
11
|
+
entity: "widget",
|
|
12
|
+
actions: yield getInitWidgetActions(),
|
|
13
|
+
});
|
|
14
|
+
}));
|
|
9
15
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import
|
|
2
|
+
import {} from "webpack";
|
|
3
3
|
import {} from "../../paths.js";
|
|
4
4
|
import { getPackageBuildConfig } from "../../package/configs/webpack/buildPackage.js";
|
|
5
5
|
import { merge } from "webpack-merge";
|
|
@@ -13,6 +13,7 @@ import { WIDGET_ARCHIVE_FULL_NAME } from "../const.js";
|
|
|
13
13
|
import { generateWidgetPaths } from "../widgetPaths.js";
|
|
14
14
|
import { generatePackagePaths } from "../../package/packagePaths.js";
|
|
15
15
|
import { checkLatestLibsVersion } from "../utils.js";
|
|
16
|
+
import { runWebpackBuild } from "../../utils.js";
|
|
16
17
|
export const runBuild = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
18
|
const mode = "production";
|
|
18
19
|
const { buildDir, host, port, dev: isBuildDevMode, packageDir, packageManifest, } = args;
|
|
@@ -42,12 +43,12 @@ export const runBuild = (args) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
42
43
|
const widgetConfig = merge(configSections);
|
|
43
44
|
const widgetArchivePath = path.resolve(WIDGET_PATHS.appBuildPath, WIDGET_ARCHIVE_FULL_NAME);
|
|
44
45
|
try {
|
|
45
|
-
yield
|
|
46
|
+
yield runWebpackBuild(widgetConfig);
|
|
46
47
|
console.log("");
|
|
47
|
-
yield
|
|
48
|
+
yield runWebpackBuild(yield getPackageBuildConfig({
|
|
48
49
|
mode,
|
|
49
50
|
PATHS: generatePackagePaths({
|
|
50
|
-
|
|
51
|
+
buildDir,
|
|
51
52
|
packageDir,
|
|
52
53
|
packageManifest,
|
|
53
54
|
}),
|
|
@@ -62,23 +63,3 @@ export const runBuild = (args) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
62
63
|
process.exit(1);
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
|
-
function build(config) {
|
|
66
|
-
const compiler = webpack(config);
|
|
67
|
-
return new Promise((res, rej) => {
|
|
68
|
-
compiler.run((err, stats) => {
|
|
69
|
-
if (err) {
|
|
70
|
-
console.error(err.stack || err);
|
|
71
|
-
if (err === null || err === void 0 ? void 0 : err.details) {
|
|
72
|
-
console.error(err.details);
|
|
73
|
-
}
|
|
74
|
-
rej();
|
|
75
|
-
}
|
|
76
|
-
stats &&
|
|
77
|
-
console.log(stats === null || stats === void 0 ? void 0 : stats.toString({
|
|
78
|
-
chunks: false,
|
|
79
|
-
colors: true,
|
|
80
|
-
}));
|
|
81
|
-
res();
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
@@ -15,7 +15,6 @@ import { WIDGET_BABEL_CONFIG, WIDGET_ESLINTIGNORE, WIDGET_ESLINTRC, WIDGET_GITIG
|
|
|
15
15
|
import { WIDGET_PACKAGE_JSON_TEMPLATE } from "../../templates/widgetPackageJson.js";
|
|
16
16
|
import { WIDGET_SDK_LIB_NAME } from "../../const.js";
|
|
17
17
|
import { WIDGET_RC_CONFIG } from "../../templates/widgetRCConfig.js";
|
|
18
|
-
const addInitActions = (basePath, plop) => { };
|
|
19
18
|
const actions = ({ widgetSDKVersion, packageCliVersion }) => {
|
|
20
19
|
const packageIconName = "Widget";
|
|
21
20
|
return [
|
|
@@ -123,8 +122,7 @@ const actions = ({ widgetSDKVersion, packageCliVersion }) => {
|
|
|
123
122
|
},
|
|
124
123
|
];
|
|
125
124
|
};
|
|
126
|
-
const getInitWidgetActions = (
|
|
127
|
-
addInitActions(basePath, plop);
|
|
125
|
+
const getInitWidgetActions = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
126
|
const [packageCliVersion, widgetSDKVersion] = yield Promise.all([
|
|
129
127
|
getLatestVersionOfLibrary(CUSTOM_PACKAGE_CLI_LIB_NAME),
|
|
130
128
|
getLatestVersionOfLibrary(WIDGET_SDK_LIB_NAME),
|
|
@@ -39,7 +39,7 @@ export const runReleaseWidget = (options) => __awaiter(void 0, void 0, void 0, f
|
|
|
39
39
|
const { first, dryRun } = options;
|
|
40
40
|
const config = getConfigFromFile();
|
|
41
41
|
const globalPaths = generateGlobalPaths({
|
|
42
|
-
|
|
42
|
+
buildDir: (_a = config === null || config === void 0 ? void 0 : config.buildDir) !== null && _a !== void 0 ? _a : DEFAULT_BUILD_DIR_NAME,
|
|
43
43
|
});
|
|
44
44
|
const changelogFile = path.resolve(globalPaths.appPath, "CHANGELOG.md");
|
|
45
45
|
const isFirstRelease = first || !(yield isExist(changelogFile));
|
|
@@ -5,9 +5,6 @@ import type {
|
|
|
5
5
|
IFillSettings,
|
|
6
6
|
IGroupSettings,
|
|
7
7
|
IPanelDescriptionCreator,
|
|
8
|
-
IWidgetDimension,
|
|
9
|
-
IWidgetDimensionHierarchy,
|
|
10
|
-
IWidgetMeasure,
|
|
11
8
|
} from "${WIDGET_SDK_LIB_NAME}";
|
|
12
9
|
import { fillSettings, type WidgetSettings } from "./settings";
|
|
13
10
|
import { createPanelDescription } from "./panel";
|
|
@@ -20,13 +17,7 @@ export class Definition implements IDefinition<WidgetSettings, IGroupSettings> {
|
|
|
20
17
|
|
|
21
18
|
public fillSettings: IFillSettings<WidgetSettings> = fillSettings;
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
settings: WidgetSettings
|
|
25
|
-
): (IWidgetDimension | IWidgetDimensionHierarchy)[] {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public getMeasures(settings: WidgetSettings): IWidgetMeasure[] {
|
|
20
|
+
getLocalMigrateVersions(): string[] {
|
|
30
21
|
return [];
|
|
31
22
|
}
|
|
32
23
|
}
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { _resolveApp, generateGlobalPaths, generateIndexPath, } from "../paths.js";
|
|
3
3
|
const resolveApp = _resolveApp();
|
|
4
4
|
export function generateWidgetPaths({ entry, assetsDir, widgetManifest, buildDir, }) {
|
|
5
|
-
const globalPaths = generateGlobalPaths({
|
|
5
|
+
const globalPaths = generateGlobalPaths({ buildDir });
|
|
6
6
|
return Object.assign(Object.assign({}, globalPaths), { get moduleIndex() {
|
|
7
7
|
return generateIndexPath(entry);
|
|
8
8
|
}, widgetManifestJsonPath: resolveApp(widgetManifest), widgetResourcesPath: assetsDir ? resolveApp(assetsDir) : null, widgetResourcesDirName: assetsDir ? path.basename(assetsDir) : null, widgetBuildDirPath: resolveApp(buildDir) });
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { getInitWidgetActions } from "./actions.js";
|
|
3
|
-
import { prompts } from "./prompts.js";
|
|
4
|
-
import { addCommonHelpers } from "../../../plopHelpers.js";
|
|
5
|
-
const generateWidgetGeneratorName = "widget-generate";
|
|
6
|
-
const getInitWidgetGenerator = (basePath, plop) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
-
addCommonHelpers(plop);
|
|
8
|
-
const actions = yield getInitWidgetActions(basePath, plop);
|
|
9
|
-
plop.setGenerator(generateWidgetGeneratorName, {
|
|
10
|
-
prompts,
|
|
11
|
-
actions,
|
|
12
|
-
});
|
|
13
|
-
return plop.getGenerator(generateWidgetGeneratorName);
|
|
14
|
-
});
|
|
15
|
-
export { getInitWidgetGenerator };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import nodePlop from "node-plop";
|
|
4
|
-
import { getInitWidgetGenerator } from "./generators.js";
|
|
5
|
-
import { spawnCommand } from "../../../utils.js";
|
|
6
|
-
const runInitWidget = (dirName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
-
const createPath = path.join(process.cwd(), dirName);
|
|
8
|
-
const plop = yield nodePlop(undefined, {
|
|
9
|
-
destBasePath: createPath,
|
|
10
|
-
force: false,
|
|
11
|
-
});
|
|
12
|
-
const initGenerator = yield getInitWidgetGenerator(createPath, plop);
|
|
13
|
-
const answers = (yield initGenerator.runPrompts());
|
|
14
|
-
yield initGenerator.runActions(answers);
|
|
15
|
-
const packageManager = answers.packageManager;
|
|
16
|
-
try {
|
|
17
|
-
yield spawnCommand(packageManager, ["install"], {
|
|
18
|
-
cwd: createPath,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
console.error(error);
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
yield spawnCommand("git", ["init", "-b", "develop"], {
|
|
26
|
-
cwd: createPath,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.error(error);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
export { runInitWidget };
|
|
File without changes
|