@infomaximum/package-cli 2.24.0-2 → 2.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +8 -8
  2. package/dist/application/applicationPaths.d.ts +15 -0
  3. package/dist/application/applicationPaths.js +9 -0
  4. package/dist/application/commands/build.d.ts +21 -0
  5. package/dist/application/commands/build.js +18 -0
  6. package/dist/application/commands/common.d.ts +16 -0
  7. package/dist/application/commands/common.js +28 -0
  8. package/dist/application/commands/init.d.ts +2 -0
  9. package/dist/application/commands/init.js +15 -0
  10. package/dist/application/commands/start.d.ts +18 -0
  11. package/dist/application/commands/start.js +23 -0
  12. package/dist/application/commands.d.ts +2 -0
  13. package/dist/application/commands.js +9 -0
  14. package/dist/application/configs/file.d.ts +10 -0
  15. package/dist/application/configs/file.js +11 -0
  16. package/dist/application/configs/webpack/common.d.ts +4 -0
  17. package/dist/application/configs/webpack/common.js +139 -0
  18. package/dist/application/configs/webpack/sections/devServer.d.ts +21 -0
  19. package/dist/application/configs/webpack/sections/devServer.js +19 -0
  20. package/dist/application/configs/webpack/sections/devtool.d.ts +3 -0
  21. package/dist/application/configs/webpack/sections/devtool.js +3 -0
  22. package/dist/application/configs/webpack/sections/loaders/cssLoaders.d.ts +8 -0
  23. package/dist/application/configs/webpack/sections/loaders/cssLoaders.js +16 -0
  24. package/dist/application/configs/webpack/sections/plugins/minimizer.d.ts +9 -0
  25. package/dist/application/configs/webpack/sections/plugins/minimizer.js +23 -0
  26. package/dist/application/configs/webpack/sections/plugins/modifyManifestApplication.d.ts +10 -0
  27. package/dist/application/configs/webpack/sections/plugins/modifyManifestApplication.js +35 -0
  28. package/dist/application/configs/webpack/sections/plugins/reactRefresh.d.ts +2 -0
  29. package/dist/application/configs/webpack/sections/plugins/reactRefresh.js +4 -0
  30. package/dist/application/configs/webpack/sections/plugins/zipApplication.d.ts +6 -0
  31. package/dist/application/configs/webpack/sections/plugins/zipApplication.js +11 -0
  32. package/dist/application/const.d.ts +10 -0
  33. package/dist/application/const.js +11 -0
  34. package/dist/application/index.d.ts +1 -0
  35. package/dist/application/index.js +1 -0
  36. package/dist/application/scripts/build.d.ts +2 -0
  37. package/dist/application/scripts/build.js +63 -0
  38. package/dist/application/scripts/init.d.ts +23 -0
  39. package/dist/application/scripts/init.js +60 -0
  40. package/dist/application/scripts/start.d.ts +2 -0
  41. package/dist/application/scripts/start.js +61 -0
  42. package/dist/application/templates/applicationConfigs.d.ts +3 -0
  43. package/dist/application/templates/applicationConfigs.js +60 -0
  44. package/dist/application/templates/applicationManifest.d.ts +1 -0
  45. package/dist/application/templates/applicationManifest.js +11 -0
  46. package/dist/application/templates/applicationPackageJson.d.ts +1 -0
  47. package/dist/application/templates/applicationPackageJson.js +29 -0
  48. package/dist/application/templates/applicationRCConfig.d.ts +1 -0
  49. package/dist/application/templates/applicationRCConfig.js +14 -0
  50. package/dist/application/templates/src/applicationContent.d.ts +1 -0
  51. package/dist/application/templates/src/applicationContent.js +11 -0
  52. package/dist/application/templates/src/applicationIndex.d.ts +1 -0
  53. package/dist/application/templates/src/applicationIndex.js +34 -0
  54. package/dist/arguments.js +2 -0
  55. package/dist/index.d.ts +0 -1
  56. package/dist/integration/scripts/init.d.ts +0 -5
  57. package/dist/integration/scripts/init.js +10 -5
  58. package/dist/integration/templates/integrationConfigs.d.ts +3 -2
  59. package/dist/integration/templates/integrationConfigs.js +134 -19
  60. package/dist/integration/templates/integrationIndex.d.ts +1 -1
  61. package/dist/integration/templates/integrationIndex.js +2 -2
  62. package/dist/integration/templates/integrationPackageJson.d.ts +1 -1
  63. package/dist/integration/templates/integrationPackageJson.js +7 -1
  64. package/dist/types.d.ts +1 -1
  65. package/dist/widget/commands.js +0 -2
  66. package/dist/widget/configs/file.d.ts +0 -2
  67. package/dist/widget/configs/webpack/common.d.ts +1 -1
  68. package/dist/widget/configs/webpack/common.js +6 -4
  69. package/dist/widget/configs/webpack/sections/plugins/minimizer.d.ts +1 -1
  70. package/dist/widget/scripts/init/actions.js +1 -1
  71. package/dist/widget/templates/src/widgetIndex.d.ts +1 -1
  72. package/dist/widget/templates/src/widgetIndex.js +1 -3
  73. package/dist/widget/templates/widgetPackageJson.d.ts +1 -1
  74. package/dist/widget/templates/widgetPackageJson.js +5 -10
  75. package/dist/widget/templates/widgetRCConfig.js +11 -15
  76. package/dist/widget/widgetPaths.d.ts +1 -2
  77. package/package.json +3 -6
  78. package/schemas/applicationConfigSchema.json +48 -0
  79. package/schemas/applicationManifestSchema.json +29 -0
  80. package/schemas/widgetConfigSchema.json +0 -5
  81. package/dist/widget/commands/build_script.d.ts +0 -7
  82. package/dist/widget/commands/build_script.js +0 -12
  83. package/dist/widget/scripts/build_script.d.ts +0 -3
  84. package/dist/widget/scripts/build_script.js +0 -39
