arui-scripts 23.3.1 → 23.5.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,11 +1,12 @@
1
1
  ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
2
2
  ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
3
3
  ts-jest[versions] (WARN) Version 6.0.2 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <6.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
4
- PASS src/bin/__tests__/create-cli.tests.ts (33.253 s)
4
+ PASS src/templates/__tests__/dockerfile-templates.tests.ts (32.557 s)
5
+ PASS src/bin/__tests__/create-cli.tests.ts
5
6
  PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts
7
+ PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (32.977 s)
6
8
  PASS src/configs/util/__tests__/create-watch-ignore-regex.tests.ts
7
9
  PASS src/configs/util/__tests__/apply-overrides.tests.ts
8
- PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (33.909 s)
9
10
  PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
10
11
  PASS src/configs/app-configs/__tests__/update-with-package.tests.ts
11
12
  PASS src/configs/util/__tests__/compress-with-dcb.test.ts
@@ -13,12 +14,12 @@ PASS src/configs/util/__tests__/get-polyfills.tests.ts
13
14
  PASS src/plugins/postcss-global-variables/utils/__tests__/parse-variables.tests.ts
14
15
  PASS src/plugins/postcss-global-variables/utils/__tests__/get-media-query-name.tests.ts
15
16
  PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
16
- PASS src/configs/__tests__/webpack-client-modules.tests.ts (10.197 s)
17
- PASS src/configs/util/__tests__/find-plugin.tests.ts (44.432 s)
17
+ PASS src/configs/__tests__/webpack-client-modules.tests.ts (10.249 s)
18
+ PASS src/configs/util/__tests__/find-plugin.tests.ts (43.753 s)
18
19
  A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
19
20
 
20
- Test Suites: 14 passed, 14 total
21
- Tests: 37 passed, 37 total
21
+ Test Suites: 15 passed, 15 total
22
+ Tests: 45 passed, 45 total
22
23
  Snapshots: 0 total
23
- Time: 46.176 s
24
+ Time: 45.756 s
24
25
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # arui-scripts
2
2
 
3
+ ## 23.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#571](https://github.com/core-ds/arui-scripts/pull/571) [`9c548f5`](https://github.com/core-ds/arui-scripts/commit/9c548f51c44d6198c8a98dd4b03f6a3a372324b7) Thanks [@syn7xx](https://github.com/syn7xx)! - Добавлен автоматический symlink на yarn бинарник в Dockerfile при использовании yarn 2+ с yarnPath в .yarnrc.yml. Это исправляет ошибку `yarn: not found` в Docker-образах (ни полный, ни slim-образ не содержат yarn).
8
+
9
+ ## 23.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#569](https://github.com/core-ds/arui-scripts/pull/569) [`ea2dfc8`](https://github.com/core-ds/arui-scripts/commit/ea2dfc84ee753f85c94900b015d26b776f3ecc30) Thanks [@heymdall-legal](https://github.com/heymdall-legal)! - Добавлена настройка `deleteNpm` для команд `docker-build` и `docker-build:compiled`. При её
14
+ включении из docker-образа удаляются npm и связанные с ним библиотеки, что уменьшает
15
+ поверхность атаки и исключает неиспользуемые пакеты из результатов security-сканирования.
16
+
3
17
  ## 23.3.1
4
18
 
5
19
  ### Patch Changes
@@ -2,4 +2,16 @@ type YarnVersion = '1' | '2+' | 'unavailable';
2
2
  export declare function getYarnVersion(): YarnVersion;
3
3
  export declare function getPruningCommand(): string;
4
4
  export declare function getInstallProductionCommand(): string;
