@infomaximum/package-cli 2.24.0 → 2.26.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/CHANGELOG.md +19 -0
- package/LICENSE +183 -183
- package/dist/application/applicationPaths.d.ts +15 -0
- package/dist/application/applicationPaths.js +9 -0
- package/dist/application/commands/build.d.ts +21 -0
- package/dist/application/commands/build.js +18 -0
- package/dist/application/commands/common.d.ts +16 -0
- package/dist/application/commands/common.js +28 -0
- package/dist/application/commands/init.d.ts +2 -0
- package/dist/application/commands/init.js +15 -0
- package/dist/application/commands/start.d.ts +18 -0
- package/dist/application/commands/start.js +23 -0
- package/dist/application/commands.d.ts +2 -0
- package/dist/application/commands.js +9 -0
- package/dist/application/configs/file.d.ts +10 -0
- package/dist/application/configs/file.js +11 -0
- package/dist/application/configs/webpack/common.d.ts +4 -0
- package/dist/application/configs/webpack/common.js +139 -0
- package/dist/application/configs/webpack/sections/devServer.d.ts +21 -0
- package/dist/application/configs/webpack/sections/devServer.js +19 -0
- package/dist/application/configs/webpack/sections/devtool.d.ts +3 -0
- package/dist/application/configs/webpack/sections/devtool.js +3 -0
- package/dist/application/configs/webpack/sections/loaders/cssLoaders.d.ts +8 -0
- package/dist/application/configs/webpack/sections/loaders/cssLoaders.js +16 -0
- package/dist/application/configs/webpack/sections/plugins/minimizer.d.ts +9 -0
- package/dist/application/configs/webpack/sections/plugins/minimizer.js +23 -0
- package/dist/application/configs/webpack/sections/plugins/modifyManifestApplication.d.ts +10 -0
- package/dist/application/configs/webpack/sections/plugins/modifyManifestApplication.js +35 -0
- package/dist/application/configs/webpack/sections/plugins/reactRefresh.d.ts +2 -0
- package/dist/application/configs/webpack/sections/plugins/reactRefresh.js +4 -0
- package/dist/application/configs/webpack/sections/plugins/zipApplication.d.ts +6 -0
- package/dist/application/configs/webpack/sections/plugins/zipApplication.js +11 -0
- package/dist/application/const.d.ts +10 -0
- package/dist/application/const.js +11 -0
- package/dist/application/index.d.ts +1 -0
- package/dist/application/index.js +1 -0
- package/dist/application/scripts/build.d.ts +2 -0
- package/dist/application/scripts/build.js +63 -0
- package/dist/application/scripts/init.d.ts +23 -0
- package/dist/application/scripts/init.js +60 -0
- package/dist/application/scripts/start.d.ts +2 -0
- package/dist/application/scripts/start.js +61 -0
- package/dist/application/templates/applicationConfigs.d.ts +3 -0
- package/dist/application/templates/applicationConfigs.js +60 -0
- package/dist/application/templates/applicationManifest.d.ts +1 -0
- package/dist/application/templates/applicationManifest.js +11 -0
- package/dist/application/templates/applicationPackageJson.d.ts +1 -0
- package/dist/application/templates/applicationPackageJson.js +29 -0
- package/dist/application/templates/applicationRCConfig.d.ts +1 -0
- package/dist/application/templates/applicationRCConfig.js +14 -0
- package/dist/application/templates/src/applicationContent.d.ts +1 -0
- package/dist/application/templates/src/applicationContent.js +11 -0
- package/dist/application/templates/src/applicationIndex.d.ts +1 -0
- package/dist/application/templates/src/applicationIndex.js +34 -0
- package/dist/arguments.js +2 -0
- package/dist/integration/configs/webpack/common.js +5 -0
- package/dist/types.d.ts +1 -1
- package/package.json +4 -1
- package/schemas/applicationConfigSchema.json +48 -0
- package/schemas/applicationManifestSchema.json +29 -0
|
@@ -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,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,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,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,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";
|