arui-scripts 0.0.0-next-20230725145300

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 (170) hide show
  1. package/.browserslistrc +5 -0
  2. package/.turbo/turbo-build.log +0 -0
  3. package/.turbo/turbo-test.log +91 -0
  4. package/CHANGELOG.md +1032 -0
  5. package/README.md +716 -0
  6. package/bin/build.sh +2 -0
  7. package/build/bin/index.d.ts +3 -0
  8. package/build/bin/index.js +21 -0
  9. package/build/commands/archive-build/index.d.ts +1 -0
  10. package/build/commands/archive-build/index.js +80 -0
  11. package/build/commands/build/build-wrapper.d.ts +8 -0
  12. package/build/commands/build/build-wrapper.js +41 -0
  13. package/build/commands/build/client.d.ts +1 -0
  14. package/build/commands/build/client.js +41 -0
  15. package/build/commands/build/index.d.ts +1 -0
  16. package/build/commands/build/index.js +10 -0
  17. package/build/commands/build/server.d.ts +1 -0
  18. package/build/commands/build/server.js +29 -0
  19. package/build/commands/bundle-analyze/index.d.ts +1 -0
  20. package/build/commands/bundle-analyze/index.js +36 -0
  21. package/build/commands/changelog/index.d.ts +5 -0
  22. package/build/commands/changelog/index.js +116 -0
  23. package/build/commands/docker-build/index.d.ts +1 -0
  24. package/build/commands/docker-build/index.js +70 -0
  25. package/build/commands/docker-build-compiled/index.d.ts +1 -0
  26. package/build/commands/docker-build-compiled/index.js +52 -0
  27. package/build/commands/ensure-yarn/index.d.ts +0 -0
  28. package/build/commands/ensure-yarn/index.js +8 -0
  29. package/build/commands/start/client.d.ts +1 -0
  30. package/build/commands/start/client.js +8 -0
  31. package/build/commands/start/index.d.ts +1 -0
  32. package/build/commands/start/index.js +8 -0
  33. package/build/commands/start/print-compiler-output.d.ts +1 -0
  34. package/build/commands/start/print-compiler-output.js +15 -0
  35. package/build/commands/start/server.d.ts +1 -0
  36. package/build/commands/start/server.js +8 -0
  37. package/build/commands/start-prod/client.d.ts +1 -0
  38. package/build/commands/start-prod/client.js +8 -0
  39. package/build/commands/start-prod/index.d.ts +1 -0
  40. package/build/commands/start-prod/index.js +8 -0
  41. package/build/commands/start-prod/server.d.ts +1 -0
  42. package/build/commands/start-prod/server.js +8 -0
  43. package/build/commands/test/index.d.ts +3 -0
  44. package/build/commands/test/index.js +17 -0
  45. package/build/commands/util/check-required-files.d.ts +2 -0
  46. package/build/commands/util/check-required-files.js +67 -0
  47. package/build/commands/util/client-assets-sizes.d.ts +26 -0
  48. package/build/commands/util/client-assets-sizes.js +88 -0
  49. package/build/commands/util/docker-build.d.ts +21 -0
  50. package/build/commands/util/docker-build.js +89 -0
  51. package/build/commands/util/exec.d.ts +2 -0
  52. package/build/commands/util/exec.js +18 -0
  53. package/build/commands/util/format-webpack-messages.d.ts +11 -0
  54. package/build/commands/util/format-webpack-messages.js +93 -0
  55. package/build/commands/util/make-tmp-dir.d.ts +6 -0
  56. package/build/commands/util/make-tmp-dir.js +29 -0
  57. package/build/commands/util/run-client-dev-server.d.ts +2 -0
  58. package/build/commands/util/run-client-dev-server.js +47 -0
  59. package/build/commands/util/run-compilers.d.ts +1 -0
  60. package/build/commands/util/run-compilers.js +31 -0
  61. package/build/commands/util/run-server-watch-compiler.d.ts +2 -0
  62. package/build/commands/util/run-server-watch-compiler.js +21 -0
  63. package/build/commands/util/yarn.d.ts +5 -0
  64. package/build/commands/util/yarn.js +53 -0
  65. package/build/configs/app-configs/calculate-dependent-config.d.ts +76 -0
  66. package/build/configs/app-configs/calculate-dependent-config.js +37 -0
  67. package/build/configs/app-configs/get-defaults.d.ts +3 -0
  68. package/build/configs/app-configs/get-defaults.js +127 -0
  69. package/build/configs/app-configs/index.d.ts +6 -0
  70. package/build/configs/app-configs/index.js +22 -0
  71. package/build/configs/app-configs/types.d.ts +108 -0
  72. package/build/configs/app-configs/types.js +2 -0
  73. package/build/configs/app-configs/update-with-config-file.d.ts +2 -0
  74. package/build/configs/app-configs/update-with-config-file.js +23 -0
  75. package/build/configs/app-configs/update-with-env.d.ts +2 -0
  76. package/build/configs/app-configs/update-with-env.js +20 -0
  77. package/build/configs/app-configs/update-with-package.d.ts +2 -0
  78. package/build/configs/app-configs/update-with-package.js +10 -0
  79. package/build/configs/app-configs/update-with-presets.d.ts +2 -0
  80. package/build/configs/app-configs/update-with-presets.js +26 -0
  81. package/build/configs/app-configs/validate-settings-keys.d.ts +4 -0
  82. package/build/configs/app-configs/validate-settings-keys.js +14 -0
  83. package/build/configs/babel-client.d.ts +34 -0
  84. package/build/configs/babel-client.js +65 -0
  85. package/build/configs/babel-dependencies.d.ts +14 -0
  86. package/build/configs/babel-dependencies.js +39 -0
  87. package/build/configs/babel-server.d.ts +27 -0
  88. package/build/configs/babel-server.js +47 -0
  89. package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +2 -0
  90. package/build/configs/config-extras/minimizers/imagemin/imagemin.js +42 -0
  91. package/build/configs/config-extras/minimizers/imagemin/index.d.ts +1 -0
  92. package/build/configs/config-extras/minimizers/imagemin/index.js +17 -0
  93. package/build/configs/config-extras/minimizers/index.d.ts +1 -0
  94. package/build/configs/config-extras/minimizers/index.js +17 -0
  95. package/build/configs/dev-server.d.ts +2 -0
  96. package/build/configs/dev-server.js +48 -0
  97. package/build/configs/jest/babel-transform.d.ts +2 -0
  98. package/build/configs/jest/babel-transform.js +4 -0
  99. package/build/configs/jest/css-mock.d.ts +1 -0
  100. package/build/configs/jest/css-mock.js +2 -0
  101. package/build/configs/jest/file-transform.d.ts +3 -0
  102. package/build/configs/jest/file-transform.js +9 -0
  103. package/build/configs/jest/index.d.ts +50 -0
  104. package/build/configs/jest/index.js +47 -0
  105. package/build/configs/modules.d.ts +16 -0
  106. package/build/configs/modules.js +101 -0
  107. package/build/configs/mq.css +22 -0
  108. package/build/configs/postcss.config.d.ts +25 -0
  109. package/build/configs/postcss.config.js +62 -0
  110. package/build/configs/postcss.d.ts +2 -0
  111. package/build/configs/postcss.js +9 -0
  112. package/build/configs/process-assets-plugin-output.d.ts +2 -0
  113. package/build/configs/process-assets-plugin-output.js +46 -0
  114. package/build/configs/server-externals-exemptions.d.ts +1 -0
  115. package/build/configs/server-externals-exemptions.js +21 -0
  116. package/build/configs/stats-options.d.ts +3 -0
  117. package/build/configs/stats-options.js +49 -0
  118. package/build/configs/supporting-browsers.d.ts +2 -0
  119. package/build/configs/supporting-browsers.js +13 -0
  120. package/build/configs/util/apply-overrides.d.ts +56 -0
  121. package/build/configs/util/apply-overrides.js +47 -0
  122. package/build/configs/util/check-node-version.d.ts +2 -0
  123. package/build/configs/util/check-node-version.js +7 -0
  124. package/build/configs/util/find-loader.d.ts +2 -0
  125. package/build/configs/util/find-loader.js +23 -0
  126. package/build/configs/util/get-entry.d.ts +9 -0
  127. package/build/configs/util/get-entry.js +22 -0
  128. package/build/configs/util/get-polyfills.d.ts +3 -0
  129. package/build/configs/util/get-polyfills.js +27 -0
  130. package/build/configs/util/install-sourcemap-support.d.ts +1 -0
  131. package/build/configs/util/install-sourcemap-support.js +7 -0
  132. package/build/configs/util/node-assets-ignore.d.ts +0 -0
  133. package/build/configs/util/node-assets-ignore.js +31 -0
  134. package/build/configs/util/noop.d.ts +1 -0
  135. package/build/configs/util/noop.js +2 -0
  136. package/build/configs/util/register-ts-node.d.ts +0 -0
  137. package/build/configs/util/register-ts-node.js +17 -0
  138. package/build/configs/util/resolve.d.ts +12 -0
  139. package/build/configs/util/resolve.js +30 -0
  140. package/build/configs/webpack.client.d.ts +10 -0
  141. package/build/configs/webpack.client.dev.d.ts +2 -0
  142. package/build/configs/webpack.client.dev.js +9 -0
  143. package/build/configs/webpack.client.js +402 -0
  144. package/build/configs/webpack.client.prod.d.ts +2 -0
  145. package/build/configs/webpack.client.prod.js +9 -0
  146. package/build/configs/webpack.server.d.ts +2 -0
  147. package/build/configs/webpack.server.dev.d.ts +2 -0
  148. package/build/configs/webpack.server.dev.js +9 -0
  149. package/build/configs/webpack.server.js +229 -0
  150. package/build/configs/webpack.server.prod.d.ts +2 -0
  151. package/build/configs/webpack.server.prod.js +9 -0
  152. package/build/index.d.ts +5 -0
  153. package/build/index.js +9 -0
  154. package/build/plugins/reload-server-webpack-plugin.d.ts +9 -0
  155. package/build/plugins/reload-server-webpack-plugin.js +42 -0
  156. package/build/templates/dockerfile-compiled.template.d.ts +2 -0
  157. package/build/templates/dockerfile-compiled.template.js +47 -0
  158. package/build/templates/dockerfile.template.d.ts +2 -0
  159. package/build/templates/dockerfile.template.js +32 -0
  160. package/build/templates/nginx.conf.template.d.ts +2 -0
  161. package/build/templates/nginx.conf.template.js +34 -0
  162. package/build/templates/start.template.d.ts +2 -0
  163. package/build/templates/start.template.js +37 -0
  164. package/build/tsconfig-local.tsbuildinfo +1 -0
  165. package/docs/modules.md +572 -0
  166. package/jest-preset.js +22 -0
  167. package/package.json +172 -0
  168. package/release.config.js +21 -0
  169. package/tsconfig-local.json +16 -0
  170. package/tsconfig.json +71 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const run_compilers_1 = require("../util/run-compilers");