5
+ /**
6
+ * Читает значение yarnPath из .yarnrc.yml.
7
+ * Возвращает путь к бинарнику yarn (например .yarn/releases/yarn-4.18.0.cjs) или null.
8
+ */
9
+ export declare function getYarnPathFromRc(): string | null;
10
+ /**
11
+ * Возвращает команду для создания symlink на yarn бинарник в Docker-образе.
12
+ * Используется при yarn 2+ с yarnPath в .yarnrc.yml, чтобы yarn был доступен
13
+ * в PATH внутри Docker-образов (где yarn не установлен глобально).
14
+ * Возвращает пустую строку, если symlink не нужен.
15
+ */
16
+ export declare function getYarnBinSymlinkCommand(): string;
5
17
  export {};
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getYarnVersion = getYarnVersion;
7
7
  exports.getPruningCommand = getPruningCommand;
8
8
  exports.getInstallProductionCommand = getInstallProductionCommand;
9
+ exports.getYarnPathFromRc = getYarnPathFromRc;
10
+ exports.getYarnBinSymlinkCommand = getYarnBinSymlinkCommand;
11
+ const fs_1 = __importDefault(require("fs"));
12
+ const path_1 = __importDefault(require("path"));
9
13
  const shelljs_1 = __importDefault(require("shelljs"));
10
14
  const app_configs_1 = require("../../configs/app-configs");
11
15
  function getYarnVersion() {
@@ -53,3 +57,41 @@ function getInstallProductionCommand() {
53
57
  }
54
58
  }
55
59
  }
