@code-pushup/utils 0.108.0 → 0.108.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/utils",
3
- "version": "0.108.0",
3
+ "version": "0.108.2",
4
4
  "description": "Low-level utilities (helper functions, etc.) used by Code PushUp CLI",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/code-pushup/cli/tree/main/packages/utils#readme",
@@ -27,7 +27,7 @@
27
27
  "node": ">=18.2.0"
28
28
  },
29
29
  "dependencies": {
30
- "@code-pushup/models": "0.108.0",
30
+ "@code-pushup/models": "0.108.2",
31
31
  "ansis": "^3.3.0",
32
32
  "build-md": "^0.4.2",
33
33
  "bundle-require": "^5.1.0",
@@ -1,5 +1,6 @@
1
1
  import { writeFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
+ import { threadId } from 'node:worker_threads';
3
4
  import { ensureDirectoryExists, pluginWorkDir } from './file-system.js';
4
5
  /**
5
6
  * Function to create timestamp nested plugin runner files for config and output.
@@ -8,8 +9,10 @@ import { ensureDirectoryExists, pluginWorkDir } from './file-system.js';
8
9
  * @param configJSON - config of the plugin runner as JSON.
9
10
  */
10
11
  export async function createRunnerFiles(pluginSlug, configJSON) {
11
- const timestamp = Date.now().toString();
12
- const runnerWorkDir = path.join(pluginWorkDir(pluginSlug), timestamp);
12
+ // Use timestamp + process ID + threadId
13
+ // This prevents race conditions when running the same plugin for multiple projects in parallel
14
+ const uniqueId = `${(performance.timeOrigin + performance.now()) * 10}-${process.pid}-${threadId}`;
15
+ const runnerWorkDir = path.join(pluginWorkDir(pluginSlug), uniqueId);
13
16
  const runnerConfigPath = path.join(runnerWorkDir, 'plugin-config.json');
14
17
  const runnerOutputPath = path.join(runnerWorkDir, 'runner-output.json');
15
18
  await ensureDirectoryExists(path.dirname(runnerOutputPath));
@@ -1 +1 @@
1
- {"version":3,"file":"create-runner-files.js","sourceRoot":"","sources":["../../../src/lib/create-runner-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAkB,EAClB,UAAkB;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IACxC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;IACxE,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;IAExE,MAAM,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC5D,MAAM,SAAS,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;IAE9C,OAAO;QACL,gBAAgB;QAChB,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"create-runner-files.js","sourceRoot":"","sources":["../../../src/lib/create-runner-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAkB,EAClB,UAAkB;IAElB,wCAAwC;IACxC,+FAA+F;IAC/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