@infomaximum/package-cli 1.9.2 → 1.10.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.
@@ -1,24 +1,25 @@
1
+ import { __awaiter } from "tslib";
1
2
  import ZipPlugin from "zip-webpack-plugin";
2
3
  import RemovePlugin from "remove-files-webpack-plugin";
3
4
  import CopyWebpackPlugin from "copy-webpack-plugin";
4
5
  import path from "path";
5
6
  import { JsonModifyWebpackPlugin } from "@infomaximum/json-modify-webpack-plugin";
6
- import { systemRequire } from "../../utils.js";
7
- import { BUILD_ARCHIVE_EXT, BUILD_WIDGET_CONFIG_NAME, MANIFEST_REG_EXP, WIDGET_ARCHIVE_FULL_NAME, } from "../../const.js";
7
+ import { isExist, systemRequire } from "../../utils.js";
8
+ import { BUILD_ARCHIVE_EXT, MANIFEST_REG_EXP, WIDGET_ARCHIVE_FULL_NAME, } from "../../const.js";
9
+ import { assertSimple } from "@infomaximum/assert";
8
10
  const packageFilename = "main.js";
9
- export const getPackageConfig = (mode, PATHS, isBuildDevMode) => {
11
+ export const getPackageConfig = (mode, PATHS, isBuildDevMode) => __awaiter(void 0, void 0, void 0, function* () {
10
12
  const widgetVersion = systemRequire(PATHS.appPackageJson).version;
11
13
  const manifestPackageName = systemRequire(PATHS.packageManifest).name;
12
14
  let widgetPackageName = `${manifestPackageName}_${widgetVersion}`;
13
15
  if (isBuildDevMode)
14
16
  widgetPackageName += "__DEV";
17
+ const widgetArchivePath = path.resolve(PATHS.appBuild, WIDGET_ARCHIVE_FULL_NAME);
18
+ assertSimple(yield isExist(PATHS.packageManifest), `File ${PATHS.packageManifest} not found`);
19
+ assertSimple(yield isExist(widgetArchivePath), `File ${widgetArchivePath} not found`);
15
20
  return {
16
21
  mode,
17
- name: "package",
18
- entry: [
19
- PATHS.packageManifest,
20
- path.resolve(PATHS.appBuild, WIDGET_ARCHIVE_FULL_NAME),
21
- ],
22
+ entry: [PATHS.packageManifest, widgetArchivePath],
22
23
  output: {
23
24
  path: PATHS.appBuild,
24
25
  filename: packageFilename,
@@ -48,6 +49,7 @@ export const getPackageConfig = (mode, PATHS, isBuildDevMode) => {
48
49
  }),
49
50
  new RemovePlugin({
50
51
  after: {
52
+ log: false,
51
53
  root: PATHS.appBuild,
52
54
  test: [
53
55
  {
@@ -76,6 +78,5 @@ export const getPackageConfig = (mode, PATHS, isBuildDevMode) => {
76
78
  ],
77
79
  }),
78
80
  ],
79
- dependencies: [BUILD_WIDGET_CONFIG_NAME],
80
81
  };
81
- };
82
+ });
@@ -2,14 +2,13 @@ import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
2
2
  import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
3
3
  import webpack, {} from "webpack";
4
4
  import { systemRequire } from "../../utils.js";
5
- import { BUILD_WIDGET_CONFIG_NAME, MANIFEST_REG_EXP } from "../../const.js";
5
+ import { MANIFEST_REG_EXP } from "../../const.js";
6
6
  const { ProgressPlugin } = webpack;
7
7
  const isProduction = (mode) => mode === "production";
8
8
  const isDevelopment = (mode) => mode === "development";
9
9
  export const getCommonWidgetConfig = (mode, PATHS) => {
10
10
  return {
11
11
  mode,
12
- name: BUILD_WIDGET_CONFIG_NAME,
13
12
  entry: [PATHS.moduleIndex, PATHS.manifestJson],
14
13
  output: {
15
14
  path: PATHS.appBuild,
package/dist/const.js CHANGED
@@ -1,6 +1,5 @@
1
1
  export const CUSTOM_WIDGET_LIB_NAME = "@infomaximum/custom-widget";
2
2
  export const CUSTOM_PACKAGE_CLI_LIB_NAME = "@infomaximum/package-cli";
3
- export const BUILD_WIDGET_CONFIG_NAME = "build-widget";
4
3
  export const WIDGET_ARCHIVE_NAME = "widget";
5
4
  export const BUILD_ARCHIVE_EXT = "zip";
6
5
  export const WIDGET_ARCHIVE_FULL_NAME = `${WIDGET_ARCHIVE_NAME}.${BUILD_ARCHIVE_EXT}`;
@@ -8,6 +8,7 @@ import { merge } from "webpack-merge";
8
8
  import { getModifyManifestWidgetPlugin } from "../../configs/webpack/sections/plugins/modifyManifestWidget.js";
9
9
  import { getMinimizer } from "../../configs/webpack/sections/plugins/minimizer.js";
10
10
  import { getZipWidgetPlugin } from "../../configs/webpack/sections/plugins/zipWidget.js";
11
+ import chalk from "chalk";
11
12
  export const runBuild = (args) => __awaiter(void 0, void 0, void 0, function* () {
12
13
  const mode = "production";
13
14
  const { entry, host, port } = args;
@@ -31,34 +32,35 @@ export const runBuild = (args) => __awaiter(void 0, void 0, void 0, function* ()
31
32
  getMinimizer(),
32
33
  ];
33
34
  const widgetConfig = merge(configSections);
34
- const configs = [
35
- widgetConfig,
36
- getPackageConfig(mode, PATHS, isBuildDevMode),
37
- ];
38
35
  try {
39
- build(configs);
36
+ yield build(widgetConfig);
37
+ console.log("");
38
+ yield build(yield getPackageConfig(mode, PATHS, isBuildDevMode));
39
+ yield checkLatestLibsVersion();
40
40
  }
41
41
  catch (error) {
42
- console.error("Failed to compile.\n");
43
- console.error(error);
42
+ console.error(chalk.red("\nFailed to compile.\n"));
43
+ console.error(chalk.red(error));
44
44
  process.exit(1);
45
45
  }
46
46
  });
47
47
  function build(config) {
48
48
  const compiler = webpack(config);
49
- return compiler.run((err, stats) => __awaiter(this, void 0, void 0, function* () {
50
- if (err) {
51
- console.error(err.stack || err);
52
- if (err === null || err === void 0 ? void 0 : err.details) {
53
- console.error(err.details);
49
+ return new Promise((res, rej) => {
50
+ compiler.run((err, stats) => {
51
+ if (err) {
52
+ console.error(err.stack || err);
53
+ if (err === null || err === void 0 ? void 0 : err.details) {
54
+ console.error(err.details);
55
+ }
56
+ rej();
54
57
  }
55
- return;
56
- }
57
- stats &&
58
- console.log(stats === null || stats === void 0 ? void 0 : stats.toString({
59
- chunks: false,
60
- colors: true,
61
- }));
62
- yield checkLatestLibsVersion();
63
- }));
58
+ stats &&
59
+ console.log(stats === null || stats === void 0 ? void 0 : stats.toString({
60
+ chunks: false,
61
+ colors: true,
62
+ }));
63
+ res();
64
+ });
65
+ });
64
66
  }
@@ -11,6 +11,7 @@ export const WIDGET_TSCONFIG_JSON = `\
11
11
  "strict": true,
12
12
  "forceConsistentCasingInFileNames": true,
13
13
  "noFallthroughCasesInSwitch": true,
14
+ "incremental": true,
14
15
  "module": "esnext",
15
16
  "moduleResolution": "node",
16
17
  "resolveJsonModule": true,
package/dist/utils.js CHANGED
@@ -8,6 +8,15 @@ import semver from "semver";
8
8
  import chalk from "chalk";
9
9
  import { CUSTOM_PACKAGE_CLI_LIB_NAME, CUSTOM_WIDGET_LIB_NAME, } from "./const.js";
10
10
  const execPromise = util.promisify(exec);
11
+ export const isExist = (entityPath) => __awaiter(void 0, void 0, void 0, function* () {
12
+ try {
13
+ yield fs.access(entityPath);
14
+ return true;
15
+ }
16
+ catch (error) {
17
+ return false;
18
+ }
19
+ });
11
20
  export const systemRequire = Module.createRequire(import.meta.url);
12
21
  export function capitalizeFirstLetter(str = "") {
13
22
  return str.charAt(0).toUpperCase() + str.slice(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/package-cli",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "exports": "./dist/index.js",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -23,6 +23,7 @@
23
23
  "dependencies": {
24
24
  "@babel/core": "^7.23.6",
25
25
  "@babel/plugin-transform-runtime": "^7.23.6",
26
+ "@infomaximum/assert": "1.1.2",
26
27
  "@infomaximum/json-modify-webpack-plugin": "^1.0.1",
27
28
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
28
29
  "@svgr/webpack": "^8.1.0",