60
+ /**
61
+ * Читает значение yarnPath из .yarnrc.yml.
62
+ * Возвращает путь к бинарнику yarn (например .yarn/releases/yarn-4.18.0.cjs) или null.
63
+ */
64
+ function getYarnPathFromRc() {
65
+ const rcPath = path_1.default.join(app_configs_1.configs.cwd, '.yarnrc.yml');
66
+ if (!shelljs_1.default.test('-f', rcPath)) {
67
+ return null;
68
+ }
69
+ let content;
70
+ try {
71
+ content = fs_1.default.readFileSync(rcPath, 'utf8');
72
+ }
73
+ catch (_a) {
74
+ return null;
75
+ }
76
+ // Ищем строку вида: yarnPath: .yarn/releases/yarn-4.18.0.cjs
77
+ // Значение может быть в кавычках или без
78
+ const match = content.match(/^\s*yarnPath:\s*['"]?([^'"\s]+)['"]?\s*$/m);
79
+ return match ? match[1] : null;
80
+ }
81
+ /**
82
+ * Возвращает команду для создания symlink на yarn бинарник в Docker-образе.
83
+ * Используется при yarn 2+ с yarnPath в .yarnrc.yml, чтобы yarn был доступен
84
+ * в PATH внутри Docker-образов (где yarn не установлен глобально).
85
+ * Возвращает пустую строку, если symlink не нужен.
86
+ */
87
+ function getYarnBinSymlinkCommand() {
88
+ if (getYarnVersion() !== '2+') {
89
+ return '';
90
+ }
91
+ const yarnPath = getYarnPathFromRc();
92
+ if (!yarnPath) {
93
+ return '';
94
+ }
95
+ // WORKDIR в Dockerfile = /src
96
+ return `ln -s /src/${yarnPath} /usr/local/bin/yarn && \\\n `;
97
+ }
@@ -45,6 +45,7 @@ function getDefaultAppConfig() {
45
45
  nginx: null,
46
46
  runFromNonRootUser: true,
47
47
  removeDevDependenciesDuringDockerBuild: true,
48
+ deleteNpm: false,
48
49
  // archive compilation configs
49
50
  archiveName: 'build.tar',
50
51
  dictionaryCompression: {
@@ -35,6 +35,7 @@ export type AppConfigs = {
35
35
  } | null;
36
36
  runFromNonRootUser: boolean;
37
37
  removeDevDependenciesDuringDockerBuild: boolean;
38
+ deleteNpm: boolean;
38
39
  archiveName: string;
39
40
  dictionaryCompression: {
40
41
  dictionaryPath: string[];
@@ -6,6 +6,7 @@ const app_configs_1 = require("../configs/app-configs");
6
6
  const apply_overrides_1 = require("../configs/util/apply-overrides");
7
7
  const installProductionCommand = (0, yarn_1.getInstallProductionCommand)();
8
8
  const yarnVersion = (0, yarn_1.getYarnVersion)();
9
+ const yarnBinSymlinkCommand = (0, yarn_1.getYarnBinSymlinkCommand)();
9
10
  const { nginx } = app_configs_1.configs;
10
11
  // В зависимости от используемого мендежера зависимостей для их установки нужно копировать разный набор файлов
11
12
  const filesRequiredToInstallDependencies = [
@@ -33,11 +34,16 @@ ${filesRequiredToInstallDependencies
33
34
  .map((file) => `ADD --chown=nginx:nginx ${file} /src/${file}`)
34
35
  .join('\n')}
35
36
 
36
- RUN ${installProductionCommand} && \\
37
+ RUN ${yarnBinSymlinkCommand}${installProductionCommand} && \\
37
38
  ${yarnVersion === 'unavailable' ? 'npm cache clean --force' : 'yarn cache clean --all'}
38
39
 
39
40
  ADD --chown=nginx:nginx . /src
40
41
 
42
+ # При необходимости удаляем npm и связанные библиотеки из образа
43
+ ${app_configs_1.configs.deleteNpm
44
+ ? 'RUN rm -rf /usr/local/bin/npm /usr/local/bin/npx /usr/local/lib/node_modules/npm'
45
+ : ''}
46
+
41
47
  # Создаем директории для nginx и выставляем правильные права
42
48
  RUN mkdir -p /var/lib/nginx && \
43
49
  chown -R nginx:nginx /var/lib/nginx && \
@@ -37,6 +37,9 @@ ${nginxNonRootPart}
37
37
  ${app_configs_1.configs.runFromNonRootUser
38
38
  ? `ADD --chown=nginx:nginx ${appPathToAdd} ${appTargetPath}`
39
39
  : `ADD ${appPathToAdd} ${appTargetPath}`}
40
+ ${app_configs_1.configs.deleteNpm
41
+ ? 'RUN rm -rf /usr/local/bin/npm /usr/local/bin/npx /usr/local/lib/node_modules/npm'
42
+ : ''}
40
43
  ${app_configs_1.configs.clientOnly ? 'COPY env-config.jso[n] /src/' : ''}
41
44
  ${app_configs_1.configs.clientOnly ? 'CMD ["nginx"]' : ''}
42
45
  `;
package/docs/settings.md CHANGED
@@ -198,6 +198,13 @@ const settings = {
198
198
  Отключает удаление devDependencies из node_modules при сборке докер образа. Используется когда вам не нужно удалять devDependencies,
199
199
  т.к. в своём Dockerfile вы не переносите node_modules в докер-контейнер. По умолчанию `true`.
200
200
 
201
+ #### deleteNpm
202
+ Удаляет npm и связанные с ним библиотеки (`/usr/local/bin/npm`, `/usr/local/bin/npx`,
203
+ `/usr/local/lib/node_modules/npm`) из итогового docker-образа, собираемого командами
204
+ [docker-build](./commands.md#docker-build) и [docker-build:compiled](./commands.md#docker-buildcompiled).
205
+ Полезно для уменьшения поверхности атаки и исключения неиспользуемых пакетов, которые могут
206
+ ложно срабатывать в security-сканерах. По умолчанию `false`.
207
+
201
208
  #### archiveName
202
209
  Имя архива, который будет создан при использовании команды [archive-build](./commands.md#archive-build). По умолчанию `'build.tar'`.
203
210
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arui-scripts",
3
- "version": "23.3.1",
3
+ "version": "23.5.0",
4
4
  "main": "./build/index.js",
5
5
  "typings": "./build/index.d.ts",
6
6
  "exports": {