@platforma-sdk/package-builder-lib 1.3.0 → 1.4.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/core.cjs +23 -0
- package/dist/core/core.cjs.map +1 -1
- package/dist/core/core.d.ts +22 -6
- package/dist/core/core.d.ts.map +1 -1
- package/dist/core/core.js +23 -0
- package/dist/core/core.js.map +1 -1
- package/dist/core/docker-coverage.cjs +56 -0
- package/dist/core/docker-coverage.cjs.map +1 -0
- package/dist/core/docker-coverage.d.ts +35 -0
- package/dist/core/docker-coverage.d.ts.map +1 -0
- package/dist/core/docker-coverage.js +53 -0
- package/dist/core/docker-coverage.js.map +1 -0
- package/dist/core/docker.cjs +2 -3
- package/dist/core/docker.cjs.map +1 -1
- package/dist/core/docker.js +2 -3
- package/dist/core/docker.js.map +1 -1
- package/dist/core/envs.d.ts +27 -27
- package/dist/core/envs.d.ts.map +1 -1
- package/dist/core/package-info.cjs +6 -1
- package/dist/core/package-info.cjs.map +1 -1
- package/dist/core/package-info.d.ts +6 -6
- package/dist/core/package-info.d.ts.map +1 -1
- package/dist/core/package-info.js +6 -1
- package/dist/core/package-info.js.map +1 -1
- package/dist/core/push-guard.d.ts +9 -6
- package/dist/core/push-guard.d.ts.map +1 -1
- package/dist/core/schemas/artifacts.d.ts +236 -71
- package/dist/core/schemas/artifacts.d.ts.map +1 -1
- package/dist/core/schemas/entrypoints.d.ts +357 -10
- package/dist/core/schemas/entrypoints.d.ts.map +1 -1
- package/dist/core/sw-json-render.cjs +18 -0
- package/dist/core/sw-json-render.cjs.map +1 -1
- package/dist/core/sw-json-render.js +18 -0
- package/dist/core/sw-json-render.js.map +1 -1
- package/dist/core/util.d.ts +42 -44
- package/dist/core/util.d.ts.map +1 -1
- package/dist/defaults.d.ts +22 -22
- package/dist/defaults.d.ts.map +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/core/__tests__/docker-build.test.ts +51 -0
- package/src/core/__tests__/docker-coverage.test.ts +319 -0
- package/src/core/core.ts +37 -0
- package/src/core/docker-coverage.ts +112 -0
- package/src/core/docker.ts +2 -7
- package/src/core/package-info.ts +11 -0
- package/src/core/sw-json-render.ts +25 -0
- package/src/index.ts +7 -0
|
@@ -1 +1 @@
|
|
|
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}artifact '${pkg.id}' ('${pkg.type}') is not '${type}'`);\n}\n"],"mappings":";;;;;;;;AAaA,IAAa,iBAAb,MAA4B;CAEhB;CACS;CAFnB,YACE,QACA,SACA;EAFQ,KAAA,SAAA;EACS,KAAA,UAAA;CAChB;CAEH,0BACE,MACA,aACA,SAIgC;EAChC,MAAM,yBAAS,IAAI,IAA+B;EAClD,IAAI,gBAAgB;EAEpB,MAAM,cAAc,SAAS,eAAe;EAE5C,KAAK,OAAO,KAAK,qCAAqC;EACtD,KAAK,OAAO,MAAM,oBAAoB,KAAK,UAAU,WAAW,CAAC;EAEjE,KAAK,MAAM,CAAC,QAAQ,OAAO,YAAY,QAAQ,GAAG;GAChD,IAAI,GAAG,SAAS,aAAa;IAE3B,gBAAgB;IAChB;GACF;GAEA,KAAK,OAAO,MAAM,oCAAoC,OAAO,KAAK;GAKlE,MAAM,eAAeA,uBAA8B,MAAM;GACzD,MAAM,OAAO,OAAO,IAAI,YAAY,IAChC,OAAO,IAAI,YAAY,IACvB,EACE,IAAI;IACF,SAAS,KAAK,QAAQ;IACtB,MAAM;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AO;EAC7B;CACF;AACF;AAEA,MAAa,yBAAyB;AACtC,MAAa,sBAAsB;AAkBnC,SAAgB,uBAAuB,UAAkB,SAA4B;CACnF,GAAG,UAAU,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CACxD,GAAG,cAAc,UAAU,KAAK,UAAU,OAAO,GAAG,EAAE,UAAU,OAAO,CAAC;AAC1E;AAEA,SAAgB,sBAAsB,UAAqC;CACzE,MAAM,OAAO,GAAG,aAAa,UAAU,MAAM;CAC7C,OAAO,KAAK,MAAM,IAAI;AACxB;AAEA,SAAS,yBACP,UACA,QACA,iBAC+B;CAC/B,IAAI,GAAG,WAAW,QAAQ,GACxB,OAAO,sBAAsB,QAAQ;CAGvC,IAAI,iBACF,MAAMV,SACJ,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,MAAMA,SAAc,GAAG,OAAO,YAAY,IAAI,GAAG,MAAM,IAAI,KAAK,aAAa,KAAK,EAAE;AACtF"}
|
|
1
|
+
{"version":3,"file":"sw-json-render.js","names":["docker.entrypointNameToOrigin","util.CLIError","util.isDevMode","util.producesRegistryDescriptor","defaults.NO_SOFTWARE_PLACEHOLDER","util.artifactIDToString","dockerCoverage.descriptorHasNoDockerVariant","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 dockerCoverage from \"./docker-coverage\";\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 if (epType === \"software\") this.warnIfNoDockerVariant(epName, srcFile);\n }\n\n /**\n * A reference re-exports another package's descriptor verbatim, so the docker-coverage\n * check cannot judge it from this package's declaration — and must not fail on it: the\n * owning package may have declared itself binary-only on purpose, and that waiver does\n * not travel inside the descriptor. Warn, naming what to fix and where.\n */\n private warnIfNoDockerVariant(epName: string, srcFile: string) {\n let descriptor: unknown;\n try {\n descriptor = JSON.parse(fs.readFileSync(srcFile, \"utf-8\"));\n } catch {\n return; // an unreadable descriptor is the copy's problem to report, not this warning's\n }\n\n if (!dockerCoverage.descriptorHasNoDockerVariant(descriptor)) return;\n\n this.logger.warn(\n `referenced entrypoint '${epName}' carries no docker image, so no kubernetes ` +\n `installation can run it. Fix it in the package that owns ${srcFile}.`,\n );\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"],"mappings":";;;;;;;;;AAcA,IAAa,iBAAb,MAA4B;CAEhB;CACS;CAFnB,YACE,QACA,SACA;EAFQ,KAAA,SAAA;EACS,KAAA,UAAA;CAChB;CAEH,0BACE,MACA,aACA,SAIgC;EAChC,MAAM,yBAAS,IAAI,IAA+B;EAClD,IAAI,gBAAgB;EAEpB,MAAM,cAAc,SAAS,eAAe;EAE5C,KAAK,OAAO,KAAK,qCAAqC;EACtD,KAAK,OAAO,MAAM,oBAAoB,KAAK,UAAU,WAAW,CAAC;EAEjE,KAAK,MAAM,CAAC,QAAQ,OAAO,YAAY,QAAQ,GAAG;GAChD,IAAI,GAAG,SAAS,aAAa;IAE3B,gBAAgB;IAChB;GACF;GAEA,KAAK,OAAO,MAAM,oCAAoC,OAAO,KAAK;GAKlE,MAAM,eAAeA,uBAA8B,MAAM;GACzD,MAAM,OAAO,OAAO,IAAI,YAAY,IAChC,OAAO,IAAI,YAAY,IACvB,EACE,IAAI;IACF,SAAS,KAAK,QAAQ;IACtB,MAAM;GACR,EACF;GACJ,IAAI,CAAC,MACH,MAAMC,SAAc,cAAc,OAAO,qBAAqB;GAGhE,IAAIC,UAAe,I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"winston";
|
|
4
|
-
|
|
5
|
-
//#region src/core/util.d.ts
|
|
6
4
|
declare namespace util_d_exports {
|
|
7
5
|
export { AllPlatforms, AllSoftwareSources, ArchType, Arches, BuildMode, CLIError, CLIErrorClass, OSType, OSes, PlatformType, SoftwareSource, artifactID, artifactIDFromString, artifactIDToString, assertNever, createLogger, currentArch, currentOS, currentPlatform, ensureDirsExist, findInstalledModule, findNodeModules, findPackageRoot, formatZodIssues, hashDirMetaSync, hashDirSync, indentText, isDevMode, isPlatformSupported, joinPlatform, packageJsonName, producesRegistryDescriptor, rSplit, shouldDoAction, softwareConfigName, splitPlatform, toInt, trimPrefix, trimSuffix, urlJoin, wrapErr };
|
|
8
6
|
}
|
|
9
|
-
declare const packageJsonName = "package.json";
|
|
10
|
-
declare const softwareConfigName = "package.json";
|
|
11
|
-
declare function assertNever(_a: never): never;
|
|
12
|
-
declare function trimPrefix(str: string, prefix: string): string;
|
|
13
|
-
declare function trimSuffix(str: string, suffix: string): string;
|
|
14
|
-
declare function hashDirMetaSync(folder: string, hasher?: Hash): Hash;
|
|
15
|
-
declare function hashDirSync(rootDir: string, hasher?: Hash, subdir?: string): Hash;
|
|
16
|
-
declare function ensureDirsExist(dirPath: string): void;
|
|
17
|
-
declare function findPackageRoot(logger: winston.Logger, startPath?: string): string;
|
|
18
|
-
declare function findNodeModules(logger: winston.Logger, startPath?: string): string;
|
|
19
|
-
declare function findInstalledModule(logger: winston.Logger, packageName: string, startPath?: string): string;
|
|
20
|
-
declare function createLogger(level?: string): winston.Logger;
|
|
21
|
-
declare function rSplit(input: string, delimiter: string, limit?: number): string[];
|
|
22
|
-
declare function urlJoin(url: string, appendPath: string): string;
|
|
23
|
-
declare function wrapErr(e: any, msg: string): any;
|
|
7
|
+
export declare const packageJsonName = "package.json";
|
|
8
|
+
export declare const softwareConfigName = "package.json";
|
|
9
|
+
export declare function assertNever(_a: never): never;
|
|
10
|
+
export declare function trimPrefix(str: string, prefix: string): string;
|
|
11
|
+
export declare function trimSuffix(str: string, suffix: string): string;
|
|
12
|
+
export declare function hashDirMetaSync(folder: string, hasher?: Hash): Hash;
|
|
13
|
+
export declare function hashDirSync(rootDir: string, hasher?: Hash, subdir?: string): Hash;
|
|
14
|
+
export declare function ensureDirsExist(dirPath: string): void;
|
|
15
|
+
export declare function findPackageRoot(logger: winston.Logger, startPath?: string): string;
|
|
16
|
+
export declare function findNodeModules(logger: winston.Logger, startPath?: string): string;
|
|
17
|
+
export declare function findInstalledModule(logger: winston.Logger, packageName: string, startPath?: string): string;
|
|
18
|
+
export declare function createLogger(level?: string): winston.Logger;
|
|
19
|
+
export declare function rSplit(input: string, delimiter: string, limit?: number): string[];
|
|
20
|
+
export declare function urlJoin(url: string, appendPath: string): string;
|
|
21
|
+
export declare function wrapErr(e: any, msg: string): any;
|
|
24
22
|
/**
|
|
25
23
|
* Converts any value to integer number 1 if value is truthful and 0 otherwice.
|
|
26
24
|
* Provides simple way to count values that are defined in an object:
|
|
@@ -28,44 +26,44 @@ declare function wrapErr(e: any, msg: string): any;
|
|
|
28
26
|
* @param input: any
|
|
29
27
|
* @returns number - '1' or '0'
|
|
30
28
|
*/
|
|
31
|
-
declare function toInt(input: any): number;
|
|
32
|
-
declare const OSes: readonly ["linux", "macosx", "windows"];
|
|
33
|
-
type OSType = (typeof OSes)[number];
|
|
34
|
-
declare function currentOS(): OSType;
|
|
35
|
-
declare const Arches: readonly ["x64", "aarch64"];
|
|
36
|
-
type ArchType = (typeof Arches)[number];
|
|
37
|
-
declare function currentArch(): ArchType;
|
|
38
|
-
declare const AllPlatforms: `${OSType}-${ArchType}`[];
|
|
39
|
-
type PlatformType = (typeof AllPlatforms)[number];
|
|
40
|
-
declare function splitPlatform(platform: PlatformType): {
|
|
29
|
+
export declare function toInt(input: any): number;
|
|
30
|
+
export declare const OSes: readonly ["linux", "macosx", "windows"];
|
|
31
|
+
export type OSType = (typeof OSes)[number];
|
|
32
|
+
export declare function currentOS(): OSType;
|
|
33
|
+
export declare const Arches: readonly ["x64", "aarch64"];
|
|
34
|
+
export type ArchType = (typeof Arches)[number];
|
|
35
|
+
export declare function currentArch(): ArchType;
|
|
36
|
+
export declare const AllPlatforms: `${OSType}-${ArchType}`[];
|
|
37
|
+
export type PlatformType = (typeof AllPlatforms)[number];
|
|
38
|
+
export declare function splitPlatform(platform: PlatformType): {
|
|
41
39
|
os: OSType;
|
|
42
40
|
arch: ArchType;
|
|
43
41
|
};
|
|
44
|
-
declare function joinPlatform(os: OSType, arch: ArchType): PlatformType;
|
|
45
|
-
declare function isPlatformSupported(os: OSType, arch: ArchType): boolean;
|
|
46
|
-
declare function currentPlatform(): PlatformType;
|
|
47
|
-
declare const AllSoftwareSources: readonly ["archive", "docker"];
|
|
48
|
-
type SoftwareSource = (typeof AllSoftwareSources)[number];
|
|
49
|
-
type BuildMode = "dev-local" | "dev-remote" | "release";
|
|
50
|
-
declare function isDevMode(mode: BuildMode): mode is "dev-local" | "dev-remote";
|
|
51
|
-
declare function producesRegistryDescriptor(mode: BuildMode): mode is "dev-remote" | "release";
|
|
52
|
-
declare function shouldDoAction(opts: {
|
|
42
|
+
export declare function joinPlatform(os: OSType, arch: ArchType): PlatformType;
|
|
43
|
+
export declare function isPlatformSupported(os: OSType, arch: ArchType): boolean;
|
|
44
|
+
export declare function currentPlatform(): PlatformType;
|
|
45
|
+
export declare const AllSoftwareSources: readonly ["archive", "docker"];
|
|
46
|
+
export type SoftwareSource = (typeof AllSoftwareSources)[number];
|
|
47
|
+
export type BuildMode = "dev-local" | "dev-remote" | "release";
|
|
48
|
+
export declare function isDevMode(mode: BuildMode): mode is "dev-local" | "dev-remote";
|
|
49
|
+
export declare function producesRegistryDescriptor(mode: BuildMode): mode is "dev-remote" | "release";
|
|
50
|
+
export declare function shouldDoAction(opts: {
|
|
53
51
|
default: boolean;
|
|
54
52
|
enable?: boolean;
|
|
55
53
|
disable?: boolean;
|
|
56
54
|
}): boolean;
|
|
57
|
-
type artifactID = {
|
|
55
|
+
export type artifactID = {
|
|
58
56
|
package: string;
|
|
59
57
|
name: string;
|
|
60
58
|
};
|
|
61
|
-
declare function artifactIDFromString(s: string): artifactID;
|
|
62
|
-
declare function artifactIDToString(a: artifactID): string;
|
|
63
|
-
declare function indentText(txt: string, indent: string | number, skipFirstLine?: boolean): string;
|
|
64
|
-
declare const formatZodIssues: (issues: z.core.$ZodIssue[], i?: string, p?: PropertyKey[]) => string;
|
|
65
|
-
declare class CLIErrorClass extends Error {
|
|
59
|
+
export declare function artifactIDFromString(s: string): artifactID;
|
|
60
|
+
export declare function artifactIDToString(a: artifactID): string;
|
|
61
|
+
export declare function indentText(txt: string, indent: string | number, skipFirstLine?: boolean): string;
|
|
62
|
+
export declare const formatZodIssues: (issues: z.core.$ZodIssue[], i?: string, p?: PropertyKey[]) => string;
|
|
63
|
+
export declare class CLIErrorClass extends Error {
|
|
66
64
|
constructor(msg: string | Error);
|
|
67
65
|
}
|
|
68
|
-
declare function CLIError(msg: string | Error): CLIErrorClass;
|
|
66
|
+
export declare function CLIError(msg: string | Error): CLIErrorClass;
|
|
69
67
|
//#endregion
|
|
70
|
-
export {
|
|
68
|
+
export { util_d_exports };
|
|
71
69
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/core/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","names":[],"sources":["../../src/core/util.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","names":[],"sources":["../../src/core/util.ts"],"mappings":";;;;;;qBASa;qBACA;wBAEG,YAAY;wBAIZ,WAAW,aAAa;wBAOxB,WAAW,aAAa;wBAOxB,gBAAgB,gBAAgB,SAAS,OAAO;wBAmBhD,YAAY,iBAAiB,SAAS,MAAM,kBAAkB;wBAsC9D,gBAAgB;wBAShB,gBAAgB,QAAQ,QAAQ,QAAQ;wBAWxC,gBAAgB,QAAQ,QAAQ,QAAQ;wBAWxC,oBACd,QAAQ,QAAQ,QAChB,qBACA;wBA+Bc,aAAa,iBAA0B,QAAQ;wBAiC/C,OAAO,eAAe,mBAAmB;wBAUzC,QAAQ,aAAa;wBAWrB,QAAQ,QAAQ;;;;;;;;wBAoBhB,MAAM;qBAIT;YACD,iBAAiB;wBAEb,aAAa;qBAiBhB;YACD,mBAAmB;wBAEf,eAAe;qBAgBlB,iBAAiB,UAAU;YAO5B,uBAAuB;wBAEnB,cAAc,UAAU;EAAiB,IAAI;EAAQ,MAAM;;wBAS3D,aAAa,IAAI,QAAQ,MAAM,WAAW;wBAI1C,oBAAoB,IAAI,QAAQ,MAAM;wBAItC,mBAAmB;qBAItB;YACD,yBAAyB;YAEzB;wBAEI,UAAU,MAAM,YAAY;wBAI5B,2BAA2B,MAAM,YAAY;wBAM7C,eAAe;EAC7B;EACA;EACA;;YAOU;EACV;EACA;;wBAGc,qBAAqB,YAAY;wBAajC,mBAAmB,GAAG;wBAItB,WAAW,aAAa,yBAAyB;qBASpD,kBAAe,QAClB,EAAE,KAAK,aAAW,YACjB,IACN;qBA0CQ,sBAAsB;EACjC,YAAY,cAAc;;wBAMZ,SAAS,cAAc,QAAQ"}
|
package/dist/defaults.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
declare namespace defaults_d_exports {
|
|
2
2
|
export { AWS_DEV_PROFILE, BIN_REGISTRY_DOWNLOAD_URL, BIN_REGISTRY_NAME, CONDA_DATA_LOCATION, CONDA_DOCKER_BASE_IMAGE, CONDA_FROZEN_ENV_SPEC_FILE, CONDA_MICROMAMBA_VERSION, CONDA_SOURCE_ENV_SPEC_FILE, DEV_BINARY_UPLOAD_TARGET, DEV_BIN_REGISTRY_NAME, DEV_BIN_REGISTRY_NAME_OVERRIDDEN, DEV_DOCKER_PUSH_TARGET, DEV_DOCKER_REGISTRY, DOCKER_BUILD_PLATFORM, DOCKER_DOCKERFILE, DOCKER_PLACEHOLDER_PKG, DOCKER_REGISTRY, NO_SOFTWARE_PLACEHOLDER, PYTHON_DOCKER_BASE_IMAGE, PYTHON_REQUIREMENTS_FILE, PYTHON_TOOLSET };
|
|
3
3
|
}
|
|
4
|
-
declare const BIN_REGISTRY_NAME = "platforma-open";
|
|
5
|
-
declare const BIN_REGISTRY_DOWNLOAD_URL = "https://bin.pl-open.science/";
|
|
6
|
-
declare const DEV_BIN_REGISTRY_NAME = "midev";
|
|
7
|
-
declare const DEV_BIN_REGISTRY_NAME_OVERRIDDEN = "dev";
|
|
8
|
-
declare const DEV_BINARY_UPLOAD_TARGET = "s3://milab-midev-registry?region=eu-central-1";
|
|
9
|
-
declare const PYTHON_TOOLSET = "pip";
|
|
10
|
-
declare const PYTHON_REQUIREMENTS_FILE = "requirements.txt";
|
|
11
|
-
declare const PYTHON_DOCKER_BASE_IMAGE = "python:3.12-slim";
|
|
12
|
-
declare const CONDA_MICROMAMBA_VERSION = "2.3.2-0";
|
|
13
|
-
declare const CONDA_SOURCE_ENV_SPEC_FILE = "conda-spec.yaml";
|
|
14
|
-
declare const CONDA_FROZEN_ENV_SPEC_FILE = "frozen-spec.yaml";
|
|
15
|
-
declare const CONDA_DATA_LOCATION = "conda-env-data";
|
|
16
|
-
declare const CONDA_DOCKER_BASE_IMAGE = "ubuntu:22.04";
|
|
17
|
-
declare const DOCKER_REGISTRY = "containers.pl-open.science/milaboratories/pl-containers";
|
|
18
|
-
declare const DOCKER_DOCKERFILE = "Dockerfile";
|
|
19
|
-
declare const DOCKER_PLACEHOLDER_PKG = "/app";
|
|
20
|
-
declare const NO_SOFTWARE_PLACEHOLDER = "no-software-placeholder";
|
|
21
|
-
declare const DEV_DOCKER_REGISTRY = "public.ecr.aws/miresearch/pl-containers";
|
|
22
|
-
declare const DEV_DOCKER_PUSH_TARGET = "ecr://public.ecr.aws/miresearch/pl-containers";
|
|
23
|
-
declare const AWS_DEV_PROFILE = "research-poweruser";
|
|
24
|
-
declare const DOCKER_BUILD_PLATFORM = "linux/amd64";
|
|
4
|
+
export declare const BIN_REGISTRY_NAME = "platforma-open";
|
|
5
|
+
export declare const BIN_REGISTRY_DOWNLOAD_URL = "https://bin.pl-open.science/";
|
|
6
|
+
export declare const DEV_BIN_REGISTRY_NAME = "midev";
|
|
7
|
+
export declare const DEV_BIN_REGISTRY_NAME_OVERRIDDEN = "dev";
|
|
8
|
+
export declare const DEV_BINARY_UPLOAD_TARGET = "s3://milab-midev-registry?region=eu-central-1";
|
|
9
|
+
export declare const PYTHON_TOOLSET = "pip";
|
|
10
|
+
export declare const PYTHON_REQUIREMENTS_FILE = "requirements.txt";
|
|
11
|
+
export declare const PYTHON_DOCKER_BASE_IMAGE = "python:3.12-slim";
|
|
12
|
+
export declare const CONDA_MICROMAMBA_VERSION = "2.3.2-0";
|
|
13
|
+
export declare const CONDA_SOURCE_ENV_SPEC_FILE = "conda-spec.yaml";
|
|
14
|
+
export declare const CONDA_FROZEN_ENV_SPEC_FILE = "frozen-spec.yaml";
|
|
15
|
+
export declare const CONDA_DATA_LOCATION = "conda-env-data";
|
|
16
|
+
export declare const CONDA_DOCKER_BASE_IMAGE = "ubuntu:22.04";
|
|
17
|
+
export declare const DOCKER_REGISTRY = "containers.pl-open.science/milaboratories/pl-containers";
|
|
18
|
+
export declare const DOCKER_DOCKERFILE = "Dockerfile";
|
|
19
|
+
export declare const DOCKER_PLACEHOLDER_PKG = "/app";
|
|
20
|
+
export declare const NO_SOFTWARE_PLACEHOLDER = "no-software-placeholder";
|
|
21
|
+
export declare const DEV_DOCKER_REGISTRY = "public.ecr.aws/miresearch/pl-containers";
|
|
22
|
+
export declare const DEV_DOCKER_PUSH_TARGET = "ecr://public.ecr.aws/miresearch/pl-containers";
|
|
23
|
+
export declare const AWS_DEV_PROFILE = "research-poweruser";
|
|
24
|
+
export declare const DOCKER_BUILD_PLATFORM = "linux/amd64";
|
|
25
25
|
//#endregion
|
|
26
|
-
export {
|
|
26
|
+
export { defaults_d_exports };
|
|
27
27
|
//# sourceMappingURL=defaults.d.ts.map
|
package/dist/defaults.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAOa;qBACA;qBAGA;qBACA;qBAIA;qBAGA;qBACA;qBAEA;qBAGA;qBACA;qBACA;qBACA;qBAEA;qBAGA;qBACA;qBACA;qBAIA;qBAIA;qBAGA;qBAGA;qBAMA"}
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_defaults = require("./defaults.cjs");
|
|
3
3
|
const require_envs = require("./core/envs.cjs");
|
|
4
4
|
const require_util = require("./core/util.cjs");
|
|
5
|
+
const require_docker_coverage = require("./core/docker-coverage.cjs");
|
|
5
6
|
const require_core = require("./core/core.cjs");
|
|
6
7
|
const require_push_guard = require("./core/push-guard.cjs");
|
|
7
8
|
//#region src/index.ts
|
|
@@ -9,6 +10,7 @@ function createBuilder(logger, opts) {
|
|
|
9
10
|
return new require_core.Core(logger, opts);
|
|
10
11
|
}
|
|
11
12
|
//#endregion
|
|
13
|
+
exports.assertDockerCoverage = require_docker_coverage.assertDockerCoverage;
|
|
12
14
|
exports.assertDockerPushIntent = require_push_guard.assertDockerPushIntent;
|
|
13
15
|
exports.createBuilder = createBuilder;
|
|
14
16
|
Object.defineProperty(exports, "defaults", {
|
|
@@ -17,12 +19,14 @@ Object.defineProperty(exports, "defaults", {
|
|
|
17
19
|
return require_defaults.defaults_exports;
|
|
18
20
|
}
|
|
19
21
|
});
|
|
22
|
+
exports.descriptorHasNoDockerVariant = require_docker_coverage.descriptorHasNoDockerVariant;
|
|
20
23
|
Object.defineProperty(exports, "envs", {
|
|
21
24
|
enumerable: true,
|
|
22
25
|
get: function() {
|
|
23
26
|
return require_envs.envs_exports;
|
|
24
27
|
}
|
|
25
28
|
});
|
|
29
|
+
exports.softwareEntrypointsWithoutDocker = require_docker_coverage.softwareEntrypointsWithoutDocker;
|
|
26
30
|
Object.defineProperty(exports, "util", {
|
|
27
31
|
enumerable: true,
|
|
28
32
|
get: function() {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Core"],"sources":["../src/index.ts"],"sourcesContent":["import type winston from \"winston\";\nimport { Core } from \"./core/core\";\n\nexport * as util from \"./core/util\";\nexport * as envs from \"./core/envs\";\nexport * as defaults from \"./defaults\";\nexport { assertDockerPushIntent, type PushIntent } from \"./core/push-guard\";\n\n/** The logger the engine and its callers pass around. */\nexport type Logger = winston.Logger;\n\n/**\n * Public surface of the build engine. Derived from `Core` so signatures never\n * drift, while the `Core` class itself stays internal (per A-0023: the engine is\n * a library, not a half-binary with an exported orchestrator class). Consumers\n * (`pl-pkg`, and later `block-tools software`) wrap this, they do not subclass it.\n */\nexport type Builder = Pick<\n Core,\n | \"buildMode\"\n | \"targetPlatform\"\n | \"allPlatforms\"\n | \"fullDirHash\"\n | \"version\"\n | \"isPrivate\"\n | \"selectedDockerPackages\"\n | \"buildDockerImages\"\n | \"buildSoftwareArchives\"\n | \"buildSwJsonFiles\"\n | \"writePublishedArtifactInfo\"\n | \"publishPackages\"\n | \"publishDockerImages\"\n>;\n\nexport function createBuilder(logger: winston.Logger, opts?: { packageRoot?: string }): Builder {\n return new Core(logger, opts);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Core"],"sources":["../src/index.ts"],"sourcesContent":["import type winston from \"winston\";\nimport { Core } from \"./core/core\";\n\nexport * as util from \"./core/util\";\nexport * as envs from \"./core/envs\";\nexport * as defaults from \"./defaults\";\nexport { assertDockerPushIntent, type PushIntent } from \"./core/push-guard\";\nexport {\n assertDockerCoverage,\n softwareEntrypointsWithoutDocker,\n descriptorHasNoDockerVariant,\n type DockerCoverage,\n} from \"./core/docker-coverage\";\n\n/** The logger the engine and its callers pass around. */\nexport type Logger = winston.Logger;\n\n/**\n * Public surface of the build engine. Derived from `Core` so signatures never\n * drift, while the `Core` class itself stays internal (per A-0023: the engine is\n * a library, not a half-binary with an exported orchestrator class). Consumers\n * (`pl-pkg`, and later `block-tools software`) wrap this, they do not subclass it.\n */\nexport type Builder = Pick<\n Core,\n | \"buildMode\"\n | \"targetPlatform\"\n | \"allPlatforms\"\n | \"fullDirHash\"\n | \"version\"\n | \"isPrivate\"\n | \"selectedDockerPackages\"\n | \"assertDockerCoverage\"\n | \"buildDockerImages\"\n | \"buildSoftwareArchives\"\n | \"buildSwJsonFiles\"\n | \"writePublishedArtifactInfo\"\n | \"publishPackages\"\n | \"publishDockerImages\"\n>;\n\nexport function createBuilder(logger: winston.Logger, opts?: { packageRoot?: string }): Builder {\n return new Core(logger, opts);\n}\n"],"mappings":";;;;;;;;AAyCA,SAAgB,cAAc,QAAwB,MAA0C;CAC9F,OAAO,IAAIA,aAAAA,KAAK,QAAQ,IAAI;AAC9B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,21 +3,21 @@ import { Core } from "./core/core.js";
|
|
|
3
3
|
import { envs_d_exports } from "./core/envs.js";
|
|
4
4
|
import { defaults_d_exports } from "./defaults.js";
|
|
5
5
|
import { PushIntent, assertDockerPushIntent } from "./core/push-guard.js";
|
|
6
|
+
import { DockerCoverage, assertDockerCoverage, descriptorHasNoDockerVariant, softwareEntrypointsWithoutDocker } from "./core/docker-coverage.js";
|
|
6
7
|
import winston from "winston";
|
|
7
|
-
|
|
8
8
|
//#region src/index.d.ts
|
|
9
9
|
/** The logger the engine and its callers pass around. */
|
|
10
|
-
type Logger = winston.Logger;
|
|
10
|
+
export type Logger = winston.Logger;
|
|
11
11
|
/**
|
|
12
12
|
* Public surface of the build engine. Derived from `Core` so signatures never
|
|
13
13
|
* drift, while the `Core` class itself stays internal (per A-0023: the engine is
|
|
14
14
|
* a library, not a half-binary with an exported orchestrator class). Consumers
|
|
15
15
|
* (`pl-pkg`, and later `block-tools software`) wrap this, they do not subclass it.
|
|
16
16
|
*/
|
|
17
|
-
type Builder = Pick<Core, "buildMode" | "targetPlatform" | "allPlatforms" | "fullDirHash" | "version" | "isPrivate" | "selectedDockerPackages" | "buildDockerImages" | "buildSoftwareArchives" | "buildSwJsonFiles" | "writePublishedArtifactInfo" | "publishPackages" | "publishDockerImages">;
|
|
18
|
-
declare function createBuilder(logger: winston.Logger, opts?: {
|
|
17
|
+
export type Builder = Pick<Core, "buildMode" | "targetPlatform" | "allPlatforms" | "fullDirHash" | "version" | "isPrivate" | "selectedDockerPackages" | "assertDockerCoverage" | "buildDockerImages" | "buildSoftwareArchives" | "buildSwJsonFiles" | "writePublishedArtifactInfo" | "publishPackages" | "publishDockerImages">;
|
|
18
|
+
export declare function createBuilder(logger: winston.Logger, opts?: {
|
|
19
19
|
packageRoot?: string;
|
|
20
20
|
}): Builder;
|
|
21
21
|
//#endregion
|
|
22
|
-
export {
|
|
22
|
+
export { type DockerCoverage, type PushIntent, assertDockerCoverage, assertDockerPushIntent, defaults_d_exports as defaults, descriptorHasNoDockerVariant, envs_d_exports as envs, softwareEntrypointsWithoutDocker, util_d_exports as util };
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;YAeY,SAAS,QAAQ;;;;;;;YAQjB,UAAU,KACpB;wBAiBc,cAAc,QAAQ,QAAQ,QAAQ;EAAS;IAAyB"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defaults_exports } from "./defaults.js";
|
|
2
2
|
import { envs_exports } from "./core/envs.js";
|
|
3
3
|
import { util_exports } from "./core/util.js";
|
|
4
|
+
import { assertDockerCoverage, descriptorHasNoDockerVariant, softwareEntrypointsWithoutDocker } from "./core/docker-coverage.js";
|
|
4
5
|
import { Core } from "./core/core.js";
|
|
5
6
|
import { assertDockerPushIntent } from "./core/push-guard.js";
|
|
6
7
|
//#region src/index.ts
|
|
@@ -8,6 +9,6 @@ function createBuilder(logger, opts) {
|
|
|
8
9
|
return new Core(logger, opts);
|
|
9
10
|
}
|
|
10
11
|
//#endregion
|
|
11
|
-
export { assertDockerPushIntent, createBuilder, defaults_exports as defaults, envs_exports as envs, util_exports as util };
|
|
12
|
+
export { assertDockerCoverage, assertDockerPushIntent, createBuilder, defaults_exports as defaults, descriptorHasNoDockerVariant, envs_exports as envs, softwareEntrypointsWithoutDocker, util_exports as util };
|
|
12
13
|
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type winston from \"winston\";\nimport { Core } from \"./core/core\";\n\nexport * as util from \"./core/util\";\nexport * as envs from \"./core/envs\";\nexport * as defaults from \"./defaults\";\nexport { assertDockerPushIntent, type PushIntent } from \"./core/push-guard\";\n\n/** The logger the engine and its callers pass around. */\nexport type Logger = winston.Logger;\n\n/**\n * Public surface of the build engine. Derived from `Core` so signatures never\n * drift, while the `Core` class itself stays internal (per A-0023: the engine is\n * a library, not a half-binary with an exported orchestrator class). Consumers\n * (`pl-pkg`, and later `block-tools software`) wrap this, they do not subclass it.\n */\nexport type Builder = Pick<\n Core,\n | \"buildMode\"\n | \"targetPlatform\"\n | \"allPlatforms\"\n | \"fullDirHash\"\n | \"version\"\n | \"isPrivate\"\n | \"selectedDockerPackages\"\n | \"buildDockerImages\"\n | \"buildSoftwareArchives\"\n | \"buildSwJsonFiles\"\n | \"writePublishedArtifactInfo\"\n | \"publishPackages\"\n | \"publishDockerImages\"\n>;\n\nexport function createBuilder(logger: winston.Logger, opts?: { packageRoot?: string }): Builder {\n return new Core(logger, opts);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type winston from \"winston\";\nimport { Core } from \"./core/core\";\n\nexport * as util from \"./core/util\";\nexport * as envs from \"./core/envs\";\nexport * as defaults from \"./defaults\";\nexport { assertDockerPushIntent, type PushIntent } from \"./core/push-guard\";\nexport {\n assertDockerCoverage,\n softwareEntrypointsWithoutDocker,\n descriptorHasNoDockerVariant,\n type DockerCoverage,\n} from \"./core/docker-coverage\";\n\n/** The logger the engine and its callers pass around. */\nexport type Logger = winston.Logger;\n\n/**\n * Public surface of the build engine. Derived from `Core` so signatures never\n * drift, while the `Core` class itself stays internal (per A-0023: the engine is\n * a library, not a half-binary with an exported orchestrator class). Consumers\n * (`pl-pkg`, and later `block-tools software`) wrap this, they do not subclass it.\n */\nexport type Builder = Pick<\n Core,\n | \"buildMode\"\n | \"targetPlatform\"\n | \"allPlatforms\"\n | \"fullDirHash\"\n | \"version\"\n | \"isPrivate\"\n | \"selectedDockerPackages\"\n | \"assertDockerCoverage\"\n | \"buildDockerImages\"\n | \"buildSoftwareArchives\"\n | \"buildSwJsonFiles\"\n | \"writePublishedArtifactInfo\"\n | \"publishPackages\"\n | \"publishDockerImages\"\n>;\n\nexport function createBuilder(logger: winston.Logger, opts?: { packageRoot?: string }): Builder {\n return new Core(logger, opts);\n}\n"],"mappings":";;;;;;;AAyCA,SAAgB,cAAc,QAAwB,MAA0C;CAC9F,OAAO,IAAI,KAAK,QAAQ,IAAI;AAC9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/package-builder-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "MiLaboratories Platforma Package builder engine (library)",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"@milaboratories/resolve-helper": "1.1.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@platforma-open/milaboratories.runenv-python-3": "1.
|
|
34
|
+
"@platforma-open/milaboratories.runenv-python-3": "1.13.2",
|
|
35
35
|
"@types/archiver": "^6.0.3",
|
|
36
36
|
"@types/node": "~24.5.2",
|
|
37
37
|
"@vitest/coverage-istanbul": "^4.1.3",
|
|
38
|
-
"typescript": "
|
|
38
|
+
"typescript": "7.0.2",
|
|
39
39
|
"vite": "^8.0.6",
|
|
40
40
|
"vitest": "^4.1.3",
|
|
41
|
-
"@milaboratories/
|
|
41
|
+
"@milaboratories/build-configs": "2.0.2",
|
|
42
42
|
"@milaboratories/ts-configs": "1.4.0",
|
|
43
|
-
"@milaboratories/
|
|
43
|
+
"@milaboratories/ts-builder": "1.7.2"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "ts-builder build --target node",
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
const { spawnMock } = vi.hoisted(() => ({ spawnMock: vi.fn() }));
|
|
4
|
+
vi.mock("node:child_process", () => ({ spawnSync: spawnMock }));
|
|
5
|
+
|
|
6
|
+
const docker = await import("../docker");
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
vi.clearAllMocks();
|
|
10
|
+
vi.unstubAllEnvs();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function runBuild() {
|
|
14
|
+
spawnMock.mockReturnValue({ status: 0 });
|
|
15
|
+
docker.build("/ctx", "/ctx/Dockerfile", "local:tag", "pkg/main", "1.0.0");
|
|
16
|
+
expect(spawnMock).toHaveBeenCalledTimes(1);
|
|
17
|
+
const [cmd, args, opts] = spawnMock.mock.calls[0] as [
|
|
18
|
+
string,
|
|
19
|
+
string[],
|
|
20
|
+
{ env: NodeJS.ProcessEnv },
|
|
21
|
+
];
|
|
22
|
+
return { cmd, args, env: opts.env };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe("docker.build", () => {
|
|
26
|
+
it("passes no buildx-only attestation flags, so podman accepts the command", () => {
|
|
27
|
+
const { cmd, args } = runBuild();
|
|
28
|
+
expect(cmd).toBe("docker");
|
|
29
|
+
expect(args[0]).toBe("build");
|
|
30
|
+
expect(args.some((a) => a.startsWith("--provenance") || a.startsWith("--sbom"))).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("disables buildx default attestations through the environment", () => {
|
|
34
|
+
const { env } = runBuild();
|
|
35
|
+
expect(env.BUILDX_NO_DEFAULT_ATTESTATIONS).toBe("1");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("overrides a user value that would enable default attestations", () => {
|
|
39
|
+
vi.stubEnv("BUILDX_NO_DEFAULT_ATTESTATIONS", "0");
|
|
40
|
+
const { env } = runBuild();
|
|
41
|
+
expect(env.BUILDX_NO_DEFAULT_ATTESTATIONS).toBe("1");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("pins the build platform", () => {
|
|
45
|
+
const { args } = runBuild();
|
|
46
|
+
expect(args.slice(args.indexOf("--platform"), args.indexOf("--platform") + 2)).toEqual([
|
|
47
|
+
"--platform",
|
|
48
|
+
"linux/amd64",
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
});
|