@infomaximum/package-cli 2.24.0 → 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 (58) hide show
  1. package/CHANGELOG.md +10 -0
  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/types.d.ts +1 -1
  56. package/package.json +1 -1
  57. package/schemas/applicationConfigSchema.json +48 -0
  58. package/schemas/applicationManifestSchema.json +29 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
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.25.0](https://github.com/Infomaximum/package-cli/compare/v2.24.0...v2.25.0) (2025-12-03)
6
+
7
+
8
+ ### Features
9
+
10
+ * добавлен запуск приложения для разработки ([77822ce](https://github.com/Infomaximum/package-cli/commit/77822cec943be8739838dd90c35fa0e9ae1c7132))
11
+ * добавлена сборка приложений ([3d3a04d](https://github.com/Infomaximum/package-cli/commit/3d3a04d0f112c53a1faafb0fb8f077894bab5652))
12
+ * добавлен манифест ([9afec05](https://github.com/Infomaximum/package-cli/commit/9afec056ee319319c006ab8d1c7e64a492633b15))
13
+ * добавлена возможность инициализировать проект приложения ([2d76102](https://github.com/Infomaximum/package-cli/commit/2d7610224e86f031d488aecb312b7587c63ec828))
14
+
5
15
  ## [2.24.0](https://github.com/Infomaximum/package-cli/compare/v2.23.1...v2.24.0) (2025-09-23)
6
16
 
7
17
 
@@ -0,0 +1,15 @@
1
+ import type { MergedApplicationBuildOptions } from "./commands/build.js";
2
+ import type { MergedApplicationStartOptions } from "./commands/start.js";
3
+ export type ApplicationPaths = ReturnType<typeof generateApplicationPaths>;
4
+ type Options = MergedApplicationBuildOptions | MergedApplicationStartOptions;
5
+ export declare function generateApplicationPaths({ entry, applicationManifest, buildDir, }: Options): {
6
+ moduleIndex: string;
7
+ applicationManifestJsonPath: string;
8
+ applicationBuildDirPath: string;
9
+ appPath: string;
10
+ appBuildPath: string;
11
+ appPackageJson: string;
12
+ appTsConfig: string;
13
+ appNodeModules: string;
14
+ };
15
+ export {};
@@ -0,0 +1,9 @@
1
+ import path from "node:path";
2
+ import { _resolveApp, generateGlobalPaths, generateIndexPath, } from "../paths.js";
3
+ const resolveApp = _resolveApp();
4
+ export function generateApplicationPaths({ entry, applicationManifest, buildDir, }) {
5
+ const globalPaths = generateGlobalPaths({ buildDir });
6
+ return Object.assign(Object.assign({}, globalPaths), { get moduleIndex() {
7
+ return generateIndexPath(entry);
8
+ }, applicationManifestJsonPath: resolveApp(applicationManifest), applicationBuildDirPath: resolveApp(buildDir) });
9
+ }
@@ -0,0 +1,21 @@
1
+ import type { Command } from "commander";
2
+ import { type InputApplicationCommonOptions } from "./common.js";
3
+ export type InputBuildOptions = {
4
+ dev: boolean;
5
+ port?: string | number;
6
+ host?: string;
7
+ buildDir?: string;
8
+ } & InputApplicationCommonOptions;
9
+ export type MergedApplicationBuildOptions = ReturnType<typeof mergeApplicationWithOptionsBuild>;
10
+ declare function mergeApplicationWithOptionsBuild(options: InputBuildOptions): {
11
+ entry: string;
12
+ packageDir: string;
13
+ packageManifest: string;
14
+ applicationManifest: string;
15
+ buildDir: string;
16
+ host: string | undefined;
17
+ port: string | number | undefined;
18
+ dev: boolean;
19
+ };
20
+ export declare const registerApplicationBuildCommand: (applicationCommand: Command) => void;
21
+ export {};
@@ -0,0 +1,18 @@
1
+ import { getApplicationConfigFromFile } from "../configs/file.js";
2
+ import { mergeApplicationConfigWithOptionsCommon, registerApplicationCommonOption, } from "./common.js";
3
+ import { runApplicationBuild } from "../scripts/build.js";
4
+ function mergeApplicationWithOptionsBuild(options) {
5
+ const config = getApplicationConfigFromFile();
6
+ return Object.assign({ host: options.host || (config === null || config === void 0 ? void 0 : config.host), port: options.port || (config === null || config === void 0 ? void 0 : config.port), dev: options.dev }, mergeApplicationConfigWithOptionsCommon(config, options));
7
+ }
8
+ export const registerApplicationBuildCommand = (applicationCommand) => {
9
+ const applicationBuildCommand = applicationCommand.command("build");
10
+ registerApplicationCommonOption(applicationBuildCommand);
11
+ applicationBuildCommand
12
+ .description("Выполняет сборку пакета")
13
+ .option("--build-dir <buildDirPath>", "путь до директории в которую будет собран пакет")
14
+ .option("--dev", "собрать пакет для разработки", false)
15
+ .option("--host <host>", "хост который будет указан в манифесте приложения")
16
+ .option("--port <port>", "порт который будет указан в манифесте приложения")
17
+ .action((options) => runApplicationBuild(mergeApplicationWithOptionsBuild(options)));
18
+ };
@@ -0,0 +1,16 @@
1
+ import type { ApplicationRCConfig } from "../configs/file.js";
2
+ import type { Command } from "commander";
3
+ import { type InputPackageOptions } from "../../package/commands.js";
4
+ export type InputApplicationCommonOptions = {
5
+ entry: string;
6
+ applicationManifest?: string;
7
+ } & InputPackageOptions;
8
+ export type MergedApplicationCommonOptions = ReturnType<typeof mergeApplicationConfigWithOptionsCommon>;
9
+ export declare function registerApplicationCommonOption(command: Command): void;
10
+ export declare function mergeApplicationConfigWithOptionsCommon(config: ApplicationRCConfig | undefined, options: InputApplicationCommonOptions): {
11
+ entry: string;
12
+ packageDir: string;
13
+ packageManifest: string;
14
+ applicationManifest: string;
15
+ buildDir: string;
16
+ };
@@ -0,0 +1,28 @@
1
+ import chalk from "chalk";
2
+ import { assertSimple } from "@infomaximum/assert";
3
+ import { DEFAULT_BUILD_DIR_NAME } from "../../const.js";
4
+ import { registerPackageOptions, } from "../../package/commands.js";
5
+ export function registerApplicationCommonOption(command) {
6
+ registerPackageOptions(command);
7
+ command
8
+ .option("--entry <path>", "путь до entrypoint")
9
+ .option("--application-manifest <manifestPath>", "путь до файла манифеста приложения");
10
+ }
11
+ export function mergeApplicationConfigWithOptionsCommon(config, options) {
12
+ const entry = options.entry || (config === null || config === void 0 ? void 0 : config.entry);
13
+ const packageDir = (options === null || options === void 0 ? void 0 : options.packageDir) || (config === null || config === void 0 ? void 0 : config.packageDir);
14
+ const buildDir = (config === null || config === void 0 ? void 0 : config.buildDir) || DEFAULT_BUILD_DIR_NAME;
15
+ const packageManifest = (options === null || options === void 0 ? void 0 : options.packageManifest) || (config === null || config === void 0 ? void 0 : config.packageManifest);
16
+ const applicationManifest = (options === null || options === void 0 ? void 0 : options.applicationManifest) || (config === null || config === void 0 ? void 0 : config.applicationManifest);
17
+ assertSimple(!!entry, chalk.red("В конфигурации не задан entry"));
18
+ assertSimple(!!packageDir, chalk.red("В конфигурации не задан packageDir"));
19
+ assertSimple(!!packageManifest, chalk.red("В конфигурации не задан packageManifest"));
20
+ assertSimple(!!applicationManifest, chalk.red("В конфигурации не задан applicationManifest"));
21
+ return {
22
+ entry,
23
+ packageDir,
24
+ packageManifest,
25
+ applicationManifest,
26
+ buildDir,
27
+ };
28
+ }
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare const registerApplicationInitCommand: (applicationCommand: Command) => void;
@@ -0,0 +1,15 @@
1
+ import { __awaiter } from "tslib";
2
+ import { runInitEntityScript } from "../../plopHelpers.js";
3
+ import { getInitApplicationActions } from "../scripts/init.js";
4
+ export const registerApplicationInitCommand = (applicationCommand) => {
5
+ const applicationInitCommand = applicationCommand.command("init <project-directory>");
6
+ applicationInitCommand
7
+ .description("Инициализация проекта приложения")
8
+ .action((dirName) => __awaiter(void 0, void 0, void 0, function* () {
9
+ runInitEntityScript({
10
+ dirName,
11
+ entity: "application",
12
+ actions: yield getInitApplicationActions(),
13
+ });
14
+ }));
15
+ };
@@ -0,0 +1,18 @@
1
+ import { type InputApplicationCommonOptions } from "./common.js";
2
+ import type { Command } from "commander";
3
+ export type InputApplicationStartOptions = {
4
+ port: string | number;
5
+ host: string;
6
+ } & InputApplicationCommonOptions;
7
+ export type MergedApplicationStartOptions = ReturnType<typeof configMergeWithOptionsStart>;
8
+ declare function configMergeWithOptionsStart(options: InputApplicationStartOptions): {
9
+ entry: string;
10
+ packageDir: string;
11
+ packageManifest: string;
12
+ applicationManifest: string;
13
+ buildDir: string;
14
+ host: string;
15
+ port: string | number;
16
+ };
17
+ export declare const registerApplicationStartCommand: (applicationCommand: Command) => void;
18
+ export {};
@@ -0,0 +1,23 @@
1
+ import chalk from "chalk";
2
+ import { assertSilent } from "@infomaximum/assert";
3
+ import { getApplicationConfigFromFile } from "../configs/file.js";
4
+ import { mergeApplicationConfigWithOptionsCommon, registerApplicationCommonOption, } from "./common.js";
5
+ import { APPLICATION_DEFAULT_HOST, APPLICATION_DEFAULT_PORT, } from "../const.js";
6
+ import { runApplicationDevServer } from "../scripts/start.js";
7
+ function configMergeWithOptionsStart(options) {
8
+ const config = getApplicationConfigFromFile();
9
+ const host = options.host || (config === null || config === void 0 ? void 0 : config.host);
10
+ const port = options.port || (config === null || config === void 0 ? void 0 : config.port);
11
+ assertSilent(!!host, chalk.yellow(`В конфигурациях не найден host, используется host по умолчанию "${APPLICATION_DEFAULT_HOST}"`));
12
+ assertSilent(!!port, chalk.yellow(`В конфигурациях не найден port, используется port по умолчанию "${APPLICATION_DEFAULT_PORT}"`));
13
+ return Object.assign({ host: host || APPLICATION_DEFAULT_HOST, port: port || APPLICATION_DEFAULT_PORT }, mergeApplicationConfigWithOptionsCommon(config, options));
14
+ }
15
+ export const registerApplicationStartCommand = (applicationCommand) => {
16
+ const applicationStartCommand = applicationCommand.command("start");
17
+ registerApplicationCommonOption(applicationStartCommand);
18
+ applicationStartCommand
19
+ .description("Выполняет запуск проекта для разработки")
20
+ .option("--port <port>", "порт на котором будет доступно приложение")
21
+ .option("--host <host>", "host на котором будет доступно приложение")
22
+ .action((options) => runApplicationDevServer(configMergeWithOptionsStart(options)));
23
+ };
@@ -0,0 +1,2 @@
1
+ import type { Command } from "commander";
2
+ export declare const registerApplicationCommands: (cli: Command) => void;
@@ -0,0 +1,9 @@
1
+ import { registerApplicationInitCommand } from "./commands/init.js";
2
+ import { registerApplicationBuildCommand } from "./commands/build.js";
3
+ import { registerApplicationStartCommand } from "./commands/start.js";
4
+ export const registerApplicationCommands = (cli) => {
5
+ const applicationCommand = cli.command("application");
6
+ registerApplicationInitCommand(applicationCommand);
7
+ registerApplicationBuildCommand(applicationCommand);
8
+ registerApplicationStartCommand(applicationCommand);
9
+ };
@@ -0,0 +1,10 @@
1
+ export type ApplicationRCConfig = {
2
+ entry: string;
3
+ applicationManifest: string;
4
+ packageManifest: string;
5
+ packageDir: string;
6
+ buildDir: string;
7
+ port: number;
8
+ host: string;
9
+ };
10
+ export declare const getApplicationConfigFromFile: () => ApplicationRCConfig | undefined;
@@ -0,0 +1,11 @@
1
+ import { rcFile } from "rc-config-loader";
2
+ import { APPLICATION_CONFIG_FIELD_NAME, APPLICATION_CONFIG_FILE_NAME, } from "../const.js";
3
+ export const getApplicationConfigFromFile = () => {
4
+ var _a;
5
+ const config = (_a = rcFile(APPLICATION_CONFIG_FILE_NAME, {
6
+ cwd: process.cwd(),
7
+ packageJSON: { fieldName: APPLICATION_CONFIG_FIELD_NAME },
8
+ configFileName: APPLICATION_CONFIG_FILE_NAME,
9
+ })) === null || _a === void 0 ? void 0 : _a.config;
10
+ return config;
11
+ };
@@ -0,0 +1,4 @@
1
+ import { type Configuration } from "webpack";
2
+ import type { Mode } from "../../../paths.js";
3
+ import type { ApplicationPaths } from "../../applicationPaths.js";
4
+ export declare const getCommonApplicationWebpackConfig: (mode: Mode, PATHS: ApplicationPaths) => Configuration;
@@ -0,0 +1,139 @@
1
+ import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
2
+ import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
3
+ import webpack, {} from "webpack";
4
+ import { applicationCssLoaders } from "./sections/loaders/cssLoaders.js";
5
+ import { compact, systemRequire } from "../../../utils.js";
6
+ import { MANIFEST_REG_EXP } from "../../../const.js";
7
+ import { APPLICATION_OUTPUT_FILE_NAME, APPLICATION_OUTPUT_FULL_FILE_NAME, } from "../../const.js";
8
+ const { ProgressPlugin } = webpack;
9
+ const isProduction = (mode) => mode === "production";
10
+ const isDevelopment = (mode) => mode === "development";
11
+ export const getCommonApplicationWebpackConfig = (mode, PATHS) => {
12
+ const manifestEntry = systemRequire(PATHS.applicationManifestJsonPath).entry;
13
+ const filename = isProduction(mode)
14
+ ? `${APPLICATION_OUTPUT_FILE_NAME}.[contenthash].js`
15
+ : APPLICATION_OUTPUT_FULL_FILE_NAME;
16
+ return {
17
+ mode,
18
+ entry: [PATHS.moduleIndex, PATHS.applicationManifestJsonPath],
19
+ output: {
20
+ path: PATHS.appBuildPath,
21
+ filename: manifestEntry !== null && manifestEntry !== void 0 ? manifestEntry : filename,
22
+ asyncChunks: false,
23
+ clean: true,
24
+ },
25
+ plugins: compact([
26
+ new ProgressPlugin(),
27
+ new ForkTsCheckerWebpackPlugin({
28
+ typescript: {
29
+ mode: "write-references",
30
+ diagnosticOptions: {
31
+ semantic: true,
32
+ syntactic: true,
33
+ },
34
+ },
35
+ }),
36
+ ]),
37
+ module: {
38
+ rules: [
39
+ {
40
+ test: /\.(js|ts|jsx|tsx)$/i,
41
+ exclude: ["/node_modules/"],
42
+ loader: systemRequire.resolve("babel-loader"),
43
+ options: {
44
+ plugins: [
45
+ systemRequire.resolve("babel-plugin-inline-json-import"),
46
+ systemRequire.resolve("@babel/plugin-transform-runtime"),
47
+ !isProduction(mode) &&
48
+ systemRequire.resolve("react-refresh/babel"),
49
+ ].filter(Boolean),
50
+ },
51
+ },
52
+ {
53
+ test: /\.css$/i,
54
+ use: applicationCssLoaders,
55
+ },
56
+ {
57
+ test: /\.s[ac]ss$/i,
58
+ use: [
59
+ ...applicationCssLoaders,
60
+ {
61
+ loader: systemRequire.resolve("sass-loader"),
62
+ options: {
63
+ implementation: systemRequire("sass"),
64
+ sassOptions: {
65
+ fiber: false,
66
+ },
67
+ },
68
+ },
69
+ ],
70
+ },
71
+ {
72
+ test: /\.less$/i,
73
+ use: [
74
+ ...applicationCssLoaders,
75
+ {
76
+ loader: systemRequire.resolve("less-loader"),
77
+ options: {
78
+ sourceMap: isDevelopment(mode),
79
+ lessOptions: {
80
+ javascriptEnabled: true,
81
+ },
82
+ },
83
+ },
84
+ ],
85
+ },
86
+ {
87
+ test: /\.(eot|ttf|woff|woff2|png|jpg|jpeg|webp|gif)$/i,
88
+ type: "asset/inline",
89
+ },
90
+ {
91
+ test: MANIFEST_REG_EXP,
92
+ type: "asset/resource",
93
+ generator: {
94
+ filename: "[name][ext]",
95
+ },
96
+ },
97
+ {
98
+ test: /\.svg$/i,
99
+ oneOf: [
100
+ {
101
+ type: "asset",
102
+ resourceQuery: /url/,
103
+ parser: {
104
+ dataUrlCondition: {
105
+ maxSize: 64 * 1024,
106
+ },
107
+ },
108
+ generator: {
109
+ filename: "build/static/[hash][ext][query]",
110
+ },
111
+ },
112
+ {
113
+ type: "asset/source",
114
+ resourceQuery: /src/,
115
+ },
116
+ {
117
+ issuer: /\.[jt]sx?$/,
118
+ loader: systemRequire.resolve("@svgr/webpack"),
119
+ options: {
120
+ svgoConfig: {
121
+ plugins: [
122
+ {
123
+ name: "removeViewBox",
124
+ active: false,
125
+ },
126
+ ],
127
+ },
128
+ },
129
+ },
130
+ ],
131
+ },
132
+ ],
133
+ },
134
+ resolve: {
135
+ extensions: [".tsx", ".ts", ".js"],
136
+ plugins: [new TsconfigPathsPlugin()],
137
+ },
138
+ };
139
+ };
@@ -0,0 +1,21 @@
1
+ type DevServerParams = {
2
+ port: string;
3
+ host: string;
4
+ };
5
+ export declare const getDevServerConfig: ({ host, port }: DevServerParams) => {
6
+ open: false;
7
+ hot: true;
8
+ port: string;
9
+ host: string;
10
+ headers: {
11
+ "Access-Control-Allow-Origin": string;
12
+ };
13
+ devMiddleware: {
14
+ writeToDisk: false;
15
+ };
16
+ allowedHosts: string;
17
+ client: {
18
+ logging: "error";
19
+ };
20
+ };
21
+ export {};
@@ -0,0 +1,19 @@
1
+ import {} from "webpack-dev-server";
2
+ export const getDevServerConfig = ({ host, port }) => {
3
+ return {
4
+ open: false,
5
+ hot: true,
6
+ port,
7
+ host,
8
+ headers: {
9
+ "Access-Control-Allow-Origin": "*",
10
+ },
11
+ devMiddleware: {
12
+ writeToDisk: false,
13
+ },
14
+ allowedHosts: "all",
15
+ client: {
16
+ logging: "error",
17
+ },
18
+ };
19
+ };
@@ -0,0 +1,3 @@
1
+ export declare const devtoolSection: {
2
+ devtool: string;
3
+ };
@@ -0,0 +1,3 @@
1
+ export const devtoolSection = {
2
+ devtool: "inline-source-map",
3
+ };
@@ -0,0 +1,8 @@
1
+ export declare const applicationCssLoaders: (string | {
2
+ loader: string;
3
+ options: {
4
+ postcssOptions: {
5
+ plugins: string[];
6
+ };
7
+ };
8
+ })[];
@@ -0,0 +1,16 @@
1
+ import { systemRequire } from "../../../../../utils.js";
2
+ export const applicationCssLoaders = [
3
+ systemRequire.resolve("style-loader"),
4
+ systemRequire.resolve("css-loader"),
5
+ {
6
+ loader: systemRequire.resolve("postcss-loader"),
7
+ options: {
8
+ postcssOptions: {
9
+ plugins: [
10
+ systemRequire.resolve("postcss-preset-env"),
11
+ systemRequire.resolve("autoprefixer"),
12
+ ],
13
+ },
14
+ },
15
+ },
16
+ ];
@@ -0,0 +1,9 @@
1
+ import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
2
+ import TerserWebpackPlugin from "terser-webpack-plugin";
3
+ export declare const getApplicationMinimizer: () => {
4
+ optimization: {
5
+ minimize: boolean;
6
+ splitChunks: boolean;
7
+ minimizer: (TerserWebpackPlugin<import("terser").MinifyOptions> | CssMinimizerPlugin<CssMinimizerPlugin.CssNanoOptionsExtended>)[];
8
+ };
9
+ };
@@ -0,0 +1,23 @@
1
+ import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
2
+ import TerserWebpackPlugin from "terser-webpack-plugin";
3
+ export const getApplicationMinimizer = () => {
4
+ return {
5
+ optimization: {
6
+ minimize: true,
7
+ splitChunks: false,
8
+ minimizer: [
9
+ new TerserWebpackPlugin({
10
+ minify: TerserWebpackPlugin.terserMinify,
11
+ parallel: true,
12
+ extractComments: false,
13
+ terserOptions: {
14
+ format: {
15
+ comments: false,
16
+ },
17
+ },
18
+ }),
19
+ new CssMinimizerPlugin(),
20
+ ],
21
+ },
22
+ };
23
+ };
@@ -0,0 +1,10 @@
1
+ import { JsonModifyWebpackPlugin } from "@infomaximum/json-modify-webpack-plugin";
2
+ import type { ApplicationPaths } from "../../../../applicationPaths.js";
3
+ type Params = {
4
+ port?: string | number;
5
+ host?: string;
6
+ isBuildDevMode: boolean;
7
+ APPLICATION_PATHS: ApplicationPaths;
8
+ };
9
+ export declare const getModifyManifestApplicationPlugin: ({ host, port, isBuildDevMode, APPLICATION_PATHS, }: Params) => JsonModifyWebpackPlugin;
10
+ export {};
@@ -0,0 +1,35 @@
1
+ import { JsonModifyWebpackPlugin } from "@infomaximum/json-modify-webpack-plugin";
2
+ import { DEV_POSTFIX } from "../../../../../const.js";
3
+ import { removeServiceFieldsForDevelopment } from "../../../../../utils.js";
4
+ import { APPLICATION_OUTPUT_FILE_NAME, APPLICATION_OUTPUT_FULL_FILE_NAME, } from "../../../../const.js";
5
+ export const getModifyManifestApplicationPlugin = ({ host, port, isBuildDevMode, APPLICATION_PATHS, }) => {
6
+ return new JsonModifyWebpackPlugin({
7
+ matchers: [
8
+ {
9
+ matcher: /^manifest.json$/,
10
+ action: (currentJsonContent, assetNames) => {
11
+ const manifestEntry = currentJsonContent.entry;
12
+ if (isBuildDevMode && host && port) {
13
+ currentJsonContent.entry = `http://${host}:${port}/${manifestEntry !== null && manifestEntry !== void 0 ? manifestEntry : APPLICATION_OUTPUT_FULL_FILE_NAME}`;
14
+ if ((currentJsonContent === null || currentJsonContent === void 0 ? void 0 : currentJsonContent.name) &&
15
+ typeof currentJsonContent.name === "object") {
16
+ Object.keys(currentJsonContent.name).forEach((lang) => {
17
+ Object.assign(currentJsonContent.name, {
18
+ [lang]: currentJsonContent.name[lang] + DEV_POSTFIX,
19
+ });
20
+ });
21
+ }
22
+ }
23
+ else if (!manifestEntry) {
24
+ const entryName = assetNames.find((asset) => asset.startsWith(`${APPLICATION_OUTPUT_FILE_NAME}.`));
25
+ if (entryName) {
26
+ currentJsonContent.entry = entryName;
27
+ }
28
+ }
29
+ removeServiceFieldsForDevelopment(currentJsonContent);
30
+ return currentJsonContent;
31
+ },
32
+ },
33
+ ],
34
+ });
35
+ };
@@ -0,0 +1,2 @@
1
+ import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
2
+ export declare const getReactRefresh: () => ReactRefreshWebpackPlugin;
@@ -0,0 +1,4 @@
1
+ import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
2
+ export const getReactRefresh = () => {
3
+ return new ReactRefreshWebpackPlugin();
4
+ };
@@ -0,0 +1,6 @@
1
+ import ZipPlugin from "zip-webpack-plugin";
2
+ type Params = {
3
+ isOnlyManifest: boolean;
4
+ };
5
+ export declare const getZipApplicationPlugin: ({ isOnlyManifest }: Params) => ZipPlugin;
6
+ export {};
@@ -0,0 +1,11 @@
1
+ import ZipPlugin from "zip-webpack-plugin";
2
+ import { APPLICATION_ARCHIVE_FULL_NAME } from "../../../../const.js";
3
+ import { BUILD_ARCHIVE_EXT, MANIFEST_JSON_FILE_NAME, } from "../../../../../const.js";
4
+ import { compact } from "../../../../../utils.js";
5
+ export const getZipApplicationPlugin = ({ isOnlyManifest }) => {
6
+ return new ZipPlugin({
7
+ filename: APPLICATION_ARCHIVE_FULL_NAME,
8
+ extension: BUILD_ARCHIVE_EXT,
9
+ include: isOnlyManifest ? compact([MANIFEST_JSON_FILE_NAME]) : undefined,
10
+ });
11
+ };
@@ -0,0 +1,10 @@
1
+ export declare const APPLICATION_SDK_LIB_NAME = "@infomaximum/application-types";
2
+ export declare const APPLICATION_OUTPUT_FILE_NAME = "application";
3
+ export declare const APPLICATION_OUTPUT_FULL_FILE_NAME = "application.js";
4
+ export declare const APPLICATION_SDK_LIB_VERSION = "1.1.1";
5
+ export declare const APPLICATION_CONFIG_FIELD_NAME = "application";
6
+ export declare const APPLICATION_CONFIG_FILE_NAME = "applicationrc";
7
+ export declare const APPLICATION_DEFAULT_HOST = "localhost";
8
+ export declare const APPLICATION_DEFAULT_PORT = "5566";
9
+ export declare const APPLICATION_ARCHIVE_NAME = "application";
10
+ export declare const APPLICATION_ARCHIVE_FULL_NAME = "application.zip";
@@ -0,0 +1,11 @@
1
+ import { BUILD_ARCHIVE_EXT } from "../const.js";
2
+ export const APPLICATION_SDK_LIB_NAME = "@infomaximum/application-types";
3
+ export const APPLICATION_OUTPUT_FILE_NAME = "application";
4
+ export const APPLICATION_OUTPUT_FULL_FILE_NAME = `${APPLICATION_OUTPUT_FILE_NAME}.js`;
5
+ export const APPLICATION_SDK_LIB_VERSION = "1.1.1";
6
+ export const APPLICATION_CONFIG_FIELD_NAME = "application";
7
+ export const APPLICATION_CONFIG_FILE_NAME = `${APPLICATION_CONFIG_FIELD_NAME}rc`;
8
+ export const APPLICATION_DEFAULT_HOST = "localhost";
9
+ export const APPLICATION_DEFAULT_PORT = "5566";
10
+ export const APPLICATION_ARCHIVE_NAME = "application";
11
+ export const APPLICATION_ARCHIVE_FULL_NAME = `${APPLICATION_ARCHIVE_NAME}.${BUILD_ARCHIVE_EXT}`;
@@ -0,0 +1 @@
1
+ export { registerApplicationCommands } from "./commands.js";
@@ -0,0 +1 @@
1
+ export { registerApplicationCommands } from "./commands.js";
@@ -0,0 +1,2 @@
1
+ import type { MergedApplicationBuildOptions } from "../commands/build.js";
2
+ export declare const runApplicationBuild: (args: MergedApplicationBuildOptions) => Promise<void>;
@@ -0,0 +1,63 @@
1
+ import { __awaiter } from "tslib";
2
+ import {} from "webpack";
3
+ import {} from "../../paths.js";
4
+ import { getPackageBuildConfig } from "../../package/configs/webpack/buildPackage.js";
5
+ import { merge } from "webpack-merge";
6
+ import chalk from "chalk";
7
+ import path from "node:path";
8
+ import { APPLICATION_ARCHIVE_FULL_NAME } from "../const.js";
9
+ import { generateApplicationPaths } from "../applicationPaths.js";
10
+ import { generatePackagePaths } from "../../package/packagePaths.js";
11
+ import { runWebpackBuild } from "../../utils.js";
12
+ import { getZipApplicationPlugin } from "../configs/webpack/sections/plugins/zipApplication.js";
13
+ import { getApplicationMinimizer } from "../configs/webpack/sections/plugins/minimizer.js";
14
+ import { getCommonApplicationWebpackConfig } from "../configs/webpack/common.js";
15
+ import { getModifyManifestApplicationPlugin } from "../configs/webpack/sections/plugins/modifyManifestApplication.js";
16
+ export const runApplicationBuild = (args) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const mode = "production";
18
+ const { buildDir, host, port, dev: isBuildDevMode, packageDir, packageManifest, } = args;
19
+ const APPLICATION_PATHS = generateApplicationPaths(args);
20
+ const sections = {
21
+ plugins: [
22
+ getZipApplicationPlugin({
23
+ isOnlyManifest: isBuildDevMode,
24
+ }),
25
+ getModifyManifestApplicationPlugin({
26
+ isBuildDevMode,
27
+ host,
28
+ port,
29
+ APPLICATION_PATHS,
30
+ }),
31
+ ],
32
+ };
33
+ if (isBuildDevMode) {
34
+ sections.entry =
35
+ APPLICATION_PATHS.applicationManifestJsonPath;
36
+ }
37
+ const configSections = [
38
+ getCommonApplicationWebpackConfig(mode, APPLICATION_PATHS),
39
+ sections,
40
+ getApplicationMinimizer(),
41
+ ];
42
+ const applicationConfig = merge(configSections);
43
+ const applicationArchivePath = path.resolve(APPLICATION_PATHS.appBuildPath, APPLICATION_ARCHIVE_FULL_NAME);
44
+ try {
45
+ yield runWebpackBuild(applicationConfig);
46
+ console.log("");
47
+ yield runWebpackBuild(yield getPackageBuildConfig({
48
+ mode,
49
+ PATHS: generatePackagePaths({
50
+ buildDir,
51
+ packageDir,
52
+ packageManifest,
53
+ }),
54
+ isBuildDevMode,
55
+ entityArchivePath: applicationArchivePath,
56
+ }));
57
+ }
58
+ catch (error) {
59
+ console.error(chalk.red("\nFailed to compile.\n"));
60
+ console.error(chalk.red(error));
61
+ process.exit(1);
62
+ }
63
+ });
@@ -0,0 +1,23 @@
1
+ import type { Answers } from "../../package/scripts/prompts.js";
2
+ declare const getInitApplicationActions: () => Promise<(data: Answers) => ({
3
+ type: string;
4
+ path: string;
5
+ template: string;
6
+ data: {
7
+ packageIconName: string;
8
+ packageType: import("../../types.js").PackageType;
9
+ };
10
+ } | {
11
+ type: string;
12
+ path: string;
13
+ template: string;
14
+ data?: undefined;
15
+ } | {
16
+ type: "add";
17
+ path: string;
18
+ template: string;
19
+ data: {
20
+ packageCliVersion: string;
21
+ };
22
+ })[]>;
23
+ export { getInitApplicationActions };
@@ -0,0 +1,60 @@
1
+ import { __awaiter } from "tslib";
2
+ import { getPackageActions } from "../../package/scripts/actions.js";
3
+ import { APPLICATION_BABEL_CONFIG, APPLICATION_GITIGNORE, APPLICATION_TSCONFIG_JSON, } from "../templates/applicationConfigs.js";
4
+ import { packageJson } from "../../utils.js";
5
+ import { APPLICATION_INDEX_TEMPLATE } from "../templates/src/applicationIndex.js";
6
+ import { APPLICATION_CONTENT_TEMPLATE } from "../templates/src/applicationContent.js";
7
+ import { APPLICATION_PACKAGE_JSON_TEMPLATE } from "../templates/applicationPackageJson.js";
8
+ import { APPLICATION_MANIFEST_TEMPLATE } from "../templates/applicationManifest.js";
9
+ import { APPLICATION_RC_CONFIG } from "../templates/applicationRCConfig.js";
10
+ import { APPLICATION_CONFIG_FILE_NAME } from "../const.js";
11
+ const actions = ({ packageCliVersion }) => {
12
+ return [
13
+ ...getPackageActions({ packageType: "application" }),
14
+ {
15
+ type: "add",
16
+ path: "src/index.tsx",
17
+ template: APPLICATION_INDEX_TEMPLATE,
18
+ },
19
+ {
20
+ type: "add",
21
+ path: "src/Content.tsx",
22
+ template: APPLICATION_CONTENT_TEMPLATE,
23
+ },
24
+ {
25
+ type: "add",
26
+ path: "tsconfig.json",
27
+ template: APPLICATION_TSCONFIG_JSON,
28
+ },
29
+ {
30
+ type: "add",
31
+ path: ".gitignore",
32
+ template: APPLICATION_GITIGNORE,
33
+ },
34
+ {
35
+ type: "add",
36
+ path: "babel.config.js",
37
+ template: APPLICATION_BABEL_CONFIG,
38
+ },
39
+ {
40
+ type: "add",
41
+ path: "package.json",
42
+ template: APPLICATION_PACKAGE_JSON_TEMPLATE,
43
+ data: { packageCliVersion },
44
+ },
45
+ {
46
+ type: "add",
47
+ path: "manifest.json",
48
+ template: APPLICATION_MANIFEST_TEMPLATE,
49
+ },
50
+ {
51
+ type: "add",
52
+ path: `${APPLICATION_CONFIG_FILE_NAME}.json`,
53
+ template: APPLICATION_RC_CONFIG,
54
+ },
55
+ ];
56
+ };
57
+ const getInitApplicationActions = () => __awaiter(void 0, void 0, void 0, function* () {
58
+ return (data) => actions(Object.assign(Object.assign({}, data), { packageCliVersion: packageJson.version }));
59
+ });
60
+ export { getInitApplicationActions };
@@ -0,0 +1,2 @@
1
+ import type { MergedApplicationStartOptions } from "../commands/start.js";
2
+ export declare const runApplicationDevServer: (options: MergedApplicationStartOptions) => Promise<void>;
@@ -0,0 +1,61 @@
1
+ import { __awaiter } from "tslib";
2
+ import _webpack, {} from "webpack";
3
+ import {} from "../../paths.js";
4
+ import WebpackDevServer from "webpack-dev-server";
5
+ import { merge } from "webpack-merge";
6
+ import { getModifyManifestApplicationPlugin } from "../configs/webpack/sections/plugins/modifyManifestApplication.js";
7
+ import { getReactRefresh } from "../configs/webpack/sections/plugins/reactRefresh.js";
8
+ import { getCommonApplicationWebpackConfig } from "../configs/webpack/common.js";
9
+ import { devtoolSection } from "../configs/webpack/sections/devtool.js";
10
+ import { getDevServerConfig } from "../configs/webpack/sections/devServer.js";
11
+ import { generateApplicationPaths, } from "../applicationPaths.js";
12
+ const { webpack } = _webpack;
13
+ export const runApplicationDevServer = (options) => __awaiter(void 0, void 0, void 0, function* () {
14
+ const PATHS = generateApplicationPaths(options);
15
+ try {
16
+ yield run(PATHS, options);
17
+ }
18
+ catch (error) {
19
+ if (error === null || error === void 0 ? void 0 : error.message) {
20
+ console.error(error.message);
21
+ }
22
+ process.exit(1);
23
+ }
24
+ });
25
+ const run = (APPLICATION_PATHS, options) => __awaiter(void 0, void 0, void 0, function* () {
26
+ const { host, port } = options;
27
+ const mode = "development";
28
+ const pluginsSection = {
29
+ plugins: [
30
+ getModifyManifestApplicationPlugin({
31
+ isBuildDevMode: true,
32
+ host,
33
+ port,
34
+ APPLICATION_PATHS,
35
+ }),
36
+ getReactRefresh(),
37
+ ],
38
+ };
39
+ const configWebpack = [
40
+ getCommonApplicationWebpackConfig(mode, APPLICATION_PATHS),
41
+ pluginsSection,
42
+ devtoolSection,
43
+ ];
44
+ const compiler = webpack(merge(configWebpack));
45
+ const devServerConfig = getDevServerConfig({
46
+ host,
47
+ port: String(port),
48
+ });
49
+ const devServer = new WebpackDevServer(devServerConfig, compiler);
50
+ ["SIGINT", "SIGTERM"].forEach(function (sig) {
51
+ process.on(sig, function () {
52
+ devServer.close();
53
+ process.exit();
54
+ });
55
+ });
56
+ process.stdin.on("end", function () {
57
+ devServer.close();
58
+ process.exit();
59
+ });
60
+ yield devServer.start();
61
+ });
@@ -0,0 +1,3 @@
1
+ export declare const APPLICATION_TSCONFIG_JSON = "{\n \"compilerOptions\": {\n \"target\": \"ES2015\",\n \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n \"allowJs\": true,\n \"skipLibCheck\": true,\n \"esModuleInterop\": true,\n \"allowSyntheticDefaultImports\": true,\n \"strict\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"noFallthroughCasesInSwitch\": true,\n \"module\": \"esnext\",\n \"moduleResolution\": \"node\",\n \"resolveJsonModule\": true,\n \"isolatedModules\": true,\n \"noEmit\": true,\n \"jsx\": \"react-jsx\"\n },\n \"exclude\": [],\n \"include\": [\"src\"]\n}\n";
2
+ export declare const APPLICATION_GITIGNORE = "# dependencies\n/node_modules\n/.pnp\n.pnp.js\n\n# testing\n/coverage\n\n# production\n/dist\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";
3
+ export declare const APPLICATION_BABEL_CONFIG = "module.exports = {\n presets: [\n \"@babel/preset-env\",\n [\"@babel/preset-react\", { runtime: \"automatic\" }],\n \"@babel/preset-typescript\",\n ],\n};\n";
@@ -0,0 +1,60 @@
1
+ export const APPLICATION_TSCONFIG_JSON = `\
2
+ {
3
+ "compilerOptions": {
4
+ "target": "ES2015",
5
+ "lib": ["dom", "dom.iterable", "esnext"],
6
+ "allowJs": true,
7
+ "skipLibCheck": true,
8
+ "esModuleInterop": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "strict": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "noFallthroughCasesInSwitch": true,
13
+ "module": "esnext",
14
+ "moduleResolution": "node",
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "noEmit": true,
18
+ "jsx": "react-jsx"
19
+ },
20
+ "exclude": [],
21
+ "include": ["src"]
22
+ }
23
+ `;
24
+ export const APPLICATION_GITIGNORE = `\
25
+ # dependencies
26
+ /node_modules
27
+ /.pnp
28
+ .pnp.js
29
+
30
+ # testing
31
+ /coverage
32
+
33
+ # production
34
+ /dist
35
+
36
+ # misc
37
+ .DS_Store
38
+ .env
39
+ .env.local
40
+ .env.development.local
41
+ .env.test.local
42
+ .env.production.local
43
+
44
+ npm-debug.log*
45
+ yarn-debug.log*
46
+ yarn-error.log*
47
+
48
+ /build
49
+ .ultra.cache.json
50
+ *.tsbuildinfo
51
+ `;
52
+ export const APPLICATION_BABEL_CONFIG = `\
53
+ module.exports = {
54
+ presets: [
55
+ "@babel/preset-env",
56
+ ["@babel/preset-react", { runtime: "automatic" }],
57
+ "@babel/preset-typescript",
58
+ ],
59
+ };
60
+ `;
@@ -0,0 +1 @@
1
+ export declare const APPLICATION_MANIFEST_TEMPLATE = "{\n \"$schema\": \"node_modules/@infomaximum/package-cli/schemas/applicationManifestSchema.json\",\n \"name\": {\n \"en\": \"{{capitalize packageName}}\",\n \"ru\": \"{{capitalize packageName}}\"\n }\n}\n";
@@ -0,0 +1,11 @@
1
+ import { CUSTOM_PACKAGE_CLI_LIB_NAME } from "../../const.js";
2
+ import { capitalizeHelperName } from "../../plopHelpers.js";
3
+ export const APPLICATION_MANIFEST_TEMPLATE = `\
4
+ {
5
+ "$schema": "node_modules/${CUSTOM_PACKAGE_CLI_LIB_NAME}/schemas/applicationManifestSchema.json",
6
+ "name": {
7
+ "en": "{{${capitalizeHelperName} packageName}}",
8
+ "ru": "{{${capitalizeHelperName} packageName}}"
9
+ }
10
+ }
11
+ `;
@@ -0,0 +1 @@
1
+ export declare const APPLICATION_PACKAGE_JSON_TEMPLATE = "{\n \"name\": \"template_application\",\n \"version\": \"1.0.0\",\n \"main\": \"src/index.tsx\",\n \"scripts\": {\n \"build\": \"im-package-cli application build\",\n \"build:dev\": \"im-package-cli application build --dev\",\n \"start\": \"im-package-cli application start\"\n },\n \"dependencies\": {\n \"react\": \"18.2.0\",\n \"react-dom\": \"18.2.0\"\n },\n \"devDependencies\": {\n \"@infomaximum/application-types\": \"1.1.1\",\n \"@infomaximum/package-cli\": \"^{{packageCliVersion}}\",\n \"@types/react\": \"18.2.55\",\n \"@types/react-dom\": \"18.2.19\",\n \"prettier\": \"3.7.3\",\n \"typescript\": \"5.9.3\"\n },\n \"browserslist\": [\n \"defaults and supports es6-module\"\n ]\n}\n";
@@ -0,0 +1,29 @@
1
+ import { CUSTOM_PACKAGE_CLI_LIB_NAME } from "../../const.js";
2
+ import { APPLICATION_SDK_LIB_NAME, APPLICATION_SDK_LIB_VERSION, } from "../const.js";
3
+ export const APPLICATION_PACKAGE_JSON_TEMPLATE = `\
4
+ {
5
+ "name": "template_application",
6
+ "version": "1.0.0",
7
+ "main": "src/index.tsx",
8
+ "scripts": {
9
+ "build": "im-package-cli application build",
10
+ "build:dev": "im-package-cli application build --dev",
11
+ "start": "im-package-cli application start"
12
+ },
13
+ "dependencies": {
14
+ "react": "18.2.0",
15
+ "react-dom": "18.2.0"
16
+ },
17
+ "devDependencies": {
18
+ "${APPLICATION_SDK_LIB_NAME}": "${APPLICATION_SDK_LIB_VERSION}",
19
+ "${CUSTOM_PACKAGE_CLI_LIB_NAME}": "^{{packageCliVersion}}",
20
+ "@types/react": "18.2.55",
21
+ "@types/react-dom": "18.2.19",
22
+ "prettier": "3.7.3",
23
+ "typescript": "5.9.3"
24
+ },
25
+ "browserslist": [
26
+ "defaults and supports es6-module"
27
+ ]
28
+ }
29
+ `;
@@ -0,0 +1 @@
1
+ export declare const APPLICATION_RC_CONFIG: string;
@@ -0,0 +1,14 @@
1
+ import { CUSTOM_PACKAGE_CLI_LIB_NAME, DEFAULT_BUILD_DIR_NAME, MANIFEST_JSON_FILE_NAME, } from "../../const.js";
2
+ import { APPLICATION_DEFAULT_HOST, APPLICATION_DEFAULT_PORT, } from "../const.js";
3
+ export const APPLICATION_RC_CONFIG = `\
4
+ {
5
+ "$schema": "node_modules/${CUSTOM_PACKAGE_CLI_LIB_NAME}/schemas/applicationConfigSchema.json",
6
+ "entry": "src/index.tsx",
7
+ "applicationManifest": "${MANIFEST_JSON_FILE_NAME}",
8
+ "packageDir": "package",
9
+ "packageManifest": "package/${MANIFEST_JSON_FILE_NAME}",
10
+ "buildDir": "${DEFAULT_BUILD_DIR_NAME}",
11
+ "port": ${+APPLICATION_DEFAULT_PORT},
12
+ "host": "${APPLICATION_DEFAULT_HOST}"
13
+ }
14
+ `;
@@ -0,0 +1 @@
1
+ export declare const APPLICATION_CONTENT_TEMPLATE = "import { FC } from \"react\";\n\nexport interface IContentProps {}\n\nconst Content: FC<IContentProps> = () => {\n return <div>Application example</div>;\n};\n\nexport default Content;\n";
@@ -0,0 +1,11 @@
1
+ export const APPLICATION_CONTENT_TEMPLATE = `\
2
+ import { FC } from "react";
3
+
4
+ export interface IContentProps {}
5
+
6
+ const Content: FC<IContentProps> = () => {
7
+ return <div>Application example</div>;
8
+ };
9
+
10
+ export default Content;
11
+ `;
@@ -0,0 +1 @@
1
+ export declare const APPLICATION_INDEX_TEMPLATE = "import { Root, createRoot } from \"react-dom/client\";\nimport Content from \"./Content\";\nimport { IApplication } from \"@infomaximum/application-types\";\nimport packageManifest from \"../package/manifest.json\";\n\nclass Application implements IApplication {\n public root: Root | null = null;\n\n public initialize(container: HTMLElement) {\n this.root = createRoot(container);\n }\n\n public mount(container: HTMLElement, props: Record<string, any>) {\n this.render(props);\n }\n\n public update(container: HTMLElement, props: Record<string, any>) {\n this.render(props);\n }\n\n public unmount() {\n this.root?.unmount();\n }\n\n private render(props: Record<string, any>) {\n this.root?.render(<Content {...props} />);\n }\n}\n\nwindow.im.defineApplication(packageManifest.guid, Application);\n";
@@ -0,0 +1,34 @@
1
+ import { MANIFEST_JSON_FILE_NAME } from "../../../const.js";
2
+ import { APPLICATION_SDK_LIB_NAME } from "../../const.js";
3
+ export const APPLICATION_INDEX_TEMPLATE = `\
4
+ import { Root, createRoot } from "react-dom/client";
5
+ import Content from "./Content";
6
+ import { IApplication } from "${APPLICATION_SDK_LIB_NAME}";
7
+ import packageManifest from "../package/${MANIFEST_JSON_FILE_NAME}";
8
+
9
+ class Application implements IApplication {
10
+ public root: Root | null = null;
11
+
12
+ public initialize(container: HTMLElement) {
13
+ this.root = createRoot(container);
14
+ }
15
+
16
+ public mount(container: HTMLElement, props: Record<string, any>) {
17
+ this.render(props);
18
+ }
19
+
20
+ public update(container: HTMLElement, props: Record<string, any>) {
21
+ this.render(props);
22
+ }
23
+
24
+ public unmount() {
25
+ this.root?.unmount();
26
+ }
27
+
28
+ private render(props: Record<string, any>) {
29
+ this.root?.render(<Content {...props} />);
30
+ }
31
+ }
32
+
33
+ window.im.defineApplication(packageManifest.guid, Application);
34
+ `;
package/dist/arguments.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { packageJson } from "./utils.js";
2
2
  import { registerWidgetCommands } from "./widget/index.js";
3
3
  import { registerIntegrationCommands } from "./integration/index.js";
4
+ import { registerApplicationCommands } from "./application/index.js";
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);
9
10
  registerIntegrationCommands(cli);
11
+ registerApplicationCommands(cli);
10
12
  };
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- export type PackageType = "widget" | "integration";
1
+ export type PackageType = "widget" | "integration" | "application";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/package-cli",
3
- "version": "2.24.0",
3
+ "version": "2.25.0",
4
4
  "exports": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -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
+ }