4
+ process.env.BROWSERSLIST_CONFIG = process.env.BROWSERSLIST_CONFIG || require.resolve('../../../.browserslistrc');
5
+ (0, run_compilers_1.runCompilers)([
6
+ require.resolve('./client'),
7
+ require.resolve('./server'),
8
+ ]);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const webpack_server_prod_1 = __importDefault(require("../../configs/webpack.server.prod"));
7
+ const run_server_watch_compiler_1 = require("../util/run-server-watch-compiler");
8
+ (0, run_server_watch_compiler_1.runServerWatchCompiler)(webpack_server_prod_1.default);
@@ -0,0 +1,3 @@
1
+ declare const jestRunner: any;
2
+ declare const jestConfig: any;
3
+ declare const argv: string[];
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // Do this as the first thing so that any code reading it knows the right env.
3
+ process.env.BABEL_ENV = 'test';
4
+ process.env.NODE_ENV = 'test';
5
+ process.env.PUBLIC_URL = '';
6
+ const jestRunner = require('jest');
7
+ const jestConfig = require('../../configs/jest');
8
+ // Makes the script crash on unhandled rejections instead of silently
9
+ // ignoring them. In the future, promise rejections that are not handled will
10
+ // terminate the Node.js process with a non-zero exit code.
11
+ process.on('unhandledRejection', err => {
12
+ throw err;
13
+ });
14
+ // Skip 'node', 'arui-scripts' and 'test' arguments and take all the rest (or none if there is no more arguments).
15
+ const argv = process.argv.slice(3);
16
+ argv.push('--config', JSON.stringify(jestConfig));
17
+ jestRunner.run(argv);
@@ -0,0 +1,2 @@
1
+ declare function checkRequiredFiles(): boolean;
2
+ export default checkRequiredFiles;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
10
+ const extensions = ['ts', 'tsx', 'js', 'jsx'];
11
+ function entryPointToArray(entryPoint) {
12
+ if (typeof entryPoint === 'string') {
13
+ return [entryPoint];
14
+ }
15
+ if (Array.isArray(entryPoint)) {
16
+ return entryPoint;
17
+ }
18
+ return Object.keys(entryPoint).reduce((result, name) => {
19
+ const entry = entryPointToArray(entryPoint[name]);
20
+ return [...result, ...entry];
21
+ }, []);
22
+ }
23
+ const files = [
24
+ ...entryPointToArray(app_configs_1.default.serverEntry),
25
+ ...entryPointToArray(app_configs_1.default.clientEntry),
26
+ ...(Array.isArray(app_configs_1.default.clientPolyfillsEntry) ? app_configs_1.default.clientPolyfillsEntry : [app_configs_1.default.clientPolyfillsEntry]),
27
+ ];
28
+ function checkFileWithExtensions(filePath, extensions) {
29
+ if (extensions.some(ext => filePath.endsWith(`.${ext}`))) {
30
+ try {
31
+ fs_1.default.accessSync(filePath);
32
+ return true;
33
+ }
34
+ catch (err) { }
35
+ }
36
+ for (let i = 0; i < extensions.length; i++) {
37
+ try {
38
+ fs_1.default.accessSync(`${filePath}.${extensions[i]}`);
39
+ return true;
40
+ }
41
+ catch (err) { }
42
+ }
43
+ return false;
44
+ }
45
+ function checkRequiredFiles() {
46
+ const unavailableFilePaths = files
47
+ .filter(Boolean)
48
+ .reduce((result, filePath) => {
49
+ if (filePath && !checkFileWithExtensions(filePath, extensions)) {
50
+ result.push(filePath);
51
+ }
52
+ return result;
53
+ }, []);
54
+ if (unavailableFilePaths.length !== 0) {
55
+ console.log(chalk_1.default.red('Could not find required files.'));
56
+ const extensionsString = extensions.join(',');
57
+ unavailableFilePaths.forEach(filePath => {
58
+ const dirName = path_1.default.dirname(filePath);
59
+ const fileName = path_1.default.basename(filePath);
60
+ console.log(chalk_1.default.red(' Name: ') + chalk_1.default.cyan(`${fileName}.{${extensionsString}}`));
61
+ console.log(chalk_1.default.red(' Searched in: ') + chalk_1.default.cyan(dirName));
62
+ });
63
+ return false;
64
+ }
65
+ return true;
66
+ }
67
+ exports.default = checkRequiredFiles;
@@ -0,0 +1,26 @@
1
+ import { Stats } from 'webpack';
2
+ type AssetSize = {
3
+ name: string;
4
+ fullName: string;
5
+ gzipSize: number;
6
+ brotliSize: number;
7
+ size: number;
8
+ sizeLabel: string;
9
+ gzipLabel: string;
10
+ brotliLabel: string;
11
+ };
12
+ type TotalSizes = {
13
+ size: number;
14
+ sizeLabel: string;
15
+ gzipSize: number;
16
+ gzipLabel: string;
17
+ brotliSize: number;
18
+ brotliLabel: string;
19
+ };
20
+ type ClientAssetsSizes = {
21
+ totalSizes: TotalSizes;
22
+ assets: AssetSize[];
23
+ };
24
+ export declare function calculateAssetsSizes(webpackStats: Stats, rootDir?: string): ClientAssetsSizes;
25
+ export declare function printAssetsSizes(sizes: ClientAssetsSizes): void;
26
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.printAssetsSizes = exports.calculateAssetsSizes = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const gzip_size_1 = require("gzip-size");
10
+ const filesize_1 = __importDefault(require("filesize"));
11
+ const strip_ansi_1 = __importDefault(require("strip-ansi"));
12
+ const chalk_1 = __importDefault(require("chalk"));
13
+ let brotliSize = () => NaN;
14
+ try {
15
+ brotliSize = require('brotli-size').sync;
16
+ }
17
+ catch (error) {
18
+ }
19
+ function canReadAsset(asset) {
20
+ return (/\.(js|css)$/.test(asset) &&
21
+ !/service-worker\.js/.test(asset) &&
22
+ !/precache-manifest\.[0-9a-f]+\.js/.test(asset));
23
+ }
24
+ function removeFileNameHash(fileName) {
25
+ return fileName
26
+ .replace(/\\/g, '/')
27
+ .replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
28
+ }
29
+ function calculateAssetsSizes(webpackStats, rootDir = '') {
30
+ const assetsStats = (webpackStats
31
+ .toJson({ all: false, assets: true })
32
+ .assets || []);
33
+ const assets = assetsStats
34
+ .filter((asset) => canReadAsset(asset.name))
35
+ .map((asset) => {
36
+ const fileContents = fs_1.default.readFileSync(path_1.default.join(rootDir, asset.name));
37
+ const size = (0, gzip_size_1.sync)(fileContents);
38
+ const brSize = brotliSize(fileContents);
39
+ const filename = path_1.default.basename(asset.name);
40
+ return {
41
+ name: removeFileNameHash(filename),
42
+ fullName: filename,
43
+ gzipSize: size,
44
+ brotliSize: brSize,
45
+ size: asset.size,
46
+ sizeLabel: (0, filesize_1.default)(asset.size),
47
+ gzipLabel: (0, filesize_1.default)(size),
48
+ brotliLabel: brSize ? (0, filesize_1.default)(brSize) : '-'
49
+ };
50
+ });
51
+ const totalSizes = (assets || []).reduce((file, total) => {
52
+ return {
53
+ size: total.size + file.size,
54
+ gzipSize: total.gzipSize + file.gzipSize,
55
+ brotliSize: total.brotliSize + file.brotliSize
56
+ };
57
+ }, { size: 0, gzipSize: 0, brotliSize: 0 });
58
+ totalSizes.sizeLabel = (0, filesize_1.default)(totalSizes.size || 0);
59
+ totalSizes.gzipLabel = (0, filesize_1.default)(totalSizes.gzipSize || 0);
60
+ totalSizes.brotliLabel = totalSizes.brotliSize ? (0, filesize_1.default)(totalSizes.brotliSize) : '-';
61
+ return {
62
+ totalSizes: totalSizes,
63
+ assets
64
+ };
65
+ }
66
+ exports.calculateAssetsSizes = calculateAssetsSizes;
67
+ function printAssetsSizes(sizes) {
68
+ const longestSizeLabelLength = Math.max.apply(null, sizes.assets.map(a => {
69
+ const sizeLength = (0, strip_ansi_1.default)(a.gzipLabel).length;
70
+ return sizeLength + sizeLength + 8;
71
+ }));
72
+ console.log(chalk_1.default.blueBright('Assets sizes:'));
73
+ sizes.assets.forEach(asset => {
74
+ let sizeLabel = `${asset.sizeLabel} (${asset.gzipLabel} gzip, ${asset.brotliLabel} br)`;
75
+ const sizeLength = (0, strip_ansi_1.default)(sizeLabel).length;
76
+ if (sizeLength < longestSizeLabelLength) {
77
+ const rightPadding = ' '.repeat(longestSizeLabelLength - sizeLength);
78
+ sizeLabel += rightPadding;
79
+ }
80
+ console.log(' ' +
81
+ sizeLabel +
82
+ ' ' +
83
+ chalk_1.default.cyan(asset.name));
84
+ });
85
+ console.log(chalk_1.default.blueBright('\nTotal size:\n') +
86
+ ` ${sizes.totalSizes.sizeLabel} (${sizes.totalSizes.gzipLabel} gzip, ${sizes.totalSizes.brotliLabel} br)\n`);
87
+ }
88
+ exports.printAssetsSizes = printAssetsSizes;
@@ -0,0 +1,21 @@
1
+ export declare function getBuildParamsFromArgs(): {
2
+ pathToTempDir: string;
3
+ imageFullName: string;
4
+ tempDirName: string;
5
+ };
6
+ type PrepareFilesForDockerParams = {
7
+ dockerfileTemplate: string;
8
+ nginxConfTemplate: string;
9
+ startScriptTemplate: string;
10
+ pathToTempDir: string;
11
+ allowLocalDockerfile: boolean;
12
+ allowLocalStartScript: boolean;
13
+ };
14
+ export declare function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript }: PrepareFilesForDockerParams): Promise<void>;
15
+ export declare function dockerVersionSatisfies(request: string): boolean;
16
+ type DockerBuildCommandParams = {
17
+ tempDirName: string;
18
+ imageFullName: string;
19
+ };
20
+ export declare function getDockerBuildCommand({ tempDirName, imageFullName }: DockerBuildCommandParams): string;
21
+ export {};
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getDockerBuildCommand = exports.dockerVersionSatisfies = exports.prepareFilesForDocker = exports.getBuildParamsFromArgs = void 0;
16
+ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const fs_extra_1 = __importDefault(require("fs-extra"));
19
+ const shelljs_1 = __importDefault(require("shelljs"));
20
+ const satisfies_1 = __importDefault(require("semver/functions/satisfies"));
21
+ function getBuildParamsFromArgs() {
22
+ let imageVersion = app_configs_1.default.version;
23
+ let imageName = app_configs_1.default.name;
24
+ let dockerRegistry = app_configs_1.default.dockerRegistry;
25
+ const commandLineArguments = process.argv.slice(3);
26
+ commandLineArguments.forEach(arg => {
27
+ let [argName, argValue] = arg.split('=');
28
+ argName = argName.toLowerCase().trim();
29
+ argValue = argValue ? argValue.trim() : '';
30
+ switch (argName) {
31
+ case 'version':
32
+ imageVersion = argValue;
33
+ break;
34
+ case 'name':
35
+ imageName = argValue;
36
+ break;
37
+ case 'registry':
38
+ dockerRegistry = argValue;
39
+ break;
40
+ default:
41
+ console.warn(`Unknown argument ${argName}`);
42
+ }
43
+ });
44
+ const tempDirName = '.docker-build';
45
+ const pathToTempDir = path_1.default.join(app_configs_1.default.cwd, tempDirName);
46
+ const imageFullName = `${dockerRegistry ? `${dockerRegistry}/` : ''}${imageName}:${imageVersion}`;
47
+ return {
48
+ pathToTempDir,
49
+ imageFullName,
50
+ tempDirName,
51
+ };
52
+ }
53
+ exports.getBuildParamsFromArgs = getBuildParamsFromArgs;
54
+ function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript }) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ yield fs_extra_1.default.emptyDir(pathToTempDir);
57
+ const nginxConf = app_configs_1.default.localNginxConf
58
+ ? yield fs_extra_1.default.readFile(app_configs_1.default.localNginxConf, 'utf8')
59
+ : nginxConfTemplate;
60
+ const dockerfile = app_configs_1.default.localDockerfile && allowLocalDockerfile
61
+ ? yield fs_extra_1.default.readFile(app_configs_1.default.localDockerfile, 'utf8')
62
+ : dockerfileTemplate;
63
+ const startScript = app_configs_1.default.localStartScript && allowLocalStartScript
64
+ ? yield fs_extra_1.default.readFile(app_configs_1.default.localStartScript, 'utf8')
65
+ : startScriptTemplate;
66
+ yield Promise.all([
67
+ fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'Dockerfile'), dockerfile, 'utf8'),
68
+ fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'nginx.conf'), nginxConf, 'utf8'),
69
+ fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'start.sh'), startScript, { encoding: 'utf8', mode: 0o555 }),
70
+ ]);
71
+ });
72
+ }
73
+ exports.prepareFilesForDocker = prepareFilesForDocker;
74
+ function dockerVersionSatisfies(request) {
75
+ const dockerVersion = shelljs_1.default.exec('docker version --format \'{{.Server.Version}}\'', { silent: true });
76
+ return (0, satisfies_1.default)(dockerVersion.toString(), request);
77
+ }
78
+ exports.dockerVersionSatisfies = dockerVersionSatisfies;
79
+ function getDockerBuildCommand({ tempDirName, imageFullName }) {
80
+ // если пытаться собрать проект на маках с m1, докер будет пытаться вытянуть базовый образ под свою платформу и
81
+ // упадет с ошибкой. Чтобы этого избежать - достаточно использовать флаг --platform. Но он поддерживается только начиная
82
+ // с docker 17.12, а на многих серверах, используемых для сборки до сих пор живет докер 1.13.1
83
+ // Соответственно они будут падать при наличии этого флага.
84
+ const canUsePlatformFlag = dockerVersionSatisfies('>=17.12');
85
+ return `docker build ${canUsePlatformFlag ? '--platform linux/x86_64' : ''} -f "./${tempDirName}/Dockerfile" \\
86
+ --build-arg START_SH_LOCATION="./${tempDirName}/start.sh" \\
87
+ --build-arg NGINX_CONF_LOCATION="./${tempDirName}/nginx.conf" -t ${imageFullName} .`;
88
+ }
89
+ exports.getDockerBuildCommand = getDockerBuildCommand;
@@ -0,0 +1,2 @@
1
+ declare function exec(command: string): Promise<unknown>;
2
+ export default exec;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const shelljs_1 = __importDefault(require("shelljs"));
7
+ function exec(command) {
8
+ return new Promise((resolve, reject) => {
9
+ console.log(`Executing command: ${command}`);
10
+ shelljs_1.default.exec(command, (code) => {
11
+ if (code === 0) {
12
+ return resolve(code);
13
+ }
14
+ reject(code);
15
+ });
16
+ });
17
+ }
18
+ exports.default = exec;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ declare function formatWebpackMessages(json: any): {
8
+ errors: any;
9
+ warnings: any;
10
+ };
11
+ export default formatWebpackMessages;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2015-present, Facebook, Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ // WARNING: this code is untranspiled and is used in browser too.
10
+ // Please make sure any changes are in ES5 or contribute a Babel compile step.
11
+ // Some custom utilities to prettify Webpack output.
12
+ // This is quite hacky and hopefully won't be needed when Webpack fixes this.
13
+ // https://github.com/webpack/webpack/issues/2878
14
+ const chalk = require('chalk');
15
+ const friendlySyntaxErrorLabel = 'Syntax error:';
16
+ function isLikelyASyntaxError(message) {
17
+ return message.includes(friendlySyntaxErrorLabel);
18
+ }
19
+ // Cleans up webpack error messages.
20
+ // eslint-disable-next-line no-unused-vars
21
+ function formatMessage(message) {
22
+ if (typeof message !== 'string') {
23
+ message = message.message;
24
+ }
25
+ let lines = message.split('\n');
26
+ // Strip webpack-added headers off errors/warnings
27
+ // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
28
+ lines = lines.filter(line => !/Module [A-z ]+\(from/.test(line));
29
+ // Transform parsing error into syntax error
30
+ // TODO: move this to our ESLint formatter?
31
+ lines = lines.map(line => {
32
+ const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
33
+ if (!parsingError) {
34
+ return line;
35
+ }
36
+ const [, errorLine, errorColumn, errorMessage] = parsingError;
37
+ return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
38
+ });
39
+ message = lines.join('\n');
40
+ // Smoosh syntax errors (commonly found in CSS)
41
+ message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)\n`);
42
+ // Clean up export errors
43
+ message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$2'.`);
44
+ message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$2' does not contain a default export (imported as '$1').`);
45
+ message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$3' (imported as '$2').`);
46
+ lines = message.split('\n');
47
+ // Remove leading newline
48
+ if (lines.length > 2 && lines[1].trim() === '') {
49
+ lines.splice(1, 1);
50
+ }
51
+ // Clean up file name
52
+ lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
53
+ // Cleans up verbose "module not found" messages for files and packages.
54
+ if (lines[1] && lines[1].indexOf('Module not found: ') === 0) {
55
+ lines = [
56
+ lines[0],
57
+ lines[1]
58
+ .replace('Error: ', '')
59
+ .replace('Module not found: Cannot find file:', 'Cannot find file:'),
60
+ ];
61
+ }
62
+ // Add helpful message for users trying to use Sass for the first time
63
+ if (lines[1] && lines[1].match(/Cannot find module.+node-sass/)) {
64
+ lines[1] = 'To import Sass files, you first need to install node-sass.\n';
65
+ lines[1] +=
66
+ 'Run `npm install node-sass` or `yarn add node-sass` inside your workspace.';
67
+ }
68
+ lines[0] = chalk.inverse(lines[0]);
69
+ message = lines.join('\n');
70
+ // Internal stacks are generally useless so we strip them... with the
71
+ // exception of stacks containing `webpack:` because they're normally
72
+ // from user code generated by webpack. For more information see
73
+ // https://github.com/facebook/create-react-app/pull/1050
74
+ message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, ''); // at ... ...:x:y
75
+ message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, ''); // at <anonymous>
76
+ lines = message.split('\n');
77
+ // Remove duplicated newlines
78
+ lines = lines.filter((line, index, arr) => index === 0 || line.trim() !== '' || line.trim() !== arr[index - 1].trim());
79
+ // Reassemble the message
80
+ message = lines.join('\n');
81
+ return message.trim();
82
+ }
83
+ function formatWebpackMessages(json) {
84
+ const formattedErrors = json.errors.map(formatMessage);
85
+ const formattedWarnings = json.warnings.map(formatMessage);
86
+ const result = { errors: formattedErrors, warnings: formattedWarnings };
87
+ if (result.errors.some(isLikelyASyntaxError)) {
88
+ // If there are any syntax errors, show just them.
89
+ result.errors = result.errors.filter(isLikelyASyntaxError);
90
+ }
91
+ return result;
92
+ }
93
+ exports.default = formatWebpackMessages;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Создает и возвращает временную папку
3
+ * @returns {Promise<string>}
4
+ */
5
+ declare function makeTmpDir(prefix?: string): Promise<string>;
6
+ export default makeTmpDir;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const path_1 = __importDefault(require("path"));
16
+ const util_1 = __importDefault(require("util"));
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const os_1 = __importDefault(require("os"));
19
+ const nodeMakeTmpDir = util_1.default.promisify(fs_1.default.mkdtemp);
20
+ /**
21
+ * Создает и возвращает временную папку
22
+ * @returns {Promise<string>}
23
+ */
24
+ function makeTmpDir(prefix) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return yield nodeMakeTmpDir(path_1.default.join(os_1.default.tmpdir(), prefix || ''));
27
+ });
28
+ }
29
+ exports.default = makeTmpDir;
@@ -0,0 +1,2 @@
1
+ import { Configuration } from 'webpack';
2
+ export declare function runClientDevServer(configuration: Configuration | Configuration[]): Promise<void>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.runClientDevServer = void 0;
16
+ const webpack_1 = __importDefault(require("webpack"));
17
+ const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
18
+ const dev_server_1 = __importDefault(require("../../configs/dev-server"));
19
+ const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
20
+ const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
21
+ function runClientDevServer(configuration) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const clientCompiler = (0, webpack_1.default)(configuration); // типы вебпака не умеют выбирать между конфигурациями и массивом конфигураций
24
+ const clientDevServer = new webpack_dev_server_1.default(dev_server_1.default, clientCompiler);
25
+ clientCompiler.hooks.invalid.tap('client', () => console.log('Compiling client...'));
26
+ clientCompiler.hooks.done.tap('client', (stats) => (0, print_compiler_output_1.default)('Client', stats));
27
+ const DEFAULT_PORT = dev_server_1.default.port;
28
+ const HOST = '0.0.0.0';
29
+ try {
30
+ const port = yield (0, WebpackDevServerUtils_1.choosePort)(HOST, +(DEFAULT_PORT || 0));
31
+ if (!port) {
32
+ // We have not found a port.
33
+ return;
34
+ }
35
+ clientDevServer.startCallback(() => {
36
+ console.log(`Client dev server running at http://${HOST}:${port}...`);
37
+ });
38
+ }
39
+ catch (err) {
40
+ if (err && err.message) {
41
+ console.log(err.message);
42
+ }
43
+ process.exit(1);
44
+ }
45
+ });
46
+ }
47
+ exports.runClientDevServer = runClientDevServer;
@@ -0,0 +1 @@
1
+ export declare function runCompilers(pathToCompilers: string[]): void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runCompilers = void 0;
7
+ const check_required_files_1 = __importDefault(require("./check-required-files"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
10
+ const child_process_1 = require("child_process");
11
+ function runCompilers(pathToCompilers) {
12
+ if (!(0, check_required_files_1.default)()) {
13
+ process.exit(1);
14
+ }
15
+ if (fs_extra_1.default.pathExistsSync(app_configs_1.default.serverOutputPath)) {
16
+ fs_extra_1.default.removeSync(app_configs_1.default.serverOutputPath);
17
+ }
18
+ const compilers = pathToCompilers.map((pathToCompiler) => {
19
+ const compiler = (0, child_process_1.spawn)('node', [pathToCompiler], { stdio: 'inherit' });
20
+ compiler.on('error', onProcessExit);
21
+ compiler.on('close', onProcessExit);
22
+ return compiler;
23
+ });
24
+ function onProcessExit(code) {
25
+ if (code !== 0) {
26
+ compilers.forEach((compiler) => compiler.kill());
27
+ process.exit(code);
28
+ }
29
+ }
30
+ }
31
+ exports.runCompilers = runCompilers;
@@ -0,0 +1,2 @@
1
+ import webpack from 'webpack';
2
+ export declare function runServerWatchCompiler(config: webpack.Configuration): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runServerWatchCompiler = void 0;
7
+ const webpack_1 = __importDefault(require("webpack"));
8
+ const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
9
+ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
10
+ function runServerWatchCompiler(config) {
11
+ const serverCompiler = (0, webpack_1.default)(config);
12
+ serverCompiler.hooks.compile.tap('server', () => console.log('Compiling server...'));
13
+ serverCompiler.hooks.invalid.tap('server', () => console.log('Compiling server...'));
14
+ serverCompiler.hooks.done.tap('server', (stats) => (0, print_compiler_output_1.default)('Server', stats));
15
+ serverCompiler.watch({
16
+ aggregateTimeout: 50,
17
+ ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
18
+ }, () => {
19
+ });
20
+ }
21
+ exports.runServerWatchCompiler = runServerWatchCompiler;
@@ -0,0 +1,5 @@
1
+ type YarnVersion = '1' | '2+' | 'unavailable';
2
+ export declare function getYarnVersion(): YarnVersion;
3
+ export declare function getPruningCommand(): string;
4
+ export declare function getInstallProductionCommand(): string;
5
+ export {};