@platforma-sdk/package-builder-lib 1.1.0 → 1.2.1
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/dist/core/archive.cjs +3 -3
- package/dist/core/archive.cjs.map +1 -1
- package/dist/core/archive.js.map +1 -1
- package/dist/core/conda/builder.cjs +9 -4
- package/dist/core/conda/builder.cjs.map +1 -1
- package/dist/core/conda/builder.js +5 -1
- package/dist/core/conda/builder.js.map +1 -1
- package/dist/core/conda/validate-spec.cjs +2 -2
- package/dist/core/conda/validate-spec.cjs.map +1 -1
- package/dist/core/conda/validate-spec.js.map +1 -1
- package/dist/core/core.cjs +29 -8
- package/dist/core/core.cjs.map +1 -1
- package/dist/core/core.d.ts +6 -1
- package/dist/core/core.d.ts.map +1 -1
- package/dist/core/core.js +27 -6
- package/dist/core/core.js.map +1 -1
- package/dist/core/docker-conda.cjs +2 -2
- package/dist/core/docker-conda.cjs.map +1 -1
- package/dist/core/docker-conda.js.map +1 -1
- package/dist/core/docker-python.cjs +3 -2
- package/dist/core/docker-python.cjs.map +1 -1
- package/dist/core/docker-python.js +1 -1
- package/dist/core/docker-python.js.map +1 -1
- package/dist/core/docker.cjs +3 -3
- package/dist/core/docker.cjs.map +1 -1
- package/dist/core/docker.js.map +1 -1
- package/dist/core/envs.cjs +34 -0
- package/dist/core/envs.cjs.map +1 -1
- package/dist/core/envs.d.ts +8 -2
- package/dist/core/envs.d.ts.map +1 -1
- package/dist/core/envs.js +13 -1
- package/dist/core/envs.js.map +1 -1
- package/dist/core/package-info.cjs +59 -5
- package/dist/core/package-info.cjs.map +1 -1
- package/dist/core/package-info.d.ts +11 -2
- package/dist/core/package-info.d.ts.map +1 -1
- package/dist/core/package-info.js +60 -6
- package/dist/core/package-info.js.map +1 -1
- package/dist/core/paths.cjs +1 -1
- package/dist/core/paths.cjs.map +1 -1
- package/dist/core/paths.js +1 -1
- package/dist/core/paths.js.map +1 -1
- package/dist/core/resolver.cjs +7 -2
- package/dist/core/resolver.cjs.map +1 -1
- package/dist/core/resolver.js +1 -1
- package/dist/core/resolver.js.map +1 -1
- package/dist/core/schemas/artifacts.cjs +7 -1
- package/dist/core/schemas/artifacts.cjs.map +1 -1
- package/dist/core/schemas/artifacts.d.ts +1 -1
- package/dist/core/schemas/artifacts.d.ts.map +1 -1
- package/dist/core/schemas/artifacts.js +1 -1
- package/dist/core/schemas/artifacts.js.map +1 -1
- package/dist/core/schemas/entrypoints.cjs +4 -1
- package/dist/core/schemas/entrypoints.cjs.map +1 -1
- package/dist/core/schemas/entrypoints.d.ts +1 -1
- package/dist/core/schemas/entrypoints.d.ts.map +1 -1
- package/dist/core/schemas/entrypoints.js +1 -1
- package/dist/core/schemas/entrypoints.js.map +1 -1
- package/dist/core/schemas/sw-json.cjs +16 -1
- package/dist/core/schemas/sw-json.cjs.map +1 -1
- package/dist/core/schemas/sw-json.js +1 -1
- package/dist/core/schemas/sw-json.js.map +1 -1
- package/dist/core/storage.cjs +6 -2
- package/dist/core/storage.cjs.map +1 -1
- package/dist/core/storage.js +4 -1
- package/dist/core/storage.js.map +1 -1
- package/dist/core/sw-json-render.cjs +38 -7
- package/dist/core/sw-json-render.cjs.map +1 -1
- package/dist/core/sw-json-render.js +37 -8
- package/dist/core/sw-json-render.js.map +1 -1
- package/dist/core/util.cjs +33 -12
- package/dist/core/util.cjs.map +1 -1
- package/dist/core/util.d.ts +12 -7
- package/dist/core/util.d.ts.map +1 -1
- package/dist/core/util.js +17 -8
- package/dist/core/util.js.map +1 -1
- package/dist/defaults.cjs +18 -1
- package/dist/defaults.cjs.map +1 -1
- package/dist/defaults.d.ts +9 -3
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +13 -2
- package/dist/defaults.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/core/core.test.ts +17 -0
- package/src/core/core.ts +48 -8
- package/src/core/envs.ts +8 -0
- package/src/core/package-info.test.ts +162 -3
- package/src/core/package-info.ts +88 -3
- package/src/core/schemas/test-artifacts.ts +1 -1
- package/src/core/sw-json-render.test.ts +23 -0
- package/src/core/sw-json-render.ts +30 -2
- package/src/core/util.test.ts +52 -0
- package/src/core/util.ts +27 -7
- package/src/defaults.ts +19 -1
- package/src/index.ts +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw-json-render.cjs","names":["descriptorFilePath","path","resolveRunEnvironment","fs"],"sources":["../../src/core/sw-json-render.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type winston from \"winston\";\nimport type { PackageInfo } from \"./package-info\";\nimport * as artifacts from \"./schemas/artifacts\";\nimport type * as swJson from \"./schemas/sw-json\";\nimport type * as entrypoint from \"./schemas/entrypoints\";\nimport * as util from \"./util\";\nimport * as docker from \"./docker\";\nimport * as defaults from \"../defaults\";\nimport { descriptorFilePath } from \"./resolver\";\nimport { resolveRunEnvironment } from \"./resolver\";\n\nexport class SwJsonRenderer {\n constructor(\n private logger: winston.Logger,\n private readonly pkgInfo: PackageInfo,\n ) {}\n\n public renderSoftwareEntrypoints(\n mode: util.BuildMode,\n entrypoints: Map<string, entrypoint.Entrypoint>,\n options?: {\n requireAllArtifacts?: boolean;\n fullDirHash?: boolean;\n },\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n let hasReferences = false;\n\n const fullDirHash = options?.fullDirHash ?? false;\n\n this.logger.info(`Rendering entrypoint descriptors...`);\n this.logger.debug(\" entrypoints: \" + JSON.stringify(entrypoints));\n\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") {\n // Entrypoint references do not need any rendering\n hasReferences = true;\n continue;\n }\n\n this.logger.debug(`Rendering entrypoint descriptor '${epName}'...`);\n\n //\n // In docker case we should merge docker info and other info\n //\n const originEpName = docker.entrypointNameToOrigin(epName);\n const info = result.has(originEpName)\n ? result.get(originEpName)\n : {\n id: {\n package: this.pkgInfo.packageName,\n name: originEpName,\n },\n };\n if (!info) {\n throw util.CLIError(`Entrypoint ${epName} not found in result`);\n }\n\n if (mode !== \"release\") {\n info.isDev = true;\n }\n\n const pkg = ep.artifact;\n if (util.isDevLocalMode(mode)) {\n switch (pkg.type) {\n case \"docker\": {\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n }\n default:\n this.logger.debug(\" rendering 'local' source...\");\n info.local = this.renderLocalPackage(epName, ep, fullDirHash);\n }\n\n result.set(originEpName, info);\n continue;\n }\n\n const type = pkg.type;\n switch (type) {\n case \"R\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"environment\":\n info.runEnv = this.renderRunEnvInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"asset\":\n info.asset = this.renderAssetInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"binary\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"docker\":\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n case \"java\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"python\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"conda\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n default:\n util.assertNever(type);\n throw new Error(\n `renderer logic error: renderSoftwareEntrypoints does not cover all package types`,\n );\n }\n\n result.set(originEpName, info);\n }\n\n if (result.size === 0 && !hasReferences) {\n this.logger.error(\"no entrypoint descriptors were rendered\");\n throw util.CLIError(\"no entrypoint descriptors were rendered\");\n }\n\n return result;\n }\n\n public writeSwJson(info: swJson.swJsonType, dstFile?: string) {\n const epType = info.asset ? \"asset\" : \"software\";\n const dstSwInfoPath =\n dstFile ?? descriptorFilePath(this.pkgInfo.packageRoot, epType, info.id.name);\n\n this.logger.info(`Writing entrypoint descriptor to '${dstSwInfoPath}'`);\n\n const { id, ...toEncode } = info; // cut entrypoint ID from the final .sw.json\n const encoded = JSON.stringify({\n name: util.artifactIDToString(id),\n ...toEncode,\n });\n\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.writeFileSync(dstSwInfoPath, encoded + \"\\n\");\n }\n\n public copySwJson(epName: string, srcFile: string) {\n let epType: Extract<entrypoint.EntrypointType, \"software\" | \"asset\">;\n if (srcFile.endsWith(compiledSoftwareSuffix)) {\n epType = \"software\";\n } else if (srcFile.endsWith(compiledAssetSuffix)) {\n epType = \"asset\";\n } else {\n throw util.CLIError(\n `unknown entrypoint '${epName}' type: cannot get type from extension of source file ${srcFile}`,\n );\n }\n\n const dstSwInfoPath = descriptorFilePath(this.pkgInfo.packageRoot, epType, epName);\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.copyFileSync(srcFile, dstSwInfoPath);\n }\n\n private renderLocalPackage(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n fullDirHash: boolean,\n ): swJson.localSoftwareType {\n const artifact = ep.artifact;\n const rootDir = this.pkgInfo.artifactContentRoot(artifact, util.currentPlatform());\n const hash = fullDirHash ? util.hashDirSync(rootDir) : util.hashDirMetaSync(rootDir);\n const localPath = rootDir;\n\n const epType = ep.type;\n switch (epType) {\n case \"environment\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'environment' artifact, which does not support local build yet`,\n );\n\n case \"asset\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'asset' artifact, which does not support local build yet`,\n );\n\n case \"software\": {\n const pkgType = artifact.type;\n switch (pkgType) {\n case \"environment\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"asset\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"binary\": {\n // Regular binary with no run environment dependency\n return {\n type: \"binary\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = artifact.dependencies ?? {};\n\n return {\n type: \"python\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n toolset: toolset ?? defaults.PYTHON_TOOLSET,\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n toolset: \"renv\",\n dependencies: {},\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"docker\": {\n throw new Error(\n `internal build script logic error: attempt to build docker entrypoint as local binary package`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: artifact[\"micromamba-version\"],\n [\"conda-root-dir\"]: artifact[\"conda-root-dir\"],\n spec: artifact.spec,\n };\n }\n default:\n util.assertNever(pkgType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all artifact types\",\n );\n }\n }\n\n default:\n util.assertNever(epType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all environment types\",\n );\n }\n }\n\n private renderBinaryInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.remoteSoftwareType | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw new Error(`'*.sw.json' generator logic error`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n\n const binPkg = ep.artifact;\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n binPkg.id,\n \"archive\",\n artifacts.isCrossPlatform(binPkg.type) ? undefined : util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryName) {\n throw util.CLIError(\n `could not render binary entrypoint '${epName}': registry name is not set in artifact info file ${artInfoPath}`,\n );\n }\n\n const pkgType = binPkg.type;\n switch (pkgType) {\n case \"docker\": {\n throw new Error(\n `internal build script logic error: entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: binPkg[\"micromamba-version\"],\n [\"conda-root-dir\"]: binPkg[\"conda-root-dir\"],\n\n spec: defaults.CONDA_FROZEN_ENV_SPEC_FILE,\n };\n }\n case \"binary\": {\n return {\n type: \"binary\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = binPkg.dependencies ?? {};\n\n return {\n type: \"python\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: toolset ?? \"pip\",\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: \"renv\",\n dependencies: {},\n };\n }\n default: {\n util.assertNever(pkgType);\n throw new Error(\n \"internal build script logic error: renderBinaryInfo does not cover all package types\",\n );\n }\n }\n }\n\n private renderRunEnvInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.runEnvInfo | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`run environments do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"environment\", `internal build script logic error`);\n const envArtifact = requireArtifactType(\n ep.artifact,\n \"environment\",\n `could not render 'environment' entrypoint`,\n );\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n envArtifact.id,\n \"archive\",\n util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n type: envArtifact.runtime,\n\n [\"r-version\"]: envArtifact[\"r-version\"],\n [\"python-version\"]: envArtifact[\"python-version\"],\n [\"java-version\"]: envArtifact[\"java-version\"],\n\n envVars: envArtifact.envVars ?? [],\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n binDir: envArtifact.binDir,\n };\n }\n\n private renderAssetInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.assetInfo | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`assets do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"asset\", `internal build script logic error`);\n const assetPkg = requireArtifactType(\n ep.artifact,\n \"asset\",\n `could not render 'asset' entrypoint`,\n );\n\n if (assetPkg.type !== \"asset\") {\n throw util.CLIError(`could not render asset entrypoint '${epName}': not 'asset' artifact`);\n }\n\n const artInfoPath = this.pkgInfo.artifactInfoLocation(assetPkg.id, \"archive\", undefined);\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryURL) {\n throw util.CLIError(\n `could not render asset entrypoint '${epName}': base download URL is not configured for asset's registry`,\n );\n }\n\n return {\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n url: util.urlJoin(artInfo.registryURL, artInfo.remoteArtifactLocation),\n };\n }\n\n private renderDockerInfo(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.dockerInfo | undefined {\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n const dockerArtifact = requireArtifactType(\n ep.artifact,\n \"docker\",\n `could not render 'docker' entrypoint`,\n );\n\n // Matches the \"x64\" write in core.buildDockerImage — docker artifacts are\n // always cross-compiled to linux/amd64 so we look up the x64 descriptor\n // regardless of host.\n const artInfoPath = this.pkgInfo.artifactInfoLocation(dockerArtifact.id, \"docker\", \"x64\");\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n tag: artInfo.remoteArtifactLocation,\n entrypoint: artInfo.entrypoint ?? [],\n cmd: ep.cmd,\n pkg: dockerArtifact.pkg || \"/\",\n };\n }\n}\n\nexport const compiledSoftwareSuffix = \".sw.json\";\nexport const compiledAssetSuffix = \".as.json\";\n\nexport type builtArtifactInfo = {\n type: artifacts.artifactType;\n platform: util.PlatformType;\n registryURL?: string; // registry public URL (for assets)\n registryName?: string; // name of registry (for binary and asset archives)\n remoteArtifactLocation: string; // path to put into sw.json or as.json file\n uploadPath?: string; // custom upload path if it does not match pathForSwJson\n\n // docker-specific fields\n entrypoint?: string[]; // entrypoint of resulting docker image. Can be overriden by setting in package.json\n\n // conda-specific fields\n spec?: string; // path to spec.yaml file within conda package\n [\"micromamba-version\"]?: string; // version of micromamba used in this conda package\n};\n\nexport function writeBuiltArtifactInfo(location: string, locInfo: builtArtifactInfo) {\n fs.mkdirSync(path.dirname(location), { recursive: true });\n fs.writeFileSync(location, JSON.stringify(locInfo), { encoding: \"utf8\" });\n}\n\nexport function readBuiltArtifactInfo(location: string): builtArtifactInfo {\n const data = fs.readFileSync(location, \"utf8\");\n return JSON.parse(data) as builtArtifactInfo;\n}\n\nfunction readArtifactInfoIfExists(\n location: string,\n epName: string,\n requireExisting?: boolean,\n): builtArtifactInfo | undefined {\n if (fs.existsSync(location)) {\n return readBuiltArtifactInfo(location);\n }\n\n if (requireExisting) {\n throw util.CLIError(\n `could not render docker entrypoint '${epName}': artifact info file '${location}' does not exist`,\n );\n }\n\n return undefined;\n}\n\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"asset\",\n errMsg: string,\n): entrypoint.AssetEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"software\",\n errMsg: string,\n): entrypoint.SoftwareEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"environment\",\n errMsg: string,\n): entrypoint.EnvironmentEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: entrypoint.EntrypointType,\n errMsg: string,\n): entrypoint.PackageEntrypoint {\n if (ep.type === type) {\n return ep;\n }\n\n throw new Error(`${errMsg}: entrypoint ${ep.name} (${ep.type}) is not '${type}'`);\n}\n\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"asset\",\n errMsg: string,\n): artifacts.withId<artifacts.assetType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"environment\",\n errMsg: string,\n): artifacts.withId<artifacts.environmentType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"java\",\n errMsg: string,\n): artifacts.withId<artifacts.javaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"python\",\n errMsg: string,\n): artifacts.withId<artifacts.pythonType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"R\",\n errMsg: string,\n): artifacts.withId<artifacts.rType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"binary\",\n errMsg: string,\n): artifacts.withId<artifacts.binaryType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"docker\",\n errMsg: string,\n): artifacts.withId<artifacts.dockerType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"conda\",\n errMsg: string,\n): artifacts.withId<artifacts.condaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: artifacts.artifactType,\n errMsg: string,\n): artifacts.withId<artifacts.anyArtifactType> {\n if (pkg.type === type) {\n return pkg;\n }\n\n if (errMsg) {\n errMsg = `${errMsg}: `;\n }\n\n throw util.CLIError(`${errMsg}artifact '${pkg.id}' ('${pkg.type}') is not '${type}'`);\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAa,iBAAb,MAA4B;CAC1B,YACE,QACA,SACA;AAFQ,OAAA,SAAA;AACS,OAAA,UAAA;;CAGnB,0BACE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AAM,UAAU,yBADI,KAAK,QAAQ,qBAAqB,eAAe,IAAI,UAAU,MAAM,EACnC,QAAQ,oBAAoB;AAClF,MAAI,CAAC,QACH;AAGF,SAAO;GACL,KAAK,QAAQ;GACb,YAAY,QAAQ,cAAc,EAAE;GACpC,KAAK,GAAG;GACR,KAAK,eAAe,OAAO;GAC5B;;;AAuBL,SAAgB,uBAAuB,UAAkB,SAA4B;AACnF,SAAA,QAAG,UAAUD,UAAAA,QAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACzD,SAAA,QAAG,cAAc,UAAU,KAAK,UAAU,QAAQ,EAAE,EAAE,UAAU,QAAQ,CAAC;;AAG3E,SAAgB,sBAAsB,UAAqC;CACzE,MAAM,OAAOE,QAAAA,QAAG,aAAa,UAAU,OAAO;AAC9C,QAAO,KAAK,MAAM,KAAK;;AAGzB,SAAS,yBACP,UACA,QACA,iBAC+B;AAC/B,KAAIA,QAAAA,QAAG,WAAW,SAAS,CACzB,QAAO,sBAAsB,SAAS;AAGxC,KAAI,gBACF,OAAA,aAAA,SACE,uCAAuC,OAAO,yBAAyB,SAAS,kBACjF;;AAqBL,SAAS,sBACP,IACA,MACA,QAC8B;AAC9B,KAAI,GAAG,SAAS,KACd,QAAO;AAGT,OAAM,IAAI,MAAM,GAAG,OAAO,eAAe,GAAG,KAAK,IAAI,GAAG,KAAK,YAAY,KAAK,GAAG;;AA2CnF,SAAS,oBACP,KACA,MACA,QAC6C;AAC7C,KAAI,IAAI,SAAS,KACf,QAAO;AAGT,KAAI,OACF,UAAS,GAAG,OAAO;AAGrB,OAAA,aAAA,SAAoB,GAAG,OAAO,YAAY,IAAI,GAAG,MAAM,IAAI,KAAK,aAAa,KAAK,GAAG"}
|
|
1
|
+
{"version":3,"file":"sw-json-render.cjs","names":["descriptorFilePath","path","resolveRunEnvironment","fs"],"sources":["../../src/core/sw-json-render.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type winston from \"winston\";\nimport type { PackageInfo } from \"./package-info\";\nimport * as artifacts from \"./schemas/artifacts\";\nimport type * as swJson from \"./schemas/sw-json\";\nimport type * as entrypoint from \"./schemas/entrypoints\";\nimport * as util from \"./util\";\nimport * as docker from \"./docker\";\nimport * as defaults from \"../defaults\";\nimport { descriptorFilePath } from \"./resolver\";\nimport { resolveRunEnvironment } from \"./resolver\";\n\nexport class SwJsonRenderer {\n constructor(\n private logger: winston.Logger,\n private readonly pkgInfo: PackageInfo,\n ) {}\n\n public renderSoftwareEntrypoints(\n mode: util.BuildMode,\n entrypoints: Map<string, entrypoint.Entrypoint>,\n options?: {\n requireAllArtifacts?: boolean;\n fullDirHash?: boolean;\n },\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n let hasReferences = false;\n\n const fullDirHash = options?.fullDirHash ?? false;\n\n this.logger.info(`Rendering entrypoint descriptors...`);\n this.logger.debug(\" entrypoints: \" + JSON.stringify(entrypoints));\n\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") {\n // Entrypoint references do not need any rendering\n hasReferences = true;\n continue;\n }\n\n this.logger.debug(`Rendering entrypoint descriptor '${epName}'...`);\n\n //\n // In docker case we should merge docker info and other info\n //\n const originEpName = docker.entrypointNameToOrigin(epName);\n const info = result.has(originEpName)\n ? result.get(originEpName)\n : {\n id: {\n package: this.pkgInfo.packageName,\n name: originEpName,\n },\n };\n if (!info) {\n throw util.CLIError(`Entrypoint ${epName} not found in result`);\n }\n\n if (util.isDevMode(mode)) {\n info.isDev = true;\n }\n\n const pkg = ep.artifact;\n if (!util.producesRegistryDescriptor(mode)) {\n switch (pkg.type) {\n case \"docker\": {\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n }\n default:\n this.logger.debug(\" rendering 'local' source...\");\n info.local = this.renderLocalPackage(epName, ep, fullDirHash);\n }\n\n result.set(originEpName, info);\n continue;\n }\n\n const type = pkg.type;\n switch (type) {\n case \"R\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"environment\":\n info.runEnv = this.renderRunEnvInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"asset\":\n info.asset = this.renderAssetInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"binary\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"docker\":\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n case \"java\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"python\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"conda\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n default:\n util.assertNever(type);\n throw new Error(\n `renderer logic error: renderSoftwareEntrypoints does not cover all package types`,\n );\n }\n\n result.set(originEpName, info);\n }\n\n if (result.size === 0 && !hasReferences) {\n this.logger.error(\"no entrypoint descriptors were rendered\");\n throw util.CLIError(\"no entrypoint descriptors were rendered\");\n }\n\n return result;\n }\n\n // One minimal `binary` placeholder per entrypoint, so a block builds, loads, and renders without\n // any software; only executing it fails, against the sentinel registry. References are copied\n // through by the caller, so they are skipped here.\n public renderPlaceholderEntrypoints(\n entrypoints: Map<string, entrypoint.Entrypoint>,\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") continue;\n const originEpName = docker.entrypointNameToOrigin(epName);\n if (result.has(originEpName)) continue;\n result.set(originEpName, {\n id: { package: this.pkgInfo.packageName, name: originEpName },\n isDev: true,\n binary: {\n type: \"binary\",\n registry: defaults.NO_SOFTWARE_PLACEHOLDER,\n package: defaults.NO_SOFTWARE_PLACEHOLDER,\n cmd: [\"true\"],\n },\n });\n }\n return result;\n }\n\n public writeSwJson(info: swJson.swJsonType, dstFile?: string) {\n const epType = info.asset ? \"asset\" : \"software\";\n const dstSwInfoPath =\n dstFile ?? descriptorFilePath(this.pkgInfo.packageRoot, epType, info.id.name);\n\n this.logger.info(`Writing entrypoint descriptor to '${dstSwInfoPath}'`);\n\n const { id, ...toEncode } = info; // cut entrypoint ID from the final .sw.json\n const encoded = JSON.stringify({\n name: util.artifactIDToString(id),\n ...toEncode,\n });\n\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.writeFileSync(dstSwInfoPath, encoded + \"\\n\");\n }\n\n public copySwJson(epName: string, srcFile: string) {\n let epType: Extract<entrypoint.EntrypointType, \"software\" | \"asset\">;\n if (srcFile.endsWith(compiledSoftwareSuffix)) {\n epType = \"software\";\n } else if (srcFile.endsWith(compiledAssetSuffix)) {\n epType = \"asset\";\n } else {\n throw util.CLIError(\n `unknown entrypoint '${epName}' type: cannot get type from extension of source file ${srcFile}`,\n );\n }\n\n const dstSwInfoPath = descriptorFilePath(this.pkgInfo.packageRoot, epType, epName);\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.copyFileSync(srcFile, dstSwInfoPath);\n }\n\n private renderLocalPackage(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n fullDirHash: boolean,\n ): swJson.localSoftwareType {\n const artifact = ep.artifact;\n const rootDir = this.pkgInfo.artifactContentRoot(artifact, util.currentPlatform());\n const hash = fullDirHash ? util.hashDirSync(rootDir) : util.hashDirMetaSync(rootDir);\n const localPath = rootDir;\n\n const epType = ep.type;\n switch (epType) {\n case \"environment\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'environment' artifact, which does not support local build yet`,\n );\n\n case \"asset\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'asset' artifact, which does not support local build yet`,\n );\n\n case \"software\": {\n const pkgType = artifact.type;\n switch (pkgType) {\n case \"environment\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"asset\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"binary\": {\n // Regular binary with no run environment dependency\n return {\n type: \"binary\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = artifact.dependencies ?? {};\n\n return {\n type: \"python\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n toolset: toolset ?? defaults.PYTHON_TOOLSET,\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n toolset: \"renv\",\n dependencies: {},\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"docker\": {\n throw new Error(\n `internal build script logic error: attempt to build docker entrypoint as local binary package`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: artifact[\"micromamba-version\"],\n [\"conda-root-dir\"]: artifact[\"conda-root-dir\"],\n spec: artifact.spec,\n };\n }\n default:\n util.assertNever(pkgType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all artifact types\",\n );\n }\n }\n\n default:\n util.assertNever(epType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all environment types\",\n );\n }\n }\n\n private renderBinaryInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.remoteSoftwareType | undefined {\n switch (mode) {\n case \"release\":\n case \"dev-remote\":\n break;\n\n case \"dev-local\":\n throw new Error(`'*.sw.json' generator logic error`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n\n const binPkg = ep.artifact;\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n binPkg.id,\n \"archive\",\n artifacts.isCrossPlatform(binPkg.type) ? undefined : util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryName) {\n throw util.CLIError(\n `could not render binary entrypoint '${epName}': registry name is not set in artifact info file ${artInfoPath}`,\n );\n }\n\n const pkgType = binPkg.type;\n switch (pkgType) {\n case \"docker\": {\n throw new Error(\n `internal build script logic error: entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: binPkg[\"micromamba-version\"],\n [\"conda-root-dir\"]: binPkg[\"conda-root-dir\"],\n\n spec: defaults.CONDA_FROZEN_ENV_SPEC_FILE,\n };\n }\n case \"binary\": {\n return {\n type: \"binary\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = binPkg.dependencies ?? {};\n\n return {\n type: \"python\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: toolset ?? \"pip\",\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: \"renv\",\n dependencies: {},\n };\n }\n default: {\n util.assertNever(pkgType);\n throw new Error(\n \"internal build script logic error: renderBinaryInfo does not cover all package types\",\n );\n }\n }\n }\n\n private renderRunEnvInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.runEnvInfo | undefined {\n switch (mode) {\n case \"release\":\n case \"dev-remote\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`run environments do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"environment\", `internal build script logic error`);\n const envArtifact = requireArtifactType(\n ep.artifact,\n \"environment\",\n `could not render 'environment' entrypoint`,\n );\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n envArtifact.id,\n \"archive\",\n util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n type: envArtifact.runtime,\n\n [\"r-version\"]: envArtifact[\"r-version\"],\n [\"python-version\"]: envArtifact[\"python-version\"],\n [\"java-version\"]: envArtifact[\"java-version\"],\n\n envVars: envArtifact.envVars ?? [],\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n binDir: envArtifact.binDir,\n };\n }\n\n private renderAssetInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.assetInfo | undefined {\n switch (mode) {\n case \"release\":\n case \"dev-remote\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`assets do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"asset\", `internal build script logic error`);\n const assetPkg = requireArtifactType(\n ep.artifact,\n \"asset\",\n `could not render 'asset' entrypoint`,\n );\n\n if (assetPkg.type !== \"asset\") {\n throw util.CLIError(`could not render asset entrypoint '${epName}': not 'asset' artifact`);\n }\n\n const artInfoPath = this.pkgInfo.artifactInfoLocation(assetPkg.id, \"archive\", undefined);\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryURL) {\n throw util.CLIError(\n `could not render asset entrypoint '${epName}': base download URL is not configured for asset's registry`,\n );\n }\n\n return {\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n url: util.urlJoin(artInfo.registryURL, artInfo.remoteArtifactLocation),\n };\n }\n\n private renderDockerInfo(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.dockerInfo | undefined {\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n const dockerArtifact = requireArtifactType(\n ep.artifact,\n \"docker\",\n `could not render 'docker' entrypoint`,\n );\n\n // Matches the \"x64\" write in core.buildDockerImage — docker artifacts are\n // always cross-compiled to linux/amd64 so we look up the x64 descriptor\n // regardless of host.\n const artInfoPath = this.pkgInfo.artifactInfoLocation(dockerArtifact.id, \"docker\", \"x64\");\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n tag: artInfo.remoteArtifactLocation,\n entrypoint: artInfo.entrypoint ?? [],\n cmd: ep.cmd,\n pkg: dockerArtifact.pkg || \"/\",\n };\n }\n}\n\nexport const compiledSoftwareSuffix = \".sw.json\";\nexport const compiledAssetSuffix = \".as.json\";\n\nexport type builtArtifactInfo = {\n type: artifacts.artifactType;\n platform: util.PlatformType;\n registryURL?: string; // registry public URL (for assets)\n registryName?: string; // name of registry (for binary and asset archives)\n remoteArtifactLocation: string; // path to put into sw.json or as.json file\n uploadPath?: string; // custom upload path if it does not match pathForSwJson\n\n // docker-specific fields\n entrypoint?: string[]; // entrypoint of resulting docker image. Can be overriden by setting in package.json\n\n // conda-specific fields\n spec?: string; // path to spec.yaml file within conda package\n [\"micromamba-version\"]?: string; // version of micromamba used in this conda package\n};\n\nexport function writeBuiltArtifactInfo(location: string, locInfo: builtArtifactInfo) {\n fs.mkdirSync(path.dirname(location), { recursive: true });\n fs.writeFileSync(location, JSON.stringify(locInfo), { encoding: \"utf8\" });\n}\n\nexport function readBuiltArtifactInfo(location: string): builtArtifactInfo {\n const data = fs.readFileSync(location, \"utf8\");\n return JSON.parse(data) as builtArtifactInfo;\n}\n\nfunction readArtifactInfoIfExists(\n location: string,\n epName: string,\n requireExisting?: boolean,\n): builtArtifactInfo | undefined {\n if (fs.existsSync(location)) {\n return readBuiltArtifactInfo(location);\n }\n\n if (requireExisting) {\n throw util.CLIError(\n `could not render docker entrypoint '${epName}': artifact info file '${location}' does not exist`,\n );\n }\n\n return undefined;\n}\n\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"asset\",\n errMsg: string,\n): entrypoint.AssetEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"software\",\n errMsg: string,\n): entrypoint.SoftwareEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"environment\",\n errMsg: string,\n): entrypoint.EnvironmentEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: entrypoint.EntrypointType,\n errMsg: string,\n): entrypoint.PackageEntrypoint {\n if (ep.type === type) {\n return ep;\n }\n\n throw new Error(`${errMsg}: entrypoint ${ep.name} (${ep.type}) is not '${type}'`);\n}\n\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"asset\",\n errMsg: string,\n): artifacts.withId<artifacts.assetType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"environment\",\n errMsg: string,\n): artifacts.withId<artifacts.environmentType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"java\",\n errMsg: string,\n): artifacts.withId<artifacts.javaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"python\",\n errMsg: string,\n): artifacts.withId<artifacts.pythonType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"R\",\n errMsg: string,\n): artifacts.withId<artifacts.rType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"binary\",\n errMsg: string,\n): artifacts.withId<artifacts.binaryType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"docker\",\n errMsg: string,\n): artifacts.withId<artifacts.dockerType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"conda\",\n errMsg: string,\n): artifacts.withId<artifacts.condaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: artifacts.artifactType,\n errMsg: string,\n): artifacts.withId<artifacts.anyArtifactType> {\n if (pkg.type === type) {\n return pkg;\n }\n\n if (errMsg) {\n errMsg = `${errMsg}: `;\n }\n\n throw util.CLIError(`${errMsg}artifact '${pkg.id}' ('${pkg.type}') is not '${type}'`);\n}\n"],"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AAOE,QAAAA,QAAG,aAAa,UAAU,MAAM;CAC7C,OAAO,KAAK,MAAM,IAAI;AACxB;AAEA,SAAS,yBACP,UACA,QACA,iBAC+B;CAC/B,IAAIA,QAAAA,QAAG,WAAW,QAAQ,GACxB,OAAO,sBAAsB,QAAQ;CAGvC,IAAI,iBACF,MAAA,aAAA,SACE,uCAAuC,OAAO,yBAAyB,SAAS,iBAClF;AAIJ;AAiBA,SAAS,sBACP,IACA,MACA,QAC8B;CAC9B,IAAI,GAAG,SAAS,MACd,OAAO;CAGT,MAAM,IAAI,MAAM,GAAG,OAAO,eAAe,GAAG,KAAK,IAAI,GAAG,KAAK,YAAY,KAAK,EAAE;AAClF;AA0CA,SAAS,oBACP,KACA,MACA,QAC6C;CAC7C,IAAI,IAAI,SAAS,MACf,OAAO;CAGT,IAAI,QACF,SAAS,GAAG,OAAO;CAGrB,MAAA,aAAA,SAAoB,GAAG,OAAO,YAAY,IAAI,GAAG,MAAM,IAAI,KAAK,aAAa,KAAK,EAAE;AACtF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CONDA_FROZEN_ENV_SPEC_FILE } from "../defaults.js";
|
|
2
|
-
import { CLIError, artifactIDToString, assertNever, currentPlatform, ensureDirsExist, hashDirMetaSync, hashDirSync,
|
|
1
|
+
import { CONDA_FROZEN_ENV_SPEC_FILE, NO_SOFTWARE_PLACEHOLDER } from "../defaults.js";
|
|
2
|
+
import { CLIError, artifactIDToString, assertNever, currentPlatform, ensureDirsExist, hashDirMetaSync, hashDirSync, isDevMode, producesRegistryDescriptor, urlJoin } from "./util.js";
|
|
3
3
|
import { isCrossPlatform } from "./schemas/artifacts.js";
|
|
4
4
|
import { entrypointNameToOrigin } from "./docker.js";
|
|
5
5
|
import { descriptorFilePath, resolveRunEnvironment } from "./resolver.js";
|
|
@@ -7,6 +7,8 @@ import fs from "node:fs";
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
//#region src/core/sw-json-render.ts
|
|
9
9
|
var SwJsonRenderer = class {
|
|
10
|
+
logger;
|
|
11
|
+
pkgInfo;
|
|
10
12
|
constructor(logger, pkgInfo) {
|
|
11
13
|
this.logger = logger;
|
|
12
14
|
this.pkgInfo = pkgInfo;
|
|
@@ -29,9 +31,9 @@ var SwJsonRenderer = class {
|
|
|
29
31
|
name: originEpName
|
|
30
32
|
} };
|
|
31
33
|
if (!info) throw CLIError(`Entrypoint ${epName} not found in result`);
|
|
32
|
-
if (mode
|
|
34
|
+
if (isDevMode(mode)) info.isDev = true;
|
|
33
35
|
const pkg = ep.artifact;
|
|
34
|
-
if (
|
|
36
|
+
if (!producesRegistryDescriptor(mode)) {
|
|
35
37
|
switch (pkg.type) {
|
|
36
38
|
case "docker":
|
|
37
39
|
info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);
|
|
@@ -81,6 +83,28 @@ var SwJsonRenderer = class {
|
|
|
81
83
|
}
|
|
82
84
|
return result;
|
|
83
85
|
}
|
|
86
|
+
renderPlaceholderEntrypoints(entrypoints) {
|
|
87
|
+
const result = /* @__PURE__ */ new Map();
|
|
88
|
+
for (const [epName, ep] of entrypoints.entries()) {
|
|
89
|
+
if (ep.type === "reference") continue;
|
|
90
|
+
const originEpName = entrypointNameToOrigin(epName);
|
|
91
|
+
if (result.has(originEpName)) continue;
|
|
92
|
+
result.set(originEpName, {
|
|
93
|
+
id: {
|
|
94
|
+
package: this.pkgInfo.packageName,
|
|
95
|
+
name: originEpName
|
|
96
|
+
},
|
|
97
|
+
isDev: true,
|
|
98
|
+
binary: {
|
|
99
|
+
type: "binary",
|
|
100
|
+
registry: NO_SOFTWARE_PLACEHOLDER,
|
|
101
|
+
package: NO_SOFTWARE_PLACEHOLDER,
|
|
102
|
+
cmd: ["true"]
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
84
108
|
writeSwJson(info, dstFile) {
|
|
85
109
|
const epType = info.asset ? "asset" : "software";
|
|
86
110
|
const dstSwInfoPath = dstFile ?? descriptorFilePath(this.pkgInfo.packageRoot, epType, info.id.name);
|
|
@@ -177,7 +201,8 @@ var SwJsonRenderer = class {
|
|
|
177
201
|
}
|
|
178
202
|
renderBinaryInfo(mode, epName, ep, requireArtifactInfo) {
|
|
179
203
|
switch (mode) {
|
|
180
|
-
case "release":
|
|
204
|
+
case "release":
|
|
205
|
+
case "dev-remote": break;
|
|
181
206
|
case "dev-local": throw new Error(`'*.sw.json' generator logic error`);
|
|
182
207
|
default: assertNever(mode);
|
|
183
208
|
}
|
|
@@ -245,7 +270,8 @@ var SwJsonRenderer = class {
|
|
|
245
270
|
}
|
|
246
271
|
renderRunEnvInfo(mode, epName, ep, requireArtifactInfo) {
|
|
247
272
|
switch (mode) {
|
|
248
|
-
case "release":
|
|
273
|
+
case "release":
|
|
274
|
+
case "dev-remote": break;
|
|
249
275
|
case "dev-local": throw CLIError(`run environments do not support 'local' dev build mode yet`);
|
|
250
276
|
default: assertNever(mode);
|
|
251
277
|
}
|
|
@@ -266,7 +292,8 @@ var SwJsonRenderer = class {
|
|
|
266
292
|
}
|
|
267
293
|
renderAssetInfo(mode, epName, ep, requireArtifactInfo) {
|
|
268
294
|
switch (mode) {
|
|
269
|
-
case "release":
|
|
295
|
+
case "release":
|
|
296
|
+
case "dev-remote": break;
|
|
270
297
|
case "dev-local": throw CLIError(`assets do not support 'local' dev build mode yet`);
|
|
271
298
|
default: assertNever(mode);
|
|
272
299
|
}
|
|
@@ -295,6 +322,8 @@ var SwJsonRenderer = class {
|
|
|
295
322
|
};
|
|
296
323
|
}
|
|
297
324
|
};
|
|
325
|
+
const compiledSoftwareSuffix = ".sw.json";
|
|
326
|
+
const compiledAssetSuffix = ".as.json";
|
|
298
327
|
function writeBuiltArtifactInfo(location, locInfo) {
|
|
299
328
|
fs.mkdirSync(path.dirname(location), { recursive: true });
|
|
300
329
|
fs.writeFileSync(location, JSON.stringify(locInfo), { encoding: "utf8" });
|
|
@@ -317,6 +346,6 @@ function requireArtifactType(pkg, type, errMsg) {
|
|
|
317
346
|
throw CLIError(`${errMsg}artifact '${pkg.id}' ('${pkg.type}') is not '${type}'`);
|
|
318
347
|
}
|
|
319
348
|
//#endregion
|
|
320
|
-
export { SwJsonRenderer, readBuiltArtifactInfo, writeBuiltArtifactInfo };
|
|
349
|
+
export { SwJsonRenderer, compiledAssetSuffix, compiledSoftwareSuffix, readBuiltArtifactInfo, writeBuiltArtifactInfo };
|
|
321
350
|
|
|
322
351
|
//# sourceMappingURL=sw-json-render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw-json-render.js","names":["docker.entrypointNameToOrigin","util.CLIError","util.isDevLocalMode","util.artifactIDToString","util.currentPlatform","util.hashDirSync","util.hashDirMetaSync","artifacts.isCrossPlatform","defaults.CONDA_FROZEN_ENV_SPEC_FILE","util.urlJoin"],"sources":["../../src/core/sw-json-render.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type winston from \"winston\";\nimport type { PackageInfo } from \"./package-info\";\nimport * as artifacts from \"./schemas/artifacts\";\nimport type * as swJson from \"./schemas/sw-json\";\nimport type * as entrypoint from \"./schemas/entrypoints\";\nimport * as util from \"./util\";\nimport * as docker from \"./docker\";\nimport * as defaults from \"../defaults\";\nimport { descriptorFilePath } from \"./resolver\";\nimport { resolveRunEnvironment } from \"./resolver\";\n\nexport class SwJsonRenderer {\n constructor(\n private logger: winston.Logger,\n private readonly pkgInfo: PackageInfo,\n ) {}\n\n public renderSoftwareEntrypoints(\n mode: util.BuildMode,\n entrypoints: Map<string, entrypoint.Entrypoint>,\n options?: {\n requireAllArtifacts?: boolean;\n fullDirHash?: boolean;\n },\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n let hasReferences = false;\n\n const fullDirHash = options?.fullDirHash ?? false;\n\n this.logger.info(`Rendering entrypoint descriptors...`);\n this.logger.debug(\" entrypoints: \" + JSON.stringify(entrypoints));\n\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") {\n // Entrypoint references do not need any rendering\n hasReferences = true;\n continue;\n }\n\n this.logger.debug(`Rendering entrypoint descriptor '${epName}'...`);\n\n //\n // In docker case we should merge docker info and other info\n //\n const originEpName = docker.entrypointNameToOrigin(epName);\n const info = result.has(originEpName)\n ? result.get(originEpName)\n : {\n id: {\n package: this.pkgInfo.packageName,\n name: originEpName,\n },\n };\n if (!info) {\n throw util.CLIError(`Entrypoint ${epName} not found in result`);\n }\n\n if (mode !== \"release\") {\n info.isDev = true;\n }\n\n const pkg = ep.artifact;\n if (util.isDevLocalMode(mode)) {\n switch (pkg.type) {\n case \"docker\": {\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n }\n default:\n this.logger.debug(\" rendering 'local' source...\");\n info.local = this.renderLocalPackage(epName, ep, fullDirHash);\n }\n\n result.set(originEpName, info);\n continue;\n }\n\n const type = pkg.type;\n switch (type) {\n case \"R\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"environment\":\n info.runEnv = this.renderRunEnvInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"asset\":\n info.asset = this.renderAssetInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"binary\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"docker\":\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n case \"java\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"python\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"conda\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n default:\n util.assertNever(type);\n throw new Error(\n `renderer logic error: renderSoftwareEntrypoints does not cover all package types`,\n );\n }\n\n result.set(originEpName, info);\n }\n\n if (result.size === 0 && !hasReferences) {\n this.logger.error(\"no entrypoint descriptors were rendered\");\n throw util.CLIError(\"no entrypoint descriptors were rendered\");\n }\n\n return result;\n }\n\n public writeSwJson(info: swJson.swJsonType, dstFile?: string) {\n const epType = info.asset ? \"asset\" : \"software\";\n const dstSwInfoPath =\n dstFile ?? descriptorFilePath(this.pkgInfo.packageRoot, epType, info.id.name);\n\n this.logger.info(`Writing entrypoint descriptor to '${dstSwInfoPath}'`);\n\n const { id, ...toEncode } = info; // cut entrypoint ID from the final .sw.json\n const encoded = JSON.stringify({\n name: util.artifactIDToString(id),\n ...toEncode,\n });\n\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.writeFileSync(dstSwInfoPath, encoded + \"\\n\");\n }\n\n public copySwJson(epName: string, srcFile: string) {\n let epType: Extract<entrypoint.EntrypointType, \"software\" | \"asset\">;\n if (srcFile.endsWith(compiledSoftwareSuffix)) {\n epType = \"software\";\n } else if (srcFile.endsWith(compiledAssetSuffix)) {\n epType = \"asset\";\n } else {\n throw util.CLIError(\n `unknown entrypoint '${epName}' type: cannot get type from extension of source file ${srcFile}`,\n );\n }\n\n const dstSwInfoPath = descriptorFilePath(this.pkgInfo.packageRoot, epType, epName);\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.copyFileSync(srcFile, dstSwInfoPath);\n }\n\n private renderLocalPackage(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n fullDirHash: boolean,\n ): swJson.localSoftwareType {\n const artifact = ep.artifact;\n const rootDir = this.pkgInfo.artifactContentRoot(artifact, util.currentPlatform());\n const hash = fullDirHash ? util.hashDirSync(rootDir) : util.hashDirMetaSync(rootDir);\n const localPath = rootDir;\n\n const epType = ep.type;\n switch (epType) {\n case \"environment\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'environment' artifact, which does not support local build yet`,\n );\n\n case \"asset\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'asset' artifact, which does not support local build yet`,\n );\n\n case \"software\": {\n const pkgType = artifact.type;\n switch (pkgType) {\n case \"environment\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"asset\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"binary\": {\n // Regular binary with no run environment dependency\n return {\n type: \"binary\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = artifact.dependencies ?? {};\n\n return {\n type: \"python\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n toolset: toolset ?? defaults.PYTHON_TOOLSET,\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n toolset: \"renv\",\n dependencies: {},\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"docker\": {\n throw new Error(\n `internal build script logic error: attempt to build docker entrypoint as local binary package`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: artifact[\"micromamba-version\"],\n [\"conda-root-dir\"]: artifact[\"conda-root-dir\"],\n spec: artifact.spec,\n };\n }\n default:\n util.assertNever(pkgType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all artifact types\",\n );\n }\n }\n\n default:\n util.assertNever(epType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all environment types\",\n );\n }\n }\n\n private renderBinaryInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.remoteSoftwareType | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw new Error(`'*.sw.json' generator logic error`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n\n const binPkg = ep.artifact;\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n binPkg.id,\n \"archive\",\n artifacts.isCrossPlatform(binPkg.type) ? undefined : util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryName) {\n throw util.CLIError(\n `could not render binary entrypoint '${epName}': registry name is not set in artifact info file ${artInfoPath}`,\n );\n }\n\n const pkgType = binPkg.type;\n switch (pkgType) {\n case \"docker\": {\n throw new Error(\n `internal build script logic error: entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: binPkg[\"micromamba-version\"],\n [\"conda-root-dir\"]: binPkg[\"conda-root-dir\"],\n\n spec: defaults.CONDA_FROZEN_ENV_SPEC_FILE,\n };\n }\n case \"binary\": {\n return {\n type: \"binary\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = binPkg.dependencies ?? {};\n\n return {\n type: \"python\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: toolset ?? \"pip\",\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: \"renv\",\n dependencies: {},\n };\n }\n default: {\n util.assertNever(pkgType);\n throw new Error(\n \"internal build script logic error: renderBinaryInfo does not cover all package types\",\n );\n }\n }\n }\n\n private renderRunEnvInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.runEnvInfo | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`run environments do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"environment\", `internal build script logic error`);\n const envArtifact = requireArtifactType(\n ep.artifact,\n \"environment\",\n `could not render 'environment' entrypoint`,\n );\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n envArtifact.id,\n \"archive\",\n util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n type: envArtifact.runtime,\n\n [\"r-version\"]: envArtifact[\"r-version\"],\n [\"python-version\"]: envArtifact[\"python-version\"],\n [\"java-version\"]: envArtifact[\"java-version\"],\n\n envVars: envArtifact.envVars ?? [],\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n binDir: envArtifact.binDir,\n };\n }\n\n private renderAssetInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.assetInfo | undefined {\n switch (mode) {\n case \"release\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`assets do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"asset\", `internal build script logic error`);\n const assetPkg = requireArtifactType(\n ep.artifact,\n \"asset\",\n `could not render 'asset' entrypoint`,\n );\n\n if (assetPkg.type !== \"asset\") {\n throw util.CLIError(`could not render asset entrypoint '${epName}': not 'asset' artifact`);\n }\n\n const artInfoPath = this.pkgInfo.artifactInfoLocation(assetPkg.id, \"archive\", undefined);\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryURL) {\n throw util.CLIError(\n `could not render asset entrypoint '${epName}': base download URL is not configured for asset's registry`,\n );\n }\n\n return {\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n url: util.urlJoin(artInfo.registryURL, artInfo.remoteArtifactLocation),\n };\n }\n\n private renderDockerInfo(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.dockerInfo | undefined {\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n const dockerArtifact = requireArtifactType(\n ep.artifact,\n \"docker\",\n `could not render 'docker' entrypoint`,\n );\n\n // Matches the \"x64\" write in core.buildDockerImage — docker artifacts are\n // always cross-compiled to linux/amd64 so we look up the x64 descriptor\n // regardless of host.\n const artInfoPath = this.pkgInfo.artifactInfoLocation(dockerArtifact.id, \"docker\", \"x64\");\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n tag: artInfo.remoteArtifactLocation,\n entrypoint: artInfo.entrypoint ?? [],\n cmd: ep.cmd,\n pkg: dockerArtifact.pkg || \"/\",\n };\n }\n}\n\nexport const compiledSoftwareSuffix = \".sw.json\";\nexport const compiledAssetSuffix = \".as.json\";\n\nexport type builtArtifactInfo = {\n type: artifacts.artifactType;\n platform: util.PlatformType;\n registryURL?: string; // registry public URL (for assets)\n registryName?: string; // name of registry (for binary and asset archives)\n remoteArtifactLocation: string; // path to put into sw.json or as.json file\n uploadPath?: string; // custom upload path if it does not match pathForSwJson\n\n // docker-specific fields\n entrypoint?: string[]; // entrypoint of resulting docker image. Can be overriden by setting in package.json\n\n // conda-specific fields\n spec?: string; // path to spec.yaml file within conda package\n [\"micromamba-version\"]?: string; // version of micromamba used in this conda package\n};\n\nexport function writeBuiltArtifactInfo(location: string, locInfo: builtArtifactInfo) {\n fs.mkdirSync(path.dirname(location), { recursive: true });\n fs.writeFileSync(location, JSON.stringify(locInfo), { encoding: \"utf8\" });\n}\n\nexport function readBuiltArtifactInfo(location: string): builtArtifactInfo {\n const data = fs.readFileSync(location, \"utf8\");\n return JSON.parse(data) as builtArtifactInfo;\n}\n\nfunction readArtifactInfoIfExists(\n location: string,\n epName: string,\n requireExisting?: boolean,\n): builtArtifactInfo | undefined {\n if (fs.existsSync(location)) {\n return readBuiltArtifactInfo(location);\n }\n\n if (requireExisting) {\n throw util.CLIError(\n `could not render docker entrypoint '${epName}': artifact info file '${location}' does not exist`,\n );\n }\n\n return undefined;\n}\n\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"asset\",\n errMsg: string,\n): entrypoint.AssetEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"software\",\n errMsg: string,\n): entrypoint.SoftwareEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"environment\",\n errMsg: string,\n): entrypoint.EnvironmentEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: entrypoint.EntrypointType,\n errMsg: string,\n): entrypoint.PackageEntrypoint {\n if (ep.type === type) {\n return ep;\n }\n\n throw new Error(`${errMsg}: entrypoint ${ep.name} (${ep.type}) is not '${type}'`);\n}\n\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"asset\",\n errMsg: string,\n): artifacts.withId<artifacts.assetType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"environment\",\n errMsg: string,\n): artifacts.withId<artifacts.environmentType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"java\",\n errMsg: string,\n): artifacts.withId<artifacts.javaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"python\",\n errMsg: string,\n): artifacts.withId<artifacts.pythonType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"R\",\n errMsg: string,\n): artifacts.withId<artifacts.rType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"binary\",\n errMsg: string,\n): artifacts.withId<artifacts.binaryType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"docker\",\n errMsg: string,\n): artifacts.withId<artifacts.dockerType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"conda\",\n errMsg: string,\n): artifacts.withId<artifacts.condaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: artifacts.artifactType,\n errMsg: string,\n): artifacts.withId<artifacts.anyArtifactType> {\n if (pkg.type === type) {\n return pkg;\n }\n\n if (errMsg) {\n errMsg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,QAAQ,oBAAoB;AAClF,MAAI,CAAC,QACH;AAGF,SAAO;GACL,KAAK,QAAQ;GACb,YAAY,QAAQ,cAAc,EAAE;GACpC,KAAK,GAAG;GACR,KAAK,eAAe,OAAO;GAC5B;;;AAuBL,SAAgB,uBAAuB,UAAkB,SAA4B;AACnF,IAAG,UAAU,KAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACzD,IAAG,cAAc,UAAU,KAAK,UAAU,QAAQ,EAAE,EAAE,UAAU,QAAQ,CAAC;;AAG3E,SAAgB,sBAAsB,UAAqC;CACzE,MAAM,OAAO,GAAG,aAAa,UAAU,OAAO;AAC9C,QAAO,KAAK,MAAM,KAAK;;AAGzB,SAAS,yBACP,UACA,QACA,iBAC+B;AAC/B,KAAI,GAAG,WAAW,SAAS,CACzB,QAAO,sBAAsB,SAAS;AAGxC,KAAI,gBACF,OAAMR,SACJ,uCAAuC,OAAO,yBAAyB,SAAS,kBACjF;;AAqBL,SAAS,sBACP,IACA,MACA,QAC8B;AAC9B,KAAI,GAAG,SAAS,KACd,QAAO;AAGT,OAAM,IAAI,MAAM,GAAG,OAAO,eAAe,GAAG,KAAK,IAAI,GAAG,KAAK,YAAY,KAAK,GAAG;;AA2CnF,SAAS,oBACP,KACA,MACA,QAC6C;AAC7C,KAAI,IAAI,SAAS,KACf,QAAO;AAGT,KAAI,OACF,UAAS,GAAG,OAAO;AAGrB,OAAMA,SAAc,GAAG,OAAO,YAAY,IAAI,GAAG,MAAM,IAAI,KAAK,aAAa,KAAK,GAAG"}
|
|
1
|
+
{"version":3,"file":"sw-json-render.js","names":["docker.entrypointNameToOrigin","util.CLIError","util.isDevMode","util.producesRegistryDescriptor","defaults.NO_SOFTWARE_PLACEHOLDER","util.artifactIDToString","util.currentPlatform","util.hashDirSync","util.hashDirMetaSync","artifacts.isCrossPlatform","defaults.CONDA_FROZEN_ENV_SPEC_FILE","util.urlJoin"],"sources":["../../src/core/sw-json-render.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type winston from \"winston\";\nimport type { PackageInfo } from \"./package-info\";\nimport * as artifacts from \"./schemas/artifacts\";\nimport type * as swJson from \"./schemas/sw-json\";\nimport type * as entrypoint from \"./schemas/entrypoints\";\nimport * as util from \"./util\";\nimport * as docker from \"./docker\";\nimport * as defaults from \"../defaults\";\nimport { descriptorFilePath } from \"./resolver\";\nimport { resolveRunEnvironment } from \"./resolver\";\n\nexport class SwJsonRenderer {\n constructor(\n private logger: winston.Logger,\n private readonly pkgInfo: PackageInfo,\n ) {}\n\n public renderSoftwareEntrypoints(\n mode: util.BuildMode,\n entrypoints: Map<string, entrypoint.Entrypoint>,\n options?: {\n requireAllArtifacts?: boolean;\n fullDirHash?: boolean;\n },\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n let hasReferences = false;\n\n const fullDirHash = options?.fullDirHash ?? false;\n\n this.logger.info(`Rendering entrypoint descriptors...`);\n this.logger.debug(\" entrypoints: \" + JSON.stringify(entrypoints));\n\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") {\n // Entrypoint references do not need any rendering\n hasReferences = true;\n continue;\n }\n\n this.logger.debug(`Rendering entrypoint descriptor '${epName}'...`);\n\n //\n // In docker case we should merge docker info and other info\n //\n const originEpName = docker.entrypointNameToOrigin(epName);\n const info = result.has(originEpName)\n ? result.get(originEpName)\n : {\n id: {\n package: this.pkgInfo.packageName,\n name: originEpName,\n },\n };\n if (!info) {\n throw util.CLIError(`Entrypoint ${epName} not found in result`);\n }\n\n if (util.isDevMode(mode)) {\n info.isDev = true;\n }\n\n const pkg = ep.artifact;\n if (!util.producesRegistryDescriptor(mode)) {\n switch (pkg.type) {\n case \"docker\": {\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n }\n default:\n this.logger.debug(\" rendering 'local' source...\");\n info.local = this.renderLocalPackage(epName, ep, fullDirHash);\n }\n\n result.set(originEpName, info);\n continue;\n }\n\n const type = pkg.type;\n switch (type) {\n case \"R\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"environment\":\n info.runEnv = this.renderRunEnvInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"asset\":\n info.asset = this.renderAssetInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"binary\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"docker\":\n info.docker = this.renderDockerInfo(epName, ep, options?.requireAllArtifacts);\n break;\n case \"java\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"python\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n case \"conda\":\n info.binary = this.renderBinaryInfo(mode, epName, ep, options?.requireAllArtifacts);\n break;\n default:\n util.assertNever(type);\n throw new Error(\n `renderer logic error: renderSoftwareEntrypoints does not cover all package types`,\n );\n }\n\n result.set(originEpName, info);\n }\n\n if (result.size === 0 && !hasReferences) {\n this.logger.error(\"no entrypoint descriptors were rendered\");\n throw util.CLIError(\"no entrypoint descriptors were rendered\");\n }\n\n return result;\n }\n\n // One minimal `binary` placeholder per entrypoint, so a block builds, loads, and renders without\n // any software; only executing it fails, against the sentinel registry. References are copied\n // through by the caller, so they are skipped here.\n public renderPlaceholderEntrypoints(\n entrypoints: Map<string, entrypoint.Entrypoint>,\n ): Map<string, swJson.swJsonType> {\n const result = new Map<string, swJson.swJsonType>();\n for (const [epName, ep] of entrypoints.entries()) {\n if (ep.type === \"reference\") continue;\n const originEpName = docker.entrypointNameToOrigin(epName);\n if (result.has(originEpName)) continue;\n result.set(originEpName, {\n id: { package: this.pkgInfo.packageName, name: originEpName },\n isDev: true,\n binary: {\n type: \"binary\",\n registry: defaults.NO_SOFTWARE_PLACEHOLDER,\n package: defaults.NO_SOFTWARE_PLACEHOLDER,\n cmd: [\"true\"],\n },\n });\n }\n return result;\n }\n\n public writeSwJson(info: swJson.swJsonType, dstFile?: string) {\n const epType = info.asset ? \"asset\" : \"software\";\n const dstSwInfoPath =\n dstFile ?? descriptorFilePath(this.pkgInfo.packageRoot, epType, info.id.name);\n\n this.logger.info(`Writing entrypoint descriptor to '${dstSwInfoPath}'`);\n\n const { id, ...toEncode } = info; // cut entrypoint ID from the final .sw.json\n const encoded = JSON.stringify({\n name: util.artifactIDToString(id),\n ...toEncode,\n });\n\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.writeFileSync(dstSwInfoPath, encoded + \"\\n\");\n }\n\n public copySwJson(epName: string, srcFile: string) {\n let epType: Extract<entrypoint.EntrypointType, \"software\" | \"asset\">;\n if (srcFile.endsWith(compiledSoftwareSuffix)) {\n epType = \"software\";\n } else if (srcFile.endsWith(compiledAssetSuffix)) {\n epType = \"asset\";\n } else {\n throw util.CLIError(\n `unknown entrypoint '${epName}' type: cannot get type from extension of source file ${srcFile}`,\n );\n }\n\n const dstSwInfoPath = descriptorFilePath(this.pkgInfo.packageRoot, epType, epName);\n util.ensureDirsExist(path.dirname(dstSwInfoPath));\n fs.copyFileSync(srcFile, dstSwInfoPath);\n }\n\n private renderLocalPackage(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n fullDirHash: boolean,\n ): swJson.localSoftwareType {\n const artifact = ep.artifact;\n const rootDir = this.pkgInfo.artifactContentRoot(artifact, util.currentPlatform());\n const hash = fullDirHash ? util.hashDirSync(rootDir) : util.hashDirMetaSync(rootDir);\n const localPath = rootDir;\n\n const epType = ep.type;\n switch (epType) {\n case \"environment\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'environment' artifact, which does not support local build yet`,\n );\n\n case \"asset\":\n throw util.CLIError(\n `entrypoint ${epName} points to 'asset' artifact, which does not support local build yet`,\n );\n\n case \"software\": {\n const pkgType = artifact.type;\n switch (pkgType) {\n case \"environment\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"asset\": {\n throw util.CLIError(\n `entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"binary\": {\n // Regular binary with no run environment dependency\n return {\n type: \"binary\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = artifact.dependencies ?? {};\n\n return {\n type: \"python\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n toolset: toolset ?? defaults.PYTHON_TOOLSET,\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n toolset: \"renv\",\n dependencies: {},\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n artifact.environment,\n artifact.type,\n ),\n };\n }\n case \"docker\": {\n throw new Error(\n `internal build script logic error: attempt to build docker entrypoint as local binary package`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n hash: hash.digest().toString(\"hex\"),\n path: localPath,\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: artifact[\"micromamba-version\"],\n [\"conda-root-dir\"]: artifact[\"conda-root-dir\"],\n spec: artifact.spec,\n };\n }\n default:\n util.assertNever(pkgType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all artifact types\",\n );\n }\n }\n\n default:\n util.assertNever(epType);\n throw new Error(\n \"renderer logic error: renderLocalInfo does not cover all environment types\",\n );\n }\n }\n\n private renderBinaryInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.remoteSoftwareType | undefined {\n switch (mode) {\n case \"release\":\n case \"dev-remote\":\n break;\n\n case \"dev-local\":\n throw new Error(`'*.sw.json' generator logic error`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n\n const binPkg = ep.artifact;\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n binPkg.id,\n \"archive\",\n artifacts.isCrossPlatform(binPkg.type) ? undefined : util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryName) {\n throw util.CLIError(\n `could not render binary entrypoint '${epName}': registry name is not set in artifact info file ${artInfoPath}`,\n );\n }\n\n const pkgType = binPkg.type;\n switch (pkgType) {\n case \"docker\": {\n throw new Error(\n `internal build script logic error: entrypoint is incompatible with artifact type: ep=${epName} (software), artifact='${pkgType}'`,\n );\n }\n case \"conda\": {\n return {\n type: \"conda\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n\n [\"micromamba-version\"]: binPkg[\"micromamba-version\"],\n [\"conda-root-dir\"]: binPkg[\"conda-root-dir\"],\n\n spec: defaults.CONDA_FROZEN_ENV_SPEC_FILE,\n };\n }\n case \"binary\": {\n return {\n type: \"binary\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n };\n }\n case \"java\": {\n return {\n type: \"java\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n };\n }\n case \"python\": {\n const { toolset, ...deps } = binPkg.dependencies ?? {};\n\n return {\n type: \"python\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: toolset ?? \"pip\",\n dependencies: deps,\n };\n }\n case \"R\": {\n return {\n type: \"R\",\n registry: artInfo.registryName,\n package: artInfo.remoteArtifactLocation,\n\n cmd: ep.cmd,\n envVars: ep.env,\n runEnv: resolveRunEnvironment(\n this.logger,\n this.pkgInfo.packageRoot,\n this.pkgInfo.packageName,\n binPkg.environment,\n binPkg.type,\n ),\n toolset: \"renv\",\n dependencies: {},\n };\n }\n default: {\n util.assertNever(pkgType);\n throw new Error(\n \"internal build script logic error: renderBinaryInfo does not cover all package types\",\n );\n }\n }\n }\n\n private renderRunEnvInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.runEnvInfo | undefined {\n switch (mode) {\n case \"release\":\n case \"dev-remote\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`run environments do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"environment\", `internal build script logic error`);\n const envArtifact = requireArtifactType(\n ep.artifact,\n \"environment\",\n `could not render 'environment' entrypoint`,\n );\n\n // TODO: we need to collect artifact info for all platforms\n const artInfoPath = this.pkgInfo.artifactInfoLocation(\n envArtifact.id,\n \"archive\",\n util.currentPlatform(),\n );\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n type: envArtifact.runtime,\n\n [\"r-version\"]: envArtifact[\"r-version\"],\n [\"python-version\"]: envArtifact[\"python-version\"],\n [\"java-version\"]: envArtifact[\"java-version\"],\n\n envVars: envArtifact.envVars ?? [],\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n binDir: envArtifact.binDir,\n };\n }\n\n private renderAssetInfo(\n mode: util.BuildMode,\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.assetInfo | undefined {\n switch (mode) {\n case \"release\":\n case \"dev-remote\":\n break;\n\n case \"dev-local\":\n throw util.CLIError(`assets do not support 'local' dev build mode yet`);\n\n default:\n util.assertNever(mode);\n }\n\n ep = requireEntrypointType(ep, \"asset\", `internal build script logic error`);\n const assetPkg = requireArtifactType(\n ep.artifact,\n \"asset\",\n `could not render 'asset' entrypoint`,\n );\n\n if (assetPkg.type !== \"asset\") {\n throw util.CLIError(`could not render asset entrypoint '${epName}': not 'asset' artifact`);\n }\n\n const artInfoPath = this.pkgInfo.artifactInfoLocation(assetPkg.id, \"archive\", undefined);\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n if (!artInfo.registryURL) {\n throw util.CLIError(\n `could not render asset entrypoint '${epName}': base download URL is not configured for asset's registry`,\n );\n }\n\n return {\n registry: artInfo.registryName!,\n package: artInfo.remoteArtifactLocation,\n url: util.urlJoin(artInfo.registryURL, artInfo.remoteArtifactLocation),\n };\n }\n\n private renderDockerInfo(\n epName: string,\n ep: entrypoint.PackageEntrypoint,\n requireArtifactInfo?: boolean,\n ): swJson.dockerInfo | undefined {\n ep = requireEntrypointType(ep, \"software\", `internal build script logic error`);\n const dockerArtifact = requireArtifactType(\n ep.artifact,\n \"docker\",\n `could not render 'docker' entrypoint`,\n );\n\n // Matches the \"x64\" write in core.buildDockerImage — docker artifacts are\n // always cross-compiled to linux/amd64 so we look up the x64 descriptor\n // regardless of host.\n const artInfoPath = this.pkgInfo.artifactInfoLocation(dockerArtifact.id, \"docker\", \"x64\");\n const artInfo = readArtifactInfoIfExists(artInfoPath, epName, requireArtifactInfo);\n if (!artInfo) {\n return undefined;\n }\n\n return {\n tag: artInfo.remoteArtifactLocation,\n entrypoint: artInfo.entrypoint ?? [],\n cmd: ep.cmd,\n pkg: dockerArtifact.pkg || \"/\",\n };\n }\n}\n\nexport const compiledSoftwareSuffix = \".sw.json\";\nexport const compiledAssetSuffix = \".as.json\";\n\nexport type builtArtifactInfo = {\n type: artifacts.artifactType;\n platform: util.PlatformType;\n registryURL?: string; // registry public URL (for assets)\n registryName?: string; // name of registry (for binary and asset archives)\n remoteArtifactLocation: string; // path to put into sw.json or as.json file\n uploadPath?: string; // custom upload path if it does not match pathForSwJson\n\n // docker-specific fields\n entrypoint?: string[]; // entrypoint of resulting docker image. Can be overriden by setting in package.json\n\n // conda-specific fields\n spec?: string; // path to spec.yaml file within conda package\n [\"micromamba-version\"]?: string; // version of micromamba used in this conda package\n};\n\nexport function writeBuiltArtifactInfo(location: string, locInfo: builtArtifactInfo) {\n fs.mkdirSync(path.dirname(location), { recursive: true });\n fs.writeFileSync(location, JSON.stringify(locInfo), { encoding: \"utf8\" });\n}\n\nexport function readBuiltArtifactInfo(location: string): builtArtifactInfo {\n const data = fs.readFileSync(location, \"utf8\");\n return JSON.parse(data) as builtArtifactInfo;\n}\n\nfunction readArtifactInfoIfExists(\n location: string,\n epName: string,\n requireExisting?: boolean,\n): builtArtifactInfo | undefined {\n if (fs.existsSync(location)) {\n return readBuiltArtifactInfo(location);\n }\n\n if (requireExisting) {\n throw util.CLIError(\n `could not render docker entrypoint '${epName}': artifact info file '${location}' does not exist`,\n );\n }\n\n return undefined;\n}\n\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"asset\",\n errMsg: string,\n): entrypoint.AssetEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"software\",\n errMsg: string,\n): entrypoint.SoftwareEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: \"environment\",\n errMsg: string,\n): entrypoint.EnvironmentEntrypoint;\nfunction requireEntrypointType(\n ep: entrypoint.PackageEntrypoint,\n type: entrypoint.EntrypointType,\n errMsg: string,\n): entrypoint.PackageEntrypoint {\n if (ep.type === type) {\n return ep;\n }\n\n throw new Error(`${errMsg}: entrypoint ${ep.name} (${ep.type}) is not '${type}'`);\n}\n\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"asset\",\n errMsg: string,\n): artifacts.withId<artifacts.assetType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"environment\",\n errMsg: string,\n): artifacts.withId<artifacts.environmentType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"java\",\n errMsg: string,\n): artifacts.withId<artifacts.javaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"python\",\n errMsg: string,\n): artifacts.withId<artifacts.pythonType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"R\",\n errMsg: string,\n): artifacts.withId<artifacts.rType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"binary\",\n errMsg: string,\n): artifacts.withId<artifacts.binaryType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"docker\",\n errMsg: string,\n): artifacts.withId<artifacts.dockerType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: \"conda\",\n errMsg: string,\n): artifacts.withId<artifacts.condaType>;\nfunction requireArtifactType(\n pkg: artifacts.withId<artifacts.anyArtifactType>,\n type: artifacts.artifactType,\n errMsg: string,\n): artifacts.withId<artifacts.anyArtifactType> {\n if (pkg.type === type) {\n return pkg;\n }\n\n if (errMsg) {\n errMsg = `${errMsg}: `;\n }\n\n throw util.CLIError(`${errMsg}artif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8B;CAC9B,IAAI,GAAG,SAAS,MACd,OAAO;CAGT,MAAM,IAAI,MAAM,GAAG,OAAO,eAAe,GAAG,KAAK,IAAI,GAAG,KAAK,YAAY,KAAK,EAAE;AAClF;AA0CA,SAAS,oBACP,KACA,MACA,QAC6C;CAC7C,IAAI,IAAI,SAAS,MACf,OAAO;CAGT,IAAI,QACF,SAAS,GAAG,OAAO;CAGrB,MAAMA,SAAc,GAAG,OAAO,YAAY,IAAI,GAAG,MAAM,IAAI,KAAK,aAAa,KAAK,EAAE;AACtF"}
|
package/dist/core/util.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_envs = require("./envs.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
|
-
node_fs = require_runtime.__toESM(node_fs);
|
|
4
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
5
|
let node_path = require("node:path");
|
|
6
|
-
node_path = require_runtime.__toESM(node_path);
|
|
7
|
-
let node_os = require("node:os");
|
|
8
|
-
node_os = require_runtime.__toESM(node_os);
|
|
6
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
9
7
|
let node_crypto = require("node:crypto");
|
|
8
|
+
let node_os = require("node:os");
|
|
9
|
+
node_os = require_runtime.__toESM(node_os, 1);
|
|
10
10
|
let winston = require("winston");
|
|
11
|
-
winston = require_runtime.__toESM(winston);
|
|
11
|
+
winston = require_runtime.__toESM(winston, 1);
|
|
12
12
|
//#region src/core/util.ts
|
|
13
13
|
var util_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
14
14
|
AllPlatforms: () => AllPlatforms,
|
|
@@ -32,11 +32,13 @@ var util_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
32
32
|
hashDirMetaSync: () => hashDirMetaSync,
|
|
33
33
|
hashDirSync: () => hashDirSync,
|
|
34
34
|
indentText: () => indentText,
|
|
35
|
-
|
|
35
|
+
isDevMode: () => isDevMode,
|
|
36
36
|
isPlatformSupported: () => isPlatformSupported,
|
|
37
37
|
joinPlatform: () => joinPlatform,
|
|
38
38
|
packageJsonName: () => packageJsonName,
|
|
39
|
+
producesRegistryDescriptor: () => producesRegistryDescriptor,
|
|
39
40
|
rSplit: () => rSplit,
|
|
41
|
+
shouldDoAction: () => shouldDoAction,
|
|
40
42
|
softwareConfigName: () => softwareConfigName,
|
|
41
43
|
splitPlatform: () => splitPlatform,
|
|
42
44
|
toInt: () => toInt,
|
|
@@ -74,7 +76,7 @@ function hashDirMetaSync(folder, hasher) {
|
|
|
74
76
|
function hashDirSync(rootDir, hasher, subdir) {
|
|
75
77
|
const hash = hasher ? hasher : (0, node_crypto.createHash)("sha256");
|
|
76
78
|
const folder = node_path.join(rootDir, subdir ?? ".");
|
|
77
|
-
const info = node_fs.default.readdirSync(folder, { withFileTypes: true });
|
|
79
|
+
const info = node_fs.default.readdirSync(folder, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
78
80
|
for (const item of info) {
|
|
79
81
|
const relPath = node_path.join(subdir ?? ".", item.name);
|
|
80
82
|
const fullPath = node_path.join(folder, item.name);
|
|
@@ -85,7 +87,7 @@ function hashDirSync(rootDir, hasher, subdir) {
|
|
|
85
87
|
let bytesRead;
|
|
86
88
|
while ((bytesRead = node_fs.default.readSync(fileDescriptor, buffer, 0, buffer.length, null)) !== 0) hash.update(buffer.subarray(0, bytesRead));
|
|
87
89
|
node_fs.default.closeSync(fileDescriptor);
|
|
88
|
-
} else if (item.isDirectory()) hashDirSync(
|
|
90
|
+
} else if (item.isDirectory()) hashDirSync(rootDir, hash, relPath);
|
|
89
91
|
}
|
|
90
92
|
return hash;
|
|
91
93
|
}
|
|
@@ -224,9 +226,16 @@ function currentPlatform() {
|
|
|
224
226
|
return `${currentOS()}-${currentArch()}`;
|
|
225
227
|
}
|
|
226
228
|
const AllSoftwareSources = ["archive", "docker"];
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
function isDevMode(mode) {
|
|
230
|
+
return mode === "dev-local" || mode === "dev-remote";
|
|
231
|
+
}
|
|
232
|
+
function producesRegistryDescriptor(mode) {
|
|
233
|
+
return mode === "dev-remote" || mode === "release";
|
|
234
|
+
}
|
|
235
|
+
function shouldDoAction(opts) {
|
|
236
|
+
if (opts.disable) return false;
|
|
237
|
+
if (opts.enable) return true;
|
|
238
|
+
return opts.default;
|
|
230
239
|
}
|
|
231
240
|
function artifactIDFromString(s) {
|
|
232
241
|
const parts = s.split(":", 2);
|
|
@@ -281,26 +290,38 @@ function CLIError(msg) {
|
|
|
281
290
|
}
|
|
282
291
|
//#endregion
|
|
283
292
|
exports.AllPlatforms = AllPlatforms;
|
|
293
|
+
exports.AllSoftwareSources = AllSoftwareSources;
|
|
294
|
+
exports.Arches = Arches;
|
|
284
295
|
exports.CLIError = CLIError;
|
|
296
|
+
exports.CLIErrorClass = CLIErrorClass;
|
|
297
|
+
exports.OSes = OSes;
|
|
298
|
+
exports.artifactIDFromString = artifactIDFromString;
|
|
285
299
|
exports.artifactIDToString = artifactIDToString;
|
|
286
300
|
exports.assertNever = assertNever;
|
|
301
|
+
exports.createLogger = createLogger;
|
|
287
302
|
exports.currentArch = currentArch;
|
|
288
303
|
exports.currentOS = currentOS;
|
|
289
304
|
exports.currentPlatform = currentPlatform;
|
|
290
305
|
exports.ensureDirsExist = ensureDirsExist;
|
|
291
306
|
exports.findInstalledModule = findInstalledModule;
|
|
307
|
+
exports.findNodeModules = findNodeModules;
|
|
292
308
|
exports.findPackageRoot = findPackageRoot;
|
|
293
309
|
exports.formatZodIssues = formatZodIssues;
|
|
294
310
|
exports.hashDirMetaSync = hashDirMetaSync;
|
|
295
311
|
exports.hashDirSync = hashDirSync;
|
|
296
|
-
exports.
|
|
312
|
+
exports.indentText = indentText;
|
|
313
|
+
exports.isDevMode = isDevMode;
|
|
314
|
+
exports.isPlatformSupported = isPlatformSupported;
|
|
297
315
|
exports.joinPlatform = joinPlatform;
|
|
298
316
|
exports.packageJsonName = packageJsonName;
|
|
317
|
+
exports.producesRegistryDescriptor = producesRegistryDescriptor;
|
|
299
318
|
exports.rSplit = rSplit;
|
|
319
|
+
exports.shouldDoAction = shouldDoAction;
|
|
300
320
|
exports.softwareConfigName = softwareConfigName;
|
|
301
321
|
exports.splitPlatform = splitPlatform;
|
|
302
322
|
exports.toInt = toInt;
|
|
303
323
|
exports.trimPrefix = trimPrefix;
|
|
324
|
+
exports.trimSuffix = trimSuffix;
|
|
304
325
|
exports.urlJoin = urlJoin;
|
|
305
326
|
Object.defineProperty(exports, "util_exports", {
|
|
306
327
|
enumerable: true,
|
package/dist/core/util.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.cjs","names":["fs","path","os"],"sources":["../../src/core/util.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as os from \"node:os\";\nimport fs from \"node:fs\";\nimport type { Hash } from \"node:crypto\";\nimport { createHash } from \"node:crypto\";\nimport winston from \"winston\";\nimport type { z } from \"zod/v4\";\nimport * as envs from \"./envs\";\n\nexport const packageJsonName = \"package.json\";\nexport const softwareConfigName = \"package.json\";\n\nexport function assertNever(_a: never) {\n throw new Error(`code logic error: assertNever() call for ${JSON.stringify(_a)}`);\n}\n\nexport function trimPrefix(str: string, prefix: string): string {\n if (str.startsWith(prefix)) {\n return str.slice(prefix.length);\n }\n return str;\n}\n\nexport function trimSuffix(str: string, suffix: string): string {\n if (str.endsWith(suffix)) {\n return str.slice(0, -suffix.length);\n }\n return str;\n}\n\nexport function hashDirMetaSync(folder: string, hasher?: Hash): Hash {\n const hash = hasher ? hasher : createHash(\"sha256\");\n const info = fs.readdirSync(folder, { withFileTypes: true });\n\n for (const item of info) {\n const fullPath = path.join(folder, item.name);\n\n if (item.isFile()) {\n const statInfo = fs.statSync(fullPath);\n const fileInfo = `${fullPath}:${statInfo.size}:${statInfo.mtimeMs}`;\n hash.update(fileInfo);\n } else if (item.isDirectory()) {\n hashDirMetaSync(fullPath, hash);\n }\n }\n\n return hash;\n}\n\nexport function hashDirSync(rootDir: string, hasher?: Hash, subdir?: string): Hash {\n const hash = hasher ? hasher : createHash(\"sha256\");\n const folder = path.join(rootDir, subdir ?? \".\");\n\n const info = fs.readdirSync(folder, { withFileTypes: true });\n\n for (const item of info) {\n const relPath = path.join(subdir ?? \".\", item.name);\n const fullPath = path.join(folder, item.name);\n\n hash.update(relPath);\n\n if (item.isFile()) {\n const fileDescriptor = fs.openSync(fullPath, \"r\");\n const buffer = Buffer.alloc(65536);\n let bytesRead: number;\n\n while ((bytesRead = fs.readSync(fileDescriptor, buffer, 0, buffer.length, null)) !== 0) {\n hash.update(buffer.subarray(0, bytesRead));\n }\n\n fs.closeSync(fileDescriptor);\n } else if (item.isDirectory()) {\n hashDirSync(fullPath, hash);\n }\n }\n\n return hash;\n}\n\n//\n// Creates all intermediate directories down to given <dirPath>.\n//\nexport function ensureDirsExist(dirPath: string) {\n if (fs.existsSync(dirPath)) {\n return;\n }\n const parentDir = path.dirname(dirPath);\n ensureDirsExist(parentDir);\n fs.mkdirSync(dirPath);\n}\n\nexport function findPackageRoot(logger: winston.Logger, startPath?: string): string {\n if (!startPath) {\n startPath = process.cwd();\n }\n logger.debug(`Detecting package root...`);\n const pkgRoot = searchPathUp(startPath, startPath, packageJsonName);\n logger.debug(` package root found at '${pkgRoot}'`);\n\n return pkgRoot;\n}\n\nexport function findNodeModules(logger: winston.Logger, startPath?: string): string {\n if (!startPath) {\n startPath = process.cwd();\n }\n logger.debug(`Detecting 'node_modules' directory...`);\n const nodeModules = searchPathUp(startPath, startPath, \"node_modules\");\n logger.debug(` 'node_modules' found at '${nodeModules}'`);\n\n return path.join(nodeModules, \"node_modules\");\n}\n\nexport function findInstalledModule(\n logger: winston.Logger,\n packageName: string,\n startPath?: string,\n): string {\n const nodeModules = findNodeModules(logger, startPath);\n const packagePath = path.resolve(nodeModules, packageName);\n\n if (!fs.existsSync(packagePath)) {\n throw CLIError(\n `package '${packageName}' not found in '${nodeModules}'. Did you forget to add it as a dependency?`,\n );\n }\n\n return packagePath;\n}\n\nfunction searchPathUp(startPath: string, pathToCheck: string, itemToCheck: string): string {\n const itemPath = path.resolve(pathToCheck, itemToCheck);\n\n if (fs.existsSync(itemPath)) {\n return pathToCheck;\n }\n\n const parentDir = path.dirname(pathToCheck);\n if (parentDir === pathToCheck || pathToCheck === \"\") {\n throw CLIError(\n `failed to find '${itemToCheck}' file in any of parent directories starting from '${startPath}'`,\n );\n }\n\n return searchPathUp(startPath, parentDir, itemToCheck);\n}\n\nexport function createLogger(level: string = \"debug\"): winston.Logger {\n if (envs.isCI() && envs.isRunnerDebug()) {\n level = \"debug\";\n }\n\n return winston.createLogger({\n level: level,\n\n format: winston.format.printf(({ level, message }) => {\n const indent = \" \".repeat(level.length + 2); // For ': ' after the level\n if (typeof message !== \"string\") {\n const messageJson = JSON.stringify(message);\n throw new Error(`logger message ${messageJson} is not a string`);\n }\n const indentedMessage = message\n .split(\"\\n\")\n .map((line: string, index: number) => (index === 0 ? line : indent + line))\n .join(\"\\n\");\n\n const colorize = (l: string) => winston.format.colorize().colorize(l, l);\n\n return `${colorize(level)}: ${indentedMessage}`;\n }),\n\n transports: [\n new winston.transports.Console({\n stderrLevels: [\"error\", \"warn\", \"info\", \"debug\"],\n handleExceptions: true,\n }),\n ],\n });\n}\n\nexport function rSplit(input: string, delimiter: string, limit?: number): string[] {\n const parts = input.split(delimiter);\n if (!limit || parts.length <= limit) {\n return parts;\n }\n\n return [parts.slice(0, -limit + 1).join(delimiter), ...parts.slice(-limit + 1)];\n}\n\nconst replaceDuplicateSlashes = new RegExp(\"//+\", \"g\");\nexport function urlJoin(url: string, appendPath: string): string {\n const u = new URL(url, \"file:/nonexistent-9672674c/\");\n if (u.protocol === \"file:\" && u.pathname.startsWith(\"/nonexistent-9672674c/\")) {\n throw new Error(`string '${url}' is not valid URL`);\n }\n\n u.pathname = u.pathname + \"/\" + appendPath;\n u.pathname = u.pathname.replaceAll(replaceDuplicateSlashes, \"/\");\n return u.toString();\n}\n\nexport function wrapErr(e: any, msg: string): any {\n if (!(e instanceof Error)) {\n return e;\n }\n\n const wrappedError = new Error(`${msg}: ${e.message}`);\n wrappedError.name = e.name;\n wrappedError.stack = e.stack;\n // Copy any additional custom properties\n Object.assign(wrappedError, e);\n return wrappedError;\n}\n\n/**\n * Converts any value to integer number 1 if value is truthful and 0 otherwice.\n * Provides simple way to count values that are defined in an object:\n * toInt(options.a) + toInt(options.b) + toInt(options.c) === 1\n * @param input: any\n * @returns number - '1' or '0'\n */\nexport function toInt(input: any): number {\n return input ? 1 : 0;\n}\n\nexport const OSes = [\"linux\", \"macosx\", \"windows\"] as const;\nexport type OSType = (typeof OSes)[number];\n\nexport function currentOS(): OSType {\n const platform = os.platform();\n switch (platform) {\n case \"darwin\":\n return \"macosx\";\n case \"linux\":\n return \"linux\";\n case \"win32\":\n return \"windows\";\n default:\n throw CLIError(\n `operating system '${platform}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` +\n JSON.stringify(OSes),\n );\n }\n}\n\nexport const Arches = [\"x64\", \"aarch64\"] as const;\nexport type ArchType = (typeof Arches)[number];\n\nexport function currentArch(): ArchType {\n const arch = os.arch();\n switch (arch) {\n case \"arm64\":\n return \"aarch64\";\n case \"x64\":\n return \"x64\";\n default:\n throw CLIError(\n `processor architecture '${arch}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` +\n JSON.stringify(Arches),\n );\n }\n}\n\n// Combinartions of OS and architecture, Platforma supports.\nexport const AllPlatforms: `${OSType}-${ArchType}`[] = [\n \"linux-x64\",\n \"linux-aarch64\",\n \"macosx-x64\",\n \"macosx-aarch64\",\n \"windows-x64\",\n] as const;\nexport type PlatformType = (typeof AllPlatforms)[number];\n\nexport function splitPlatform(platform: PlatformType): { os: OSType; arch: ArchType } {\n const parts = platform.split(\"-\");\n\n return {\n os: parts[0] as OSType,\n arch: parts[1] as ArchType,\n };\n}\n\nexport function joinPlatform(os: OSType, arch: ArchType): PlatformType {\n return `${os}-${arch}`;\n}\n\nexport function isPlatformSupported(os: OSType, arch: ArchType): boolean {\n return AllPlatforms.includes(`${os}-${arch}`);\n}\n\nexport function currentPlatform(): PlatformType {\n return `${currentOS()}-${currentArch()}`;\n}\n\nexport const AllSoftwareSources = [\"archive\", \"docker\"] as const; // add 'image', '<whatever>' here when supported\nexport type SoftwareSource = (typeof AllSoftwareSources)[number];\n\nexport type BuildMode = \"dev-local\" | \"release\";\n\n/** True for dev-local build mode. */\nexport function isDevLocalMode(mode: BuildMode): mode is \"dev-local\" {\n return mode === \"dev-local\";\n}\n\nexport type artifactID = {\n package: string;\n name: string;\n};\n\nexport function artifactIDFromString(s: string): artifactID {\n const parts = s.split(\":\", 2);\n if (parts.length < 2) {\n throw CLIError(\n `string '${s}' is not an artifact ID (artifact ID format is <packageName>:<artifactName>)`,\n );\n }\n return {\n package: parts[0],\n name: parts[1],\n };\n}\n\nexport function artifactIDToString(a: artifactID): string {\n return `${a.package}:${a.name}`;\n}\n\nexport function indentText(txt: string, indent: string | number, skipFirstLine: boolean = false) {\n indent = typeof indent === \"number\" ? \" \".repeat(indent) : indent;\n\n return txt\n .split(\"\\n\")\n .map((line, index) => (index === 0 && skipFirstLine ? line : `${indent}${line}`))\n .join(\"\\n\");\n}\n\nexport const formatZodIssues = (\n issues: z.core.$ZodIssue[],\n i: string = \"\",\n p: PropertyKey[] = [],\n): string => {\n const _errors: string[] = [];\n\n const formatSubpath = (path: PropertyKey[], prefix: string = \"\") => {\n let pp = path.join(\".\");\n if (pp != \"\" && p.length > 0) pp = `.${pp}`;\n if (pp != \"\") pp = `${prefix}${pp}`;\n return pp;\n };\n\n const addItem = (item: string) => _errors.push(indentText(item, i));\n\n for (const issue of issues) {\n if (issue.code === \"invalid_union\") {\n addItem(`✖ Expected one of several possible values`);\n const path = formatSubpath(issue.path, \"\");\n addItem(` → at '${path}':`);\n for (const errGrp of issue.errors) {\n _errors.push(formatZodIssues(errGrp, `${i} `, [...p, ...issue.path]));\n }\n } else if (issue.code === \"invalid_element\" || issue.code === \"invalid_key\") {\n addItem(`✖ ${issue.code.replaceAll(\"_\", \" \")}:`);\n _errors.push(formatZodIssues(issue.issues, `${i} `, [...p, ...issue.path]));\n } else if (issue.code === \"invalid_type\") {\n const path = formatSubpath(issue.path, \" \");\n const prefix = `✖ (${issue.expected})${path}: `;\n const msg = indentText(issue.message, Math.min(prefix.length, 20), true);\n addItem(`${prefix}${msg}`);\n } else {\n const path = formatSubpath(issue.path, \" \");\n const prefix = `✖ (${issue.code.replaceAll(\"_\", \" \")})${path}: `;\n const msg = indentText(issue.message, Math.min(prefix.length, 20), true);\n addItem(`${prefix}${msg}`);\n }\n }\n\n return _errors.join(\"\\n\");\n};\n\n// User-facing CLI error. The top-level handler (bin/run.mjs) prints its\n// message without a stack trace and exits non-zero.\nexport class CLIErrorClass extends Error {\n constructor(msg: string | Error) {\n super(typeof msg === \"string\" ? msg : msg.message);\n this.name = \"CLIError\";\n }\n}\n\nexport function CLIError(msg: string | Error): CLIErrorClass {\n return new CLIErrorClass(msg);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,kBAAkB;AAC/B,MAAa,qBAAqB;AAElC,SAAgB,YAAY,IAAW;AACrC,OAAM,IAAI,MAAM,4CAA4C,KAAK,UAAU,GAAG,GAAG;;AAGnF,SAAgB,WAAW,KAAa,QAAwB;AAC9D,KAAI,IAAI,WAAW,OAAO,CACxB,QAAO,IAAI,MAAM,OAAO,OAAO;AAEjC,QAAO;;AAGT,SAAgB,WAAW,KAAa,QAAwB;AAC9D,KAAI,IAAI,SAAS,OAAO,CACtB,QAAO,IAAI,MAAM,GAAG,CAAC,OAAO,OAAO;AAErC,QAAO;;AAGT,SAAgB,gBAAgB,QAAgB,QAAqB;CACnE,MAAM,OAAO,SAAS,UAAA,GAAA,YAAA,YAAoB,SAAS;CACnD,MA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MAAM,SAAS,GAAG,KAAK;AAE5C,UAAQ,GAAG,SADC,WAAW,MAAM,SAAS,KAAK,IAAI,OAAO,QAAQ,GAAG,EAAE,KAAK,GAC9C;QACrB;EACL,MAAM,OAAO,cAAc,MAAM,MAAM,IAAI;EAC3C,MAAM,SAAS,MAAM,MAAM,KAAK,WAAW,KAAK,IAAI,CAAC,GAAG,KAAK;AAE7D,UAAQ,GAAG,SADC,WAAW,MAAM,SAAS,KAAK,IAAI,OAAO,QAAQ,GAAG,EAAE,KAAK,GAC9C;;AAI9B,QAAO,QAAQ,KAAK,KAAK;;AAK3B,IAAa,gBAAb,cAAmC,MAAM;CACvC,YAAY,KAAqB;AAC/B,QAAM,OAAO,QAAQ,WAAW,MAAM,IAAI,QAAQ;AAClD,OAAK,OAAO;;;AAIhB,SAAgB,SAAS,KAAoC;AAC3D,QAAO,IAAI,cAAc,IAAI"}
|
|
1
|
+
{"version":3,"file":"util.cjs","names":["fs","path","os"],"sources":["../../src/core/util.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as os from \"node:os\";\nimport fs from \"node:fs\";\nimport type { Hash } from \"node:crypto\";\nimport { createHash } from \"node:crypto\";\nimport winston from \"winston\";\nimport type { z } from \"zod/v4\";\nimport * as envs from \"./envs\";\n\nexport const packageJsonName = \"package.json\";\nexport const softwareConfigName = \"package.json\";\n\nexport function assertNever(_a: never): never {\n throw new Error(`code logic error: assertNever() call for ${JSON.stringify(_a)}`);\n}\n\nexport function trimPrefix(str: string, prefix: string): string {\n if (str.startsWith(prefix)) {\n return str.slice(prefix.length);\n }\n return str;\n}\n\nexport function trimSuffix(str: string, suffix: string): string {\n if (str.endsWith(suffix)) {\n return str.slice(0, -suffix.length);\n }\n return str;\n}\n\nexport function hashDirMetaSync(folder: string, hasher?: Hash): Hash {\n const hash = hasher ? hasher : createHash(\"sha256\");\n const info = fs.readdirSync(folder, { withFileTypes: true });\n\n for (const item of info) {\n const fullPath = path.join(folder, item.name);\n\n if (item.isFile()) {\n const statInfo = fs.statSync(fullPath);\n const fileInfo = `${fullPath}:${statInfo.size}:${statInfo.mtimeMs}`;\n hash.update(fileInfo);\n } else if (item.isDirectory()) {\n hashDirMetaSync(fullPath, hash);\n }\n }\n\n return hash;\n}\n\nexport function hashDirSync(rootDir: string, hasher?: Hash, subdir?: string): Hash {\n const hash = hasher ? hasher : createHash(\"sha256\");\n const folder = path.join(rootDir, subdir ?? \".\");\n\n // Sort for a host-independent hash: readdir enumeration order is not guaranteed.\n const info = fs\n .readdirSync(folder, { withFileTypes: true })\n .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n for (const item of info) {\n const relPath = path.join(subdir ?? \".\", item.name);\n const fullPath = path.join(folder, item.name);\n\n hash.update(relPath);\n\n if (item.isFile()) {\n const fileDescriptor = fs.openSync(fullPath, \"r\");\n const buffer = Buffer.alloc(65536);\n let bytesRead: number;\n\n while ((bytesRead = fs.readSync(fileDescriptor, buffer, 0, buffer.length, null)) !== 0) {\n hash.update(buffer.subarray(0, bytesRead));\n }\n\n fs.closeSync(fileDescriptor);\n } else if (item.isDirectory()) {\n // Keep rootDir fixed and pass the accumulated relPath so nested entries hash under their\n // full path from the root — otherwise `dirA/` + `file` collides with `dirA/file`.\n hashDirSync(rootDir, hash, relPath);\n }\n }\n\n return hash;\n}\n\n//\n// Creates all intermediate directories down to given <dirPath>.\n//\nexport function ensureDirsExist(dirPath: string) {\n if (fs.existsSync(dirPath)) {\n return;\n }\n const parentDir = path.dirname(dirPath);\n ensureDirsExist(parentDir);\n fs.mkdirSync(dirPath);\n}\n\nexport function findPackageRoot(logger: winston.Logger, startPath?: string): string {\n if (!startPath) {\n startPath = process.cwd();\n }\n logger.debug(`Detecting package root...`);\n const pkgRoot = searchPathUp(startPath, startPath, packageJsonName);\n logger.debug(` package root found at '${pkgRoot}'`);\n\n return pkgRoot;\n}\n\nexport function findNodeModules(logger: winston.Logger, startPath?: string): string {\n if (!startPath) {\n startPath = process.cwd();\n }\n logger.debug(`Detecting 'node_modules' directory...`);\n const nodeModules = searchPathUp(startPath, startPath, \"node_modules\");\n logger.debug(` 'node_modules' found at '${nodeModules}'`);\n\n return path.join(nodeModules, \"node_modules\");\n}\n\nexport function findInstalledModule(\n logger: winston.Logger,\n packageName: string,\n startPath?: string,\n): string {\n const nodeModules = findNodeModules(logger, startPath);\n const packagePath = path.resolve(nodeModules, packageName);\n\n if (!fs.existsSync(packagePath)) {\n throw CLIError(\n `package '${packageName}' not found in '${nodeModules}'. Did you forget to add it as a dependency?`,\n );\n }\n\n return packagePath;\n}\n\nfunction searchPathUp(startPath: string, pathToCheck: string, itemToCheck: string): string {\n const itemPath = path.resolve(pathToCheck, itemToCheck);\n\n if (fs.existsSync(itemPath)) {\n return pathToCheck;\n }\n\n const parentDir = path.dirname(pathToCheck);\n if (parentDir === pathToCheck || pathToCheck === \"\") {\n throw CLIError(\n `failed to find '${itemToCheck}' file in any of parent directories starting from '${startPath}'`,\n );\n }\n\n return searchPathUp(startPath, parentDir, itemToCheck);\n}\n\nexport function createLogger(level: string = \"debug\"): winston.Logger {\n if (envs.isCI() && envs.isRunnerDebug()) {\n level = \"debug\";\n }\n\n return winston.createLogger({\n level: level,\n\n format: winston.format.printf(({ level, message }) => {\n const indent = \" \".repeat(level.length + 2); // For ': ' after the level\n if (typeof message !== \"string\") {\n const messageJson = JSON.stringify(message);\n throw new Error(`logger message ${messageJson} is not a string`);\n }\n const indentedMessage = message\n .split(\"\\n\")\n .map((line: string, index: number) => (index === 0 ? line : indent + line))\n .join(\"\\n\");\n\n const colorize = (l: string) => winston.format.colorize().colorize(l, l);\n\n return `${colorize(level)}: ${indentedMessage}`;\n }),\n\n transports: [\n new winston.transports.Console({\n stderrLevels: [\"error\", \"warn\", \"info\", \"debug\"],\n handleExceptions: true,\n }),\n ],\n });\n}\n\nexport function rSplit(input: string, delimiter: string, limit?: number): string[] {\n const parts = input.split(delimiter);\n if (!limit || parts.length <= limit) {\n return parts;\n }\n\n return [parts.slice(0, -limit + 1).join(delimiter), ...parts.slice(-limit + 1)];\n}\n\nconst replaceDuplicateSlashes = new RegExp(\"//+\", \"g\");\nexport function urlJoin(url: string, appendPath: string): string {\n const u = new URL(url, \"file:/nonexistent-9672674c/\");\n if (u.protocol === \"file:\" && u.pathname.startsWith(\"/nonexistent-9672674c/\")) {\n throw new Error(`string '${url}' is not valid URL`);\n }\n\n u.pathname = u.pathname + \"/\" + appendPath;\n u.pathname = u.pathname.replaceAll(replaceDuplicateSlashes, \"/\");\n return u.toString();\n}\n\nexport function wrapErr(e: any, msg: string): any {\n if (!(e instanceof Error)) {\n return e;\n }\n\n const wrappedError = new Error(`${msg}: ${e.message}`);\n wrappedError.name = e.name;\n wrappedError.stack = e.stack;\n // Copy any additional custom properties\n Object.assign(wrappedError, e);\n return wrappedError;\n}\n\n/**\n * Converts any value to integer number 1 if value is truthful and 0 otherwice.\n * Provides simple way to count values that are defined in an object:\n * toInt(options.a) + toInt(options.b) + toInt(options.c) === 1\n * @param input: any\n * @returns number - '1' or '0'\n */\nexport function toInt(input: any): number {\n return input ? 1 : 0;\n}\n\nexport const OSes = [\"linux\", \"macosx\", \"windows\"] as const;\nexport type OSType = (typeof OSes)[number];\n\nexport function currentOS(): OSType {\n const platform = os.platform();\n switch (platform) {\n case \"darwin\":\n return \"macosx\";\n case \"linux\":\n return \"linux\";\n case \"win32\":\n return \"windows\";\n default:\n throw CLIError(\n `operating system '${platform}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` +\n JSON.stringify(OSes),\n );\n }\n}\n\nexport const Arches = [\"x64\", \"aarch64\"] as const;\nexport type ArchType = (typeof Arches)[number];\n\nexport function currentArch(): ArchType {\n const arch = os.arch();\n switch (arch) {\n case \"arm64\":\n return \"aarch64\";\n case \"x64\":\n return \"x64\";\n default:\n throw CLIError(\n `processor architecture '${arch}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` +\n JSON.stringify(Arches),\n );\n }\n}\n\n// Combinartions of OS and architecture, Platforma supports.\nexport const AllPlatforms: `${OSType}-${ArchType}`[] = [\n \"linux-x64\",\n \"linux-aarch64\",\n \"macosx-x64\",\n \"macosx-aarch64\",\n \"windows-x64\",\n] as const;\nexport type PlatformType = (typeof AllPlatforms)[number];\n\nexport function splitPlatform(platform: PlatformType): { os: OSType; arch: ArchType } {\n const parts = platform.split(\"-\");\n\n return {\n os: parts[0] as OSType,\n arch: parts[1] as ArchType,\n };\n}\n\nexport function joinPlatform(os: OSType, arch: ArchType): PlatformType {\n return `${os}-${arch}`;\n}\n\nexport function isPlatformSupported(os: OSType, arch: ArchType): boolean {\n return AllPlatforms.includes(`${os}-${arch}`);\n}\n\nexport function currentPlatform(): PlatformType {\n return `${currentOS()}-${currentArch()}`;\n}\n\nexport const AllSoftwareSources = [\"archive\", \"docker\"] as const; // add 'image', '<whatever>' here when supported\nexport type SoftwareSource = (typeof AllSoftwareSources)[number];\n\nexport type BuildMode = \"dev-local\" | \"dev-remote\" | \"release\";\n\nexport function isDevMode(mode: BuildMode): mode is \"dev-local\" | \"dev-remote\" {\n return mode === \"dev-local\" || mode === \"dev-remote\";\n}\n\nexport function producesRegistryDescriptor(mode: BuildMode): mode is \"dev-remote\" | \"release\" {\n return mode === \"dev-remote\" || mode === \"release\";\n}\n\n// Resolve a `--do`/`--no-do` (or PL_*_/PL_*_NO_ env) tri-state: explicit disable wins, then enable,\n// else the default.\nexport function shouldDoAction(opts: {\n default: boolean;\n enable?: boolean;\n disable?: boolean;\n}): boolean {\n if (opts.disable) return false;\n if (opts.enable) return true;\n return opts.default;\n}\n\nexport type artifactID = {\n package: string;\n name: string;\n};\n\nexport function artifactIDFromString(s: string): artifactID {\n const parts = s.split(\":\", 2);\n if (parts.length < 2) {\n throw CLIError(\n `string '${s}' is not an artifact ID (artifact ID format is <packageName>:<artifactName>)`,\n );\n }\n return {\n package: parts[0],\n name: parts[1],\n };\n}\n\nexport function artifactIDToString(a: artifactID): string {\n return `${a.package}:${a.name}`;\n}\n\nexport function indentText(txt: string, indent: string | number, skipFirstLine: boolean = false) {\n indent = typeof indent === \"number\" ? \" \".repeat(indent) : indent;\n\n return txt\n .split(\"\\n\")\n .map((line, index) => (index === 0 && skipFirstLine ? line : `${indent}${line}`))\n .join(\"\\n\");\n}\n\nexport const formatZodIssues = (\n issues: z.core.$ZodIssue[],\n i: string = \"\",\n p: PropertyKey[] = [],\n): string => {\n const _errors: string[] = [];\n\n const formatSubpath = (path: PropertyKey[], prefix: string = \"\") => {\n let pp = path.join(\".\");\n if (pp != \"\" && p.length > 0) pp = `.${pp}`;\n if (pp != \"\") pp = `${prefix}${pp}`;\n return pp;\n };\n\n const addItem = (item: string) => _errors.push(indentText(item, i));\n\n for (const issue of issues) {\n if (issue.code === \"invalid_union\") {\n addItem(`✖ Expected one of several possible values`);\n const path = formatSubpath(issue.path, \"\");\n addItem(` → at '${path}':`);\n for (const errGrp of issue.errors) {\n _errors.push(formatZodIssues(errGrp, `${i} `, [...p, ...issue.path]));\n }\n } else if (issue.code === \"invalid_element\" || issue.code === \"invalid_key\") {\n addItem(`✖ ${issue.code.replaceAll(\"_\", \" \")}:`);\n _errors.push(formatZodIssues(issue.issues, `${i} `, [...p, ...issue.path]));\n } else if (issue.code === \"invalid_type\") {\n const path = formatSubpath(issue.path, \" \");\n const prefix = `✖ (${issue.expected})${path}: `;\n const msg = indentText(issue.message, Math.min(prefix.length, 20), true);\n addItem(`${prefix}${msg}`);\n } else {\n const path = formatSubpath(issue.path, \" \");\n const prefix = `✖ (${issue.code.replaceAll(\"_\", \" \")})${path}: `;\n const msg = indentText(issue.message, Math.min(prefix.length, 20), true);\n addItem(`${prefix}${msg}`);\n }\n }\n\n return _errors.join(\"\\n\");\n};\n\n// User-facing CLI error. The top-level handler (bin/run.mjs) prints its\n// message without a stack trace and exits non-zero.\nexport class CLIErrorClass extends Error {\n constructor(msg: string | Error) {\n super(typeof msg === \"string\" ? msg : msg.message);\n this.name = \"CLIError\";\n }\n}\n\nexport function CLIError(msg: string | Error): CLIErrorClass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