2023-11-30 14:21:35 +01:00
|
|
|
/**
|
|
|
|
|
* this script finds a given native modules version as found in package-lock.json and
|
|
|
|
|
* outputs the path where a cached build would be expected to stdout.
|
|
|
|
|
* We can then restore that path from cache.
|
|
|
|
|
*
|
|
|
|
|
* This is useful in CI to know the location of the build before
|
|
|
|
|
* we install the dependencies and rebuild from scratch.
|
|
|
|
|
* (see .github/workflows/test.yml)
|
|
|
|
|
* */
|
2023-04-19 13:58:49 +02:00
|
|
|
import fs from "node:fs/promises"
|
2024-12-23 17:31:00 +01:00
|
|
|
import { buildCachedLibPaths } from "./nativeLibraryProvider.js"
|
2025-06-16 16:26:56 +02:00
|
|
|
import { getValidArchitecture, removeNpmNamespacePrefix } from "./buildUtils.js"
|
2023-04-19 13:58:49 +02:00
|
|
|
|
|
|
|
|
const packageJson = JSON.parse(await fs.readFile("package-lock.json", "utf-8"))
|
2025-06-16 16:26:56 +02:00
|
|
|
const packageName = process.argv[2]
|
2023-04-19 13:58:49 +02:00
|
|
|
// we have a git commit as a version in dependencies, we want the actually resolved version number
|
2025-06-16 16:26:56 +02:00
|
|
|
const version = packageJson.packages[`node_modules/${packageName}`].version
|
|
|
|
|
const moduleName = removeNpmNamespacePrefix(packageName)
|
|
|
|
|
const platform = "linux"
|
2024-12-24 09:55:03 +01:00
|
|
|
const paths = await buildCachedLibPaths({
|
2025-06-03 12:43:32 +02:00
|
|
|
rootDir: ".",
|
2025-06-16 16:26:56 +02:00
|
|
|
platform: platform,
|
2024-12-24 09:55:03 +01:00
|
|
|
environment: "node",
|
|
|
|
|
versionedEnvironment: `node-${process.versions.modules}`,
|
2025-06-16 16:26:56 +02:00
|
|
|
nodeModule: moduleName,
|
2024-12-24 09:55:03 +01:00
|
|
|
libraryVersion: version,
|
2025-06-16 16:26:56 +02:00
|
|
|
architecture: getValidArchitecture(platform, process.arch),
|
2024-12-24 09:55:03 +01:00
|
|
|
})
|
|
|
|
|
console.log(paths[process.arch])
|