@@ -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/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
2
  export type { IntegrationRCConfig, IntegrationFetcherReturnType, IntegrationFetcher, } from "./integration/configs/file.js";
3
- export type { WidgetRCConfig } from "./widget/configs/file.js";
@@ -12,11 +12,6 @@ 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;
20
15
  } | {
21
16
  type: "add";
22
17
  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_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";
2
+ import { INTEGRATION_BABEL_CONFIG, INTEGRATION_COMMITLINT_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";
@@ -16,22 +16,22 @@ const actions = ({ packageCliVersion, integrationSdkVersion }) => {
16
16
  {
17
17
  type: "add",
18
18
  path: "src/types/common.d.ts",
19
- template: undefined
19
+ template: "",
20
20
  },
21
21
  {
22
22
  type: "add",
23
23
  path: "src/utils/index.ts",
24
- template: ""
24
+ template: "",
25
25
  },
26
26
  {
27
27
  type: "add",
28
28
  path: "src/modules/template.ts",
29
- template: ""
29
+ template: "",
30
30
  },
31
31
  {
32
32
  type: "add",
33
33
  path: "src/connections/base.ts",
34
- template: ""
34
+ template: "",
35
35
  },
36
36
  {
37
37
  type: "add",
@@ -74,6 +74,11 @@ const actions = ({ packageCliVersion, integrationSdkVersion }) => {
74
74
  template: INTEGRATION_PACKAGE_JSON_TEMPLATE,
75
75
  data: { packageCliVersion, integrationSdkVersion },
76
76
  },
77
+ {
78
+ type: "add",
79
+ path: ".commitlintrc.json",
80
+ template: INTEGRATION_COMMITLINT_CONFIG,
81
+ },
77
82
  {
78
83
  type: "add",
79
84
  path: ".vscode/launch.json",
@@ -1,7 +1,7 @@
1
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";
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\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
- 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";
4
+ export declare const INTEGRATION_ESLINTRC = "import eslint from \"@eslint/js\";\nimport { defineConfig } from \"eslint/config\";\nimport tseslint from \"typescript-eslint\";\nimport fp from \"eslint-plugin-fp\";\nimport sonarPlugin from \"eslint-plugin-sonarjs\";\nexport default defineConfig(\n eslint.configs.recommended,\n tseslint.configs.recommended,\n tseslint.configs.strict,\n tseslint.configs.stylistic,\n\n [\n {\n ignores: [\n \"**/dist/**\",\n \"**/build/**\",\n \"**/node_modules/**\",\n \"**/*.config.js\",\n \"**/*.config.cjs\",\n \"**/*.config.mjs\",\n ],\n files: [\"**/*.ts\", \"**/*.tsx\"],\n languageOptions: {\n ecmaVersion: \"latest\",\n sourceType: \"module\",\n parserOptions: {\n project: \"./tsconfig.json\",\n },\n },\n plugins: {\n \"@typescript-eslint\": tseslint.plugin,\n fp,\n sonarjs: sonarPlugin,\n },\n rules: {\n \"@typescript-eslint/no-unused-vars\": [\n \"error\",\n {\n argsIgnorePattern: \"^_\",\n varsIgnorePattern: \"^_\",\n },\n ],\n \"@typescript-eslint/no-explicit-any\": \"warn\",\n \"@typescript-eslint/consistent-type-definitions\": [\n \"error\",\n \"interface\",\n ],\n \"@typescript-eslint/explicit-function-return-type\": [\n \"error\",\n {\n allowExpressions: true,\n allowTypedFunctionExpressions: true,\n },\n ],\n \"@typescript-eslint/naming-convention\": [\n \"error\",\n {\n selector: [\"variable\", \"function\"],\n format: [\"camelCase\"],\n leadingUnderscore: \"allow\",\n trailingUnderscore: \"forbid\",\n },\n\n {\n selector: [\"typeLike\", \"class\"],\n format: [\"PascalCase\"],\n },\n {\n selector: \"interface\",\n format: [\"PascalCase\"],\n custom: {\n regex: \"^I[A-Z]\",\n match: true,\n },\n },\n {\n selector: \"typeAlias\",\n format: [\"PascalCase\"],\n custom: {\n regex: \"^T[A-Z]\",\n match: true,\n },\n },\n {\n selector: \"enum\",\n format: [\"PascalCase\"],\n custom: {\n regex: \"^E[A-Z]\",\n match: true,\n },\n },\n {\n selector: \"enumMember\",\n format: [\"PascalCase\"],\n },\n {\n selector: \"method\",\n format: [\"camelCase\"],\n },\n {\n selector: \"parameter\",\n format: [\"camelCase\"],\n leadingUnderscore: \"allow\",\n },\n ],\n \"@typescript-eslint/prefer-for-of\": \"error\",\n \"prefer-const\": \"error\",\n \"no-var\": \"error\",\n \"prefer-arrow-callback\": \"error\",\n\n eqeqeq: [\"error\", \"always\"],\n yoda: \"error\",\n \"no-lonely-if\": \"error\",\n curly: \"error\",\n // \u041E\u0433\u0440\u0430\u0447\u0438\u0447\u0435\u043D\u0438\u0435 \u043D\u0430 \u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0441\u0442\u0440\u043E\u043A \u0432 \u0444\u0443\u043D\u043A\u0446\u0438\u0438, \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u043E\u0449\u0440\u044F\u0442\u044C \u0431\u043E\u043B\u0435\u0435 \u043C\u0435\u043B\u043A\u0438\u0435, \u0431\u043E\u043B\u0435\u0435 \u0443\u043F\u0440\u0430\u0432\u043B\u044F\u0435\u043C\u044B\u0435 \u0444\u0443\u043D\u043A\u0446\u0438\u0438.\n \"max-lines-per-function\": [\n \"error\",\n { max: 100, skipComments: true, skipBlankLines: true },\n ],\n \"max-depth\": [\"error\", { max: 3 }],\n\n \"no-param-reassign\": [\"error\", { props: true }],\n //sonarjs \u043F\u0440\u0430\u0432\u0438\u043B\u0430\n \"sonarjs/cognitive-complexity\": [\"error\", 10],\n \"sonarjs/no-identical-expressions\": \"error\",\n \"sonarjs/no-ignored-return\": \"error\",\n \"sonarjs/no-redundant-boolean\": \"error\",\n },\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";
6
6
  export declare const INTEGRATION_RC_CONFIG = "//@ts-check\n\nrequire(\"dotenv\").config();\n\nconst query = `\nmutation UpdateIntegration($id: Long!, $js_code: String) {\n automation {\n integration {\n update(id: $id, js_code: $js_code) {\n id\n }\n }\n }\n}`;\n\n/**\n * @type {import(\"@infomaximum/package-cli\").IntegrationRCConfig}\n */\nconst config = {\n entry: \"src/index.ts\",\n fetcher: (integrationCode) => {\n return {\n graphqlUrl: process.env.GRAPHQL_URL,\n apiKey: process.env.API_KEY,\n query,\n variables: {\n id: process.env.INTEGRATION_ID,\n js_code: integrationCode,\n },\n };\n },\n\n debugging: {\n seriesIterations: 3,\n commonAuthData: {\n BASE_URL: process.env.WEBHOOK_URL\n },\n blocks: {},\n connections: {},\n },\n};\n\nmodule.exports = config;\n";
7
7
  export declare const INTEGRATION_ENV_EXAMPLE_CONFIG = "INTEGRATION_ID=0\nGRAPHQL_URL=https://example.com/graphql\nAPI_KEY=123456789qwertyuiop\nWEBHOOK_URL=https://example.com/webhook\n";
@@ -10,3 +10,4 @@ export declare const INTEGRATION_VSCODE_SETTINGS = "{\n \"typescript.tsdk\": \"
10
10
  export declare const INTEGRATION_VSCODE_EXTENSIONS = "{\n \"recommendations\": [\"Jokerok.integration-debugger\"]\n}\n";
11
11
  export declare const INTEGRATION_HUSKY_PRECOMMIT = "yarn lint\n";
12
12
  export declare const INTEGRATION_HUSKY_COMMITMSG = "yarn commitlint --edit $1\n";
13
+ export declare const INTEGRATION_COMMITLINT_CONFIG = "{\n \"extends\": [\"@commitlint/config-conventional\"]\n}\n";