@platforma-sdk/block-tools 2.17.8 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +8 -8
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +426 -420
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-C07cYptA.mjs → config-BusBoNIz.mjs} +495 -586
- package/dist/config-BusBoNIz.mjs.map +1 -0
- package/dist/config-DG4SQFXv.js +2 -0
- package/dist/config-DG4SQFXv.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -15
- package/dist/index.mjs.map +1 -1
- package/dist/io/storage.d.ts +1 -28
- package/dist/structure/rules/root-package-json.d.ts +1 -0
- package/dist/structure/rules/root-pnpm-workspace.d.ts +1 -0
- package/package.json +2 -3
- package/src/cmd/structure/refresh.ts +2 -2
- package/src/io/folder_reader.test.ts +18 -0
- package/src/io/folder_reader.ts +6 -0
- package/src/io/storage.ts +8 -147
- package/src/structure/__tests__/toolchain.test.ts +24 -14
- package/src/structure/rules/root-catalog-bump.ts +17 -0
- package/src/structure/rules/root-package-json.ts +5 -1
- package/src/structure/rules/root-pnpm-workspace.ts +6 -2
- package/src/structure/rules/shared/toolchain.ts +0 -2
- package/dist/config-C07cYptA.mjs.map +0 -1
- package/dist/config-on5N57rI.js +0 -3
- package/dist/config-on5N57rI.js.map +0 -1
- package/src/io/storage.test.ts +0 -96
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config-DG4SQFXv.js");let t=require("@platforma-sdk/package-builder-lib");var n=e.qt({GlobalOverviewPath:()=>e.r,MetaFile:()=>e.i,PlPackageConfigData:()=>e.c,PlPackageJsonConfigFile:()=>e.l,PlPackageYamlConfigFile:()=>e.u,PlRegCommonConfigData:()=>e.d,PlRegFullPackageConfigData:()=>e.f,PlRegPackageConfig:()=>e.t,PlRegPackageConfigDataShard:()=>e.p,packageContentPrefix:()=>e.a,packageOverviewPath:()=>e.o,payloadFilePath:()=>e.s});exports.BlockDescriptionPackageJsonField=e.ft,exports.BlockPackFolderName=e.pt,exports.BlockRegistryV2=e.x,exports.ChannelNameRegexp=e.S,exports.ChannelsFolder=e.C,Object.defineProperty(exports,"FSStorage",{enumerable:!0,get:function(){return t.FSStorage}}),Object.defineProperty(exports,"GcsStorage",{enumerable:!0,get:function(){return t.GcsStorage}}),exports.GlobalOverviewFileName=e.w,exports.GlobalOverviewGzFileName=e.T,exports.GlobalOverviewGzPath=e.E,exports.GlobalOverviewPath=e.D,exports.KindImplementer=e.$,exports.KindManifest=e.et,exports.KindManifestFile=e.yt,exports.KindManifestFileInfo=e.tt,exports.KindManifestFileName=e.nt,exports.KindManifestIdentity=e.rt,exports.KindOverview=e.it,exports.KindOverviewFileName=e.at,exports.KindOverviewPathPattern=e.ot,exports.KindResolutionError=e._,exports.KindVersionMismatchError=e.J,exports.KindVersionOverview=e.st,exports.KindsPrefix=e.ct,exports.MainPrefix=e.O,exports.ManifestFileName=e.k,exports.ManifestSuffix=e.A,exports.PackageManifestPattern=e.j,exports.PackageOverview=e.M,exports.PackageOverviewFileName=e.N,exports.PackageOverviewVersionEntry=e.P,exports.PublishedCoordsFileName=e.U,Object.defineProperty(exports,"RegistryV1",{enumerable:!0,get:function(){return n}}),exports.RegistryV2Reader=e.h,Object.defineProperty(exports,"S3Storage",{enumerable:!0,get:function(){return t.S3Storage}}),exports.absoluteToBase64=e.Ft,exports.absoluteToBytes=e.It,exports.absoluteToString=e.Lt,exports.addRelativePathPrefix=e.St,exports.blockComponentsManifestToAbsoluteUrl=e.Tt,exports.buildBlockPackDist=e.xt,exports.buildKindDist=e.bt,exports.buildPublishedCoords=e.W,exports.checkKindVersionMatch=e.Y,exports.consolidateBlockComponents=e.Et,exports.consolidateBlockPackDescription=e.Ct,exports.consolidateBlockPackMeta=e.kt,exports.cpAbsoluteToRelative=e.Rt,exports.embedBlockPackMetaAbsoluteBase64=e.At,exports.embedBlockPackMetaAbsoluteBytes=e.jt,exports.embedBlockPackMetaBytes=e.Mt,exports.folderReaderByUrl=e.m,exports.inferUpdateSuggestions=e.g,exports.kindContentPrefix=e.lt,exports.kindOverviewPath=e.ut,exports.loadPackDescription=e.mt,exports.loadPackDescriptionFromManifest=e.ht,exports.loadPackDescriptionRaw=e.gt,exports.mapLocalToAbsolute=e.zt,exports.npmNameToKindPath=e.dt,exports.packFolderToRelativeTgz=e.Bt,exports.packageChannelPrefix=e.F,exports.packageChannelPrefixInsideV2=e.I,exports.packageContentPrefix=e.L,exports.packageContentPrefixInsideV2=e.R,exports.packageOverviewPath=e.z,exports.packageOverviewPathInsideV2=e.B,exports.parseGlobalOverviewReg=e.V,exports.parsePackageName=e._t,exports.parseSelector=e.v,exports.publishBlock=e.q,exports.readFacadeKindDependency=e.X,exports.readModelCompiledKindRef=e.Z,exports.relativeToContentString=e.Vt,exports.relativeToExplicitBinary64=e.Ht,exports.relativeToExplicitBytes=e.Ut,exports.relativeToExplicitString=e.Wt,exports.resolveBlockComponents=e.Dt,exports.resolveBlockPackDescription=e.wt,exports.resolveBlockPackMeta=e.Nt,exports.resolveFacadeKind=e.Q,exports.resolveKind=e.y,exports.resolveManifestBlockComponents=e.Ot,exports.resolveManifestBlockPackMeta=e.Pt,exports.resolveModuleFile=e.Gt,exports.resolveModuleFolder=e.Kt,exports.resolveToRegistry=e.G,exports.selectorToRange=e.b,Object.defineProperty(exports,"storageByUrl",{enumerable:!0,get:function(){return t.storageByUrl}}),exports.tryLoadPackDescription=e.vt,exports.writePublishedCoords=e.K;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["require_config","registry_v1_exports"],"sources":["../src/registry_v1/index.ts"],"sourcesContent":["export * from \"./v1_repo_schema\";\nexport * from \"./config_schema\";\nexport { PlRegPackageConfig } from \"./config\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":["require_config","_platforma_sdk_package_builder_lib","registry_v1_exports"],"sources":["../src/registry_v1/index.ts"],"sourcesContent":["export * from \"./v1_repo_schema\";\nexport * from \"./config_schema\";\nexport { PlRegPackageConfig } from \"./config\";\n"],"mappings":""}
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f,
|
|
1
|
+
import { $ as e, A as t, At as n, B as r, Bt as i, C as a, Ct as o, D as s, Dt as c, E as l, Et as u, F as d, Ft as f, G as p, Gt as m, H as h, Ht as g, I as _, It as v, J as y, Jt as b, Kt as x, L as S, Lt as C, M as w, Mt as T, N as E, Nt as D, O, Ot as k, P as A, Pt as j, Q as M, R as N, Rt as P, S as F, St as I, T as L, Tt as R, U as z, Ut as B, V, Vt as H, W as U, Wt as W, X as G, Xt as K, Y as q, Yt as J, Z as Y, Zt as X, _ as Z, _t as Q, a as $, at as ee, b as te, bt as ne, c as re, ct as ie, d as ae, dt as oe, et as se, f as ce, ft as le, g as ue, gt as de, h as fe, ht as pe, i as me, it as he, j as ge, jt as _e, k as ve, kt as ye, l as be, lt as xe, m as Se, mt as Ce, nt as we, o as Te, ot as Ee, p as De, pt as Oe, q as ke, qt as Ae, r as je, rt as Me, s as Ne, st as Pe, t as Fe, tt as Ie, u as Le, ut as Re, v as ze, vt as Be, w as Ve, wt as He, x as Ue, xt as We, y as Ge, yt as Ke, z as qe, zt as Je } from "./config-BusBoNIz.mjs";
|
|
2
2
|
// src/registry_v1/index.ts
|
|
3
|
-
var
|
|
4
|
-
GlobalOverviewPath: () =>
|
|
5
|
-
MetaFile: () =>
|
|
6
|
-
PlPackageConfigData: () =>
|
|
7
|
-
PlPackageJsonConfigFile: () =>
|
|
8
|
-
PlPackageYamlConfigFile: () =>
|
|
9
|
-
PlRegCommonConfigData: () =>
|
|
10
|
-
PlRegFullPackageConfigData: () =>
|
|
11
|
-
PlRegPackageConfig: () =>
|
|
12
|
-
PlRegPackageConfigDataShard: () =>
|
|
13
|
-
packageContentPrefix: () =>
|
|
14
|
-
packageOverviewPath: () =>
|
|
15
|
-
payloadFilePath: () =>
|
|
3
|
+
var Ye = /* @__PURE__ */ X({
|
|
4
|
+
GlobalOverviewPath: () => je,
|
|
5
|
+
MetaFile: () => me,
|
|
6
|
+
PlPackageConfigData: () => re,
|
|
7
|
+
PlPackageJsonConfigFile: () => be,
|
|
8
|
+
PlPackageYamlConfigFile: () => Le,
|
|
9
|
+
PlRegCommonConfigData: () => ae,
|
|
10
|
+
PlRegFullPackageConfigData: () => ce,
|
|
11
|
+
PlRegPackageConfig: () => Fe,
|
|
12
|
+
PlRegPackageConfigDataShard: () => De,
|
|
13
|
+
packageContentPrefix: () => $,
|
|
14
|
+
packageOverviewPath: () => Te,
|
|
15
|
+
payloadFilePath: () => Ne
|
|
16
16
|
});
|
|
17
|
-
export {
|
|
17
|
+
export { de as BlockDescriptionPackageJsonField, Q as BlockPackFolderName, L as BlockRegistryV2, l as ChannelNameRegexp, s as ChannelsFolder, fe as FSStorage, ue as GcsStorage, O as GlobalOverviewFileName, ve as GlobalOverviewGzFileName, t as GlobalOverviewGzPath, ge as GlobalOverviewPath, Me as KindImplementer, he as KindManifest, o as KindManifestFile, ee as KindManifestFileInfo, Ee as KindManifestFileName, Pe as KindManifestIdentity, ie as KindOverview, xe as KindOverviewFileName, Re as KindOverviewPathPattern, Ue as KindResolutionError, M as KindVersionMismatchError, oe as KindVersionOverview, le as KindsPrefix, w as MainPrefix, E as ManifestFileName, A as ManifestSuffix, d as PackageManifestPattern, _ as PackageOverview, S as PackageOverviewFileName, N as PackageOverviewVersionEntry, ke as PublishedCoordsFileName, Ye as RegistryV1, Ge as RegistryV2Reader, Z as S3Storage, Je as absoluteToBase64, i as absoluteToBytes, H as absoluteToString, u as addRelativePathPrefix, ye as blockComponentsManifestToAbsoluteUrl, R as buildBlockPackDist, He as buildKindDist, y as buildPublishedCoords, e as checkKindVersionMatch, n as consolidateBlockComponents, c as consolidateBlockPackDescription, D as consolidateBlockPackMeta, g as cpAbsoluteToRelative, j as embedBlockPackMetaAbsoluteBase64, f as embedBlockPackMetaAbsoluteBytes, v as embedBlockPackMetaBytes, Se as folderReaderByUrl, te as inferUpdateSuggestions, Oe as kindContentPrefix, Ce as kindOverviewPath, Be as loadPackDescription, Ke as loadPackDescriptionFromManifest, ne as loadPackDescriptionRaw, B as mapLocalToAbsolute, pe as npmNameToKindPath, W as packFolderToRelativeTgz, qe as packageChannelPrefix, r as packageChannelPrefixInsideV2, V as packageContentPrefix, h as packageContentPrefixInsideV2, z as packageOverviewPath, U as packageOverviewPathInsideV2, p as parseGlobalOverviewReg, We as parsePackageName, F as parseSelector, Y as publishBlock, se as readFacadeKindDependency, Ie as readModelCompiledKindRef, m as relativeToContentString, x as relativeToExplicitBinary64, Ae as relativeToExplicitBytes, b as relativeToExplicitString, _e as resolveBlockComponents, k as resolveBlockPackDescription, C as resolveBlockPackMeta, we as resolveFacadeKind, a as resolveKind, T as resolveManifestBlockComponents, P as resolveManifestBlockPackMeta, J as resolveModuleFile, K as resolveModuleFolder, q as resolveToRegistry, Ve as selectorToRange, ze as storageByUrl, I as tryLoadPackDescription, G as writePublishedCoords };
|
|
18
18
|
|
|
19
19
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["checkKindVersionMatch","GlobalOverviewGzPath","consolidateBlockComponents","packageChannelPrefixInsideV2","absoluteToBytes","resolveKind","KindManifestFile","ChannelsFolder","consolidateBlockPackDescription","ChannelNameRegexp","addRelativePathPrefix","PackageManifestPattern","embedBlockPackMetaAbsoluteBytes","parseGlobalOverviewReg","relativeToContentString","packageContentPrefixInsideV2","cpAbsoluteToRelative","PackageOverview","embedBlockPackMetaBytes","buildPublishedCoords","relativeToExplicitString","relativeToExplicitBinary64","PackageOverviewFileName","resolveBlockPackMeta","MainPrefix","resolveManifestBlockComponents","ManifestFileName","consolidateBlockPackMeta","resolveBlockPackDescription","ManifestSuffix","embedBlockPackMetaAbsoluteBase64","KindVersionMismatchError","PackageOverviewVersionEntry","resolveManifestBlockPackMeta","parseSelector","tryLoadPackDescription","BlockRegistryV2","buildBlockPackDist","packageOverviewPath","mapLocalToAbsolute","absoluteToString","packageOverviewPathInsideV2","packFolderToRelativeTgz","writePublishedCoords","resolveModuleFolder","resolveToRegistry","resolveModuleFile","publishBlock","__exportAll","S3Storage","BlockPackFolderName","packageContentPrefix$1","KindManifestFileInfo","inferUpdateSuggestions","loadPackDescriptionRaw","PlPackageConfigData","KindOverview","PlRegCommonConfigData","KindVersionOverview","readFacadeKindDependency","PlRegFullPackageConfigData","KindsPrefix","GcsStorage","BlockDescriptionPackageJsonField","FSStorage","npmNameToKindPath","MetaFile","KindManifest","GlobalOverviewPath","resolveBlockComponents","GlobalOverviewGzFileName","blockComponentsManifestToAbsoluteUrl","PlPackageJsonConfigFile","KindOverviewFileName","folderReaderByUrl","kindOverviewPath","resolveFacadeKind","packageOverviewPath$1","KindManifestFileName","PlRegPackageConfigDataShard","kindContentPrefix","PublishedCoordsFileName","relativeToExplicitBytes","GlobalOverviewPath$1","KindImplementer","payloadFilePath","KindManifestIdentity","PlRegPackageConfig","readModelCompiledKindRef","PlPackageYamlConfigFile","KindOverviewPathPattern","storageByUrl","loadPackDescription","selectorToRange","buildKindDist","KindResolutionError","parsePackageName","RegistryV2Reader","loadPackDescriptionFromManifest","packageChannelPrefix","absoluteToBase64","registry_v1_exports","GlobalOverviewFileName","packageContentPrefix"],"sources":["../src/registry_v1/index.ts"],"sourcesContent":["export * from \"./v1_repo_schema\";\nexport * from \"./config_schema\";\nexport { PlRegPackageConfig } from \"./config\";\n"],"mappings":""}
|
package/dist/io/storage.d.ts
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export interface RegistryStorage {
|
|
3
|
-
putFile(file: string, buffer: Buffer): Promise<void>;
|
|
4
|
-
getFile(file: string): Promise<Buffer | undefined>;
|
|
5
|
-
listFiles(prefix: string): Promise<string[]>;
|
|
6
|
-
deleteFiles(...files: string[]): Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
export declare class S3Storage implements RegistryStorage {
|
|
9
|
-
readonly client: S3;
|
|
10
|
-
readonly bucket: string;
|
|
11
|
-
readonly root: string;
|
|
12
|
-
constructor(client: S3, bucket: string, root: string);
|
|
13
|
-
getFile(file: string): Promise<Buffer | undefined>;
|
|
14
|
-
listFiles(prefix: string): Promise<string[]>;
|
|
15
|
-
putFile(file: string, buffer: Buffer): Promise<void>;
|
|
16
|
-
deleteFiles(...files: string[]): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export declare class FSStorage implements RegistryStorage {
|
|
19
|
-
/** Absolute path */
|
|
20
|
-
readonly root: string;
|
|
21
|
-
constructor(_root: string);
|
|
22
|
-
private toAbsolutePath;
|
|
23
|
-
getFile(address: string): Promise<Buffer | undefined>;
|
|
24
|
-
listFiles(prefix: string): Promise<string[]>;
|
|
25
|
-
putFile(address: string, buffer: Buffer): Promise<void>;
|
|
26
|
-
deleteFiles(...files: string[]): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
export declare function storageByUrl(address: string): RegistryStorage;
|
|
1
|
+
export { type RegistryStorage, S3Storage, GcsStorage, FSStorage, storageByUrl, } from '@platforma-sdk/package-builder-lib';
|
|
@@ -31,4 +31,5 @@ export declare const DERIVED_CATALOG_PINS: readonly DerivedCatalogPin[];
|
|
|
31
31
|
export declare const RUNENV_PYTHON = "@platforma-open/milaboratories.runenv-python-3";
|
|
32
32
|
export declare const RUNENV_PYTHON_VERSION = "1.8.2";
|
|
33
33
|
export declare function rootPnpmWorkspaceInitial(ctx: RunContext): Record<string, unknown>;
|
|
34
|
+
export declare function rootPnpmWorkspaceToolchainRules(): void;
|
|
34
35
|
export declare function rootPnpmWorkspaceRules(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/block-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "Utility to manipulate Platforma Blocks and Block Registry",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@aws-sdk/client-ecr-public": "3.1157.0",
|
|
27
|
-
"@aws-sdk/client-s3": "3.1157.0",
|
|
28
27
|
"@inquirer/prompts": "^7.0.1",
|
|
29
28
|
"@milaboratories/pl-http": "1.2.6",
|
|
30
29
|
"@milaboratories/pl-model-backend": "1.4.45",
|
|
@@ -33,7 +32,7 @@
|
|
|
33
32
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
34
33
|
"@milaboratories/ts-helpers": "1.9.1",
|
|
35
34
|
"@platforma-sdk/blocks-deps-updater": "2.2.2",
|
|
36
|
-
"@platforma-sdk/package-builder-lib": "1.
|
|
35
|
+
"@platforma-sdk/package-builder-lib": "1.5.0",
|
|
37
36
|
"canonicalize": "~2.1.0",
|
|
38
37
|
"commander": "^15.0.0",
|
|
39
38
|
"lru-cache": "^11.5.3",
|
|
@@ -31,14 +31,14 @@ export async function runRefresh(opts: {
|
|
|
31
31
|
|
|
32
32
|
export function structureRefreshCommand(packageRoot: string): Command {
|
|
33
33
|
const cmd = new Command("refresh").description(
|
|
34
|
-
"Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only
|
|
34
|
+
"Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only updates the catalog versions and the pnpm and Node toolchain (network).",
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
cmd.argument("[paths...]", "block path(s); defaults to the current directory");
|
|
38
38
|
cmd.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules");
|
|
39
39
|
cmd.option(
|
|
40
40
|
"--update-deps-only",
|
|
41
|
-
"
|
|
41
|
+
"update ONLY the catalog versions and the pnpm and Node toolchain (npm network). Follow with `pnpm install` then a plain refresh.",
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
cmd.action(async (argv: string[], flags) => {
|
|
@@ -19,3 +19,21 @@ test("test url reader without slash", async () => {
|
|
|
19
19
|
const content = await reader.getContentReader()("ping");
|
|
20
20
|
expect(content?.toString("utf8")).toStrictEqual("pong");
|
|
21
21
|
});
|
|
22
|
+
|
|
23
|
+
test("test url reader rejects non-2xx responses", async () => {
|
|
24
|
+
const { createServer } = await import("node:http");
|
|
25
|
+
const server = createServer((req, res) => {
|
|
26
|
+
if (req.url === "/ok.txt") res.writeHead(200).end("content");
|
|
27
|
+
else res.writeHead(404).end("<Error><Code>NoSuchKey</Code></Error>");
|
|
28
|
+
});
|
|
29
|
+
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
30
|
+
try {
|
|
31
|
+
const address = server.address();
|
|
32
|
+
if (address === null || typeof address === "string") throw new Error("no port");
|
|
33
|
+
const reader = folderReaderByUrl(`http://127.0.0.1:${address.port}/`);
|
|
34
|
+
expect((await reader.readFile("ok.txt")).toString()).toEqual("content");
|
|
35
|
+
await expect(reader.readFile("missing.json")).rejects.toThrow(/HTTP 404/);
|
|
36
|
+
} finally {
|
|
37
|
+
await new Promise((resolve) => server.close(resolve));
|
|
38
|
+
}
|
|
39
|
+
});
|
package/src/io/folder_reader.ts
CHANGED
|
@@ -5,6 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import pathPosix from "node:path/posix";
|
|
6
6
|
import fsp from "node:fs/promises";
|
|
7
7
|
import { defaultHttpDispatcher } from "@milaboratories/pl-http";
|
|
8
|
+
import { util } from "@platforma-sdk/package-builder-lib";
|
|
8
9
|
|
|
9
10
|
export type ReadFileOptions = { signal?: AbortSignal };
|
|
10
11
|
|
|
@@ -27,6 +28,11 @@ class HttpFolderReader implements FolderReader {
|
|
|
27
28
|
dispatcher: this.httpDispatcher,
|
|
28
29
|
signal: options?.signal,
|
|
29
30
|
});
|
|
31
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
32
|
+
// Release the connection; the error body (S3/GCS XML, an HTML page) is not registry content.
|
|
33
|
+
await response.body.dump();
|
|
34
|
+
throw new Error(`Failed to read ${util.redactUrl(targetUrl)}: HTTP ${response.statusCode}`);
|
|
35
|
+
}
|
|
30
36
|
return Buffer.from(await response.body.arrayBuffer());
|
|
31
37
|
}
|
|
32
38
|
|
package/src/io/storage.ts
CHANGED
|
@@ -1,147 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getFile(file: string): Promise<Buffer | undefined>;
|
|
10
|
-
|
|
11
|
-
listFiles(prefix: string): Promise<string[]>;
|
|
12
|
-
|
|
13
|
-
deleteFiles(...files: string[]): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class S3Storage implements RegistryStorage {
|
|
17
|
-
constructor(
|
|
18
|
-
public readonly client: S3,
|
|
19
|
-
public readonly bucket: string,
|
|
20
|
-
public readonly root: string,
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
async getFile(file: string): Promise<Buffer | undefined> {
|
|
24
|
-
try {
|
|
25
|
-
return Buffer.from(
|
|
26
|
-
await (
|
|
27
|
-
await this.client.getObject({
|
|
28
|
-
Bucket: this.bucket,
|
|
29
|
-
Key: pathPosix.join(this.root, file),
|
|
30
|
-
})
|
|
31
|
-
).Body!.transformToByteArray(),
|
|
32
|
-
);
|
|
33
|
-
} catch (e: unknown) {
|
|
34
|
-
if (e instanceof Error && e.name === "NoSuchKey") return undefined;
|
|
35
|
-
else throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async listFiles(prefix: string): Promise<string[]> {
|
|
40
|
-
const listRoot = pathPosix.join(this.root, prefix);
|
|
41
|
-
const paginator = paginateListObjectsV2(
|
|
42
|
-
{ client: this.client },
|
|
43
|
-
{
|
|
44
|
-
Bucket: this.bucket,
|
|
45
|
-
Prefix: listRoot,
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
const result: string[] = [];
|
|
49
|
-
for await (const page of paginator)
|
|
50
|
-
result.push(...(page.Contents ?? []).map((e) => pathPosix.relative(listRoot, e.Key!)));
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async putFile(file: string, buffer: Buffer): Promise<void> {
|
|
55
|
-
await this.client.putObject({
|
|
56
|
-
Bucket: this.bucket,
|
|
57
|
-
Key: pathPosix.join(this.root, file),
|
|
58
|
-
Body: buffer,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async deleteFiles(...files: string[]): Promise<void> {
|
|
63
|
-
// TODO implement support of more than 1000 files
|
|
64
|
-
const results = await this.client.deleteObjects({
|
|
65
|
-
Bucket: this.bucket,
|
|
66
|
-
Delete: {
|
|
67
|
-
Objects: files.map((file) => ({
|
|
68
|
-
Key: pathPosix.join(this.root, file),
|
|
69
|
-
})),
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
if (results.Errors !== undefined && results.Errors.length > 0)
|
|
73
|
-
throw new Error(
|
|
74
|
-
`Errors encountered while deleting files: ${results.Errors.map((e) => e.Message ?? e.Code ?? "Unknown error").join("\n")}`,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export class FSStorage implements RegistryStorage {
|
|
80
|
-
/** Absolute path */
|
|
81
|
-
public readonly root: string;
|
|
82
|
-
|
|
83
|
-
constructor(_root: string) {
|
|
84
|
-
this.root = path.resolve(_root);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private toAbsolutePath(localPath: string): string {
|
|
88
|
-
if (pathPosix.isAbsolute(localPath)) throw new Error("absolute path");
|
|
89
|
-
return path.resolve(this.root, localPath.split(pathPosix.sep).join(path.sep));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async getFile(address: string): Promise<Buffer | undefined> {
|
|
93
|
-
try {
|
|
94
|
-
return await fs.promises.readFile(this.toAbsolutePath(address));
|
|
95
|
-
} catch (err: unknown) {
|
|
96
|
-
if (err instanceof Error && "code" in err && err.code === "ENOENT") return undefined;
|
|
97
|
-
else throw err;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async listFiles(prefix: string): Promise<string[]> {
|
|
102
|
-
try {
|
|
103
|
-
const listRoot = this.toAbsolutePath(prefix);
|
|
104
|
-
return (await fs.promises.readdir(listRoot, { recursive: true, withFileTypes: true }))
|
|
105
|
-
.filter((e) => e.isFile())
|
|
106
|
-
.map((e) =>
|
|
107
|
-
path
|
|
108
|
-
.relative(listRoot, path.resolve(e.parentPath, e.name))
|
|
109
|
-
.split(path.sep)
|
|
110
|
-
.join(pathPosix.sep),
|
|
111
|
-
);
|
|
112
|
-
} catch (err: unknown) {
|
|
113
|
-
if (err instanceof Error && "code" in err && err.code === "ENOENT") return [];
|
|
114
|
-
else throw err;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async putFile(address: string, buffer: Buffer): Promise<void> {
|
|
119
|
-
const absoluteAddress = this.toAbsolutePath(address);
|
|
120
|
-
await fs.promises.mkdir(path.dirname(absoluteAddress), { recursive: true });
|
|
121
|
-
await fs.promises.writeFile(absoluteAddress, buffer);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async deleteFiles(...files: string[]): Promise<void> {
|
|
125
|
-
// Folders are not removed, deletes issued sequentially
|
|
126
|
-
for (const file of files) await fs.promises.rm(this.toAbsolutePath(file));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function storageByUrl(address: string): RegistryStorage {
|
|
131
|
-
const url = new URL(address, `file:${path.resolve(".").split(path.sep).join(pathPosix.sep)}/`);
|
|
132
|
-
switch (url.protocol) {
|
|
133
|
-
case "file:": {
|
|
134
|
-
const root = path.resolve(url.pathname);
|
|
135
|
-
return new FSStorage(root);
|
|
136
|
-
}
|
|
137
|
-
case "s3:": {
|
|
138
|
-
const options: NonNullable<ConstructorParameters<typeof S3>[0]> = {};
|
|
139
|
-
const region = url.searchParams.get("region");
|
|
140
|
-
if (region) options.region = region;
|
|
141
|
-
const bucket = url.hostname;
|
|
142
|
-
return new S3Storage(new S3(options), bucket, url.pathname.replace(/^\//, ""));
|
|
143
|
-
}
|
|
144
|
-
default:
|
|
145
|
-
throw new Error(`Unknown protocol: ${url.protocol}`);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
1
|
+
// The storage drivers live in package-builder-lib, shared with software package uploads.
|
|
2
|
+
export {
|
|
3
|
+
type RegistryStorage,
|
|
4
|
+
S3Storage,
|
|
5
|
+
GcsStorage,
|
|
6
|
+
FSStorage,
|
|
7
|
+
storageByUrl,
|
|
8
|
+
} from "@platforma-sdk/package-builder-lib";
|
|
@@ -31,11 +31,18 @@ const VARS: BlockVars = {
|
|
|
31
31
|
const readMonorepoFile = (relativePath: string) =>
|
|
32
32
|
readFileSync(new URL(`../../../../../${relativePath}`, import.meta.url), "utf-8");
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const REFRESH_MODES = ["default", "update-deps-only"] as const;
|
|
35
|
+
|
|
36
|
+
function refresh(fs: MemoryFileSystem, mode: (typeof REFRESH_MODES)[number] = "default") {
|
|
37
|
+
return engineRun(
|
|
38
|
+
STRUCTURE,
|
|
39
|
+
fs,
|
|
40
|
+
discoverRunContext({ fs, isSdkInternal: false, updateDepsOnly: mode === "update-deps-only" }),
|
|
41
|
+
{
|
|
42
|
+
templates: defaultTemplateProvider(),
|
|
43
|
+
rediscover: () => discoverRunContext({ fs, isSdkInternal: false, dryRun: true }),
|
|
44
|
+
},
|
|
45
|
+
);
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
function editJson(fs: MemoryFileSystem, edit: (json: Record<string, unknown>) => void) {
|
|
@@ -67,7 +74,7 @@ describe("block toolchain", () => {
|
|
|
67
74
|
expect(workspace.allowBuilds).toMatchObject({ ...REQUIRED_BUILDS, ...SKIPPED_BUILDS });
|
|
68
75
|
});
|
|
69
76
|
|
|
70
|
-
test("refresh moves an old block to the SDK pnpm and Node", () => {
|
|
77
|
+
test.each(REFRESH_MODES)("refresh (%s) moves an old block to the SDK pnpm and Node", (mode) => {
|
|
71
78
|
const { fs } = simulateInit({ vars: VARS });
|
|
72
79
|
editJson(fs, (json) => {
|
|
73
80
|
json.packageManager = "pnpm@9.12.0";
|
|
@@ -80,7 +87,7 @@ describe("block toolchain", () => {
|
|
|
80
87
|
doc.setIn(["catalog", "turbo"], "~2.8.11");
|
|
81
88
|
});
|
|
82
89
|
|
|
83
|
-
refresh(fs);
|
|
90
|
+
refresh(fs, mode);
|
|
84
91
|
|
|
85
92
|
const pkg = JSON.parse(fs.read("package.json"));
|
|
86
93
|
expect(pkg.packageManager).toBe(PACKAGE_MANAGER);
|
|
@@ -146,11 +153,14 @@ describe("block toolchain", () => {
|
|
|
146
153
|
expect(workspace.allowBuilds).toEqual({ ...SKIPPED_BUILDS, ...REQUIRED_BUILDS });
|
|
147
154
|
});
|
|
148
155
|
|
|
149
|
-
test
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
test.each(REFRESH_MODES)(
|
|
157
|
+
"refresh (%s) refuses a package.json pnpm field with settings",
|
|
158
|
+
(mode) => {
|
|
159
|
+
const { fs } = simulateInit({ vars: VARS });
|
|
160
|
+
editJson(fs, (json) => {
|
|
161
|
+
json.pnpm = { overrides: { zod: "~3.25.76" } };
|
|
162
|
+
});
|
|
163
|
+
expect(() => refresh(fs, mode)).toThrow(/pnpm-workspace\.yaml/);
|
|
164
|
+
},
|
|
165
|
+
);
|
|
156
166
|
});
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
// migrated block that never carried `@milaboratories/ts-builder` etc. now
|
|
15
15
|
// gets them ADDED on `--update-deps-only`, no manual catalog seed required.
|
|
16
16
|
//
|
|
17
|
+
// The same frame also applies the toolchain rules (SDK pnpm and Node, pnpm 12
|
|
18
|
+
// workspace settings), so `upgrade-sdk` runs its first `pnpm i` on the SDK
|
|
19
|
+
// pnpm with its release-age check.
|
|
20
|
+
//
|
|
17
21
|
// Wrapped in the same root-scope `when(!isSdkInternal)` guard as the rest of
|
|
18
22
|
// the root rules — internal blocks get their catalog from the parent
|
|
19
23
|
// monorepo, so catalog resolution never applies there.
|
|
@@ -27,9 +31,13 @@ import {
|
|
|
27
31
|
ensureCatalogLatest,
|
|
28
32
|
ensureCatalogVersion,
|
|
29
33
|
pinCatalogToDependencyOf,
|
|
34
|
+
enforceFieldOrder,
|
|
30
35
|
} from "../engine/api";
|
|
36
|
+
import { rootPackageJsonInitial, rootPackageJsonToolchainRules } from "./root-package-json";
|
|
37
|
+
import { canonicalPackageJsonOrder } from "./shared/key-order";
|
|
31
38
|
import {
|
|
32
39
|
rootPnpmWorkspaceInitial,
|
|
40
|
+
rootPnpmWorkspaceToolchainRules,
|
|
33
41
|
SDK_CATALOG_PACKAGES,
|
|
34
42
|
DERIVED_CATALOG_PINS,
|
|
35
43
|
RUNENV_PYTHON,
|
|
@@ -42,6 +50,14 @@ export function rootCatalogBumpRules(): void {
|
|
|
42
50
|
when(
|
|
43
51
|
({ ctx }) => !ctx.isSdkInternal,
|
|
44
52
|
() => {
|
|
53
|
+
managed(
|
|
54
|
+
"package.json",
|
|
55
|
+
generate(() => rootPackageJsonInitial()),
|
|
56
|
+
() => {
|
|
57
|
+
rootPackageJsonToolchainRules();
|
|
58
|
+
enforceFieldOrder([...canonicalPackageJsonOrder]);
|
|
59
|
+
},
|
|
60
|
+
);
|
|
45
61
|
// On init, the default root rules create pnpm-workspace.yaml from
|
|
46
62
|
// this same generator (the curated SDK placeholders + infra
|
|
47
63
|
// floor); this leaf then overwrites the SDK entries with npm
|
|
@@ -77,6 +93,7 @@ export function rootCatalogBumpRules(): void {
|
|
|
77
93
|
if (ctx.modules.some((m) => m.scope === "software")) {
|
|
78
94
|
ensureCatalogVersion(RUNENV_PYTHON, RUNENV_PYTHON_VERSION);
|
|
79
95
|
}
|
|
96
|
+
rootPnpmWorkspaceToolchainRules();
|
|
80
97
|
},
|
|
81
98
|
);
|
|
82
99
|
},
|
|
@@ -80,7 +80,7 @@ export function rootPackageJsonInitial(): Record<string, unknown> {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
export function
|
|
83
|
+
export function rootPackageJsonToolchainRules(): void {
|
|
84
84
|
ensureField("packageManager", PACKAGE_MANAGER);
|
|
85
85
|
ensureField("devEngines.runtime", NODE_RUNTIME);
|
|
86
86
|
removeField(
|
|
@@ -96,6 +96,10 @@ export function rootPackageJsonRules(): void {
|
|
|
96
96
|
"pnpm",
|
|
97
97
|
'pnpm 11+ ignores the "pnpm" field in package.json. Move its settings to pnpm-workspace.yaml: overrides as is, onlyBuiltDependencies as allowBuilds true, neverBuiltDependencies as allowBuilds false.',
|
|
98
98
|
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function rootPackageJsonRules(): void {
|
|
102
|
+
rootPackageJsonToolchainRules();
|
|
99
103
|
|
|
100
104
|
// Root is never published — it carries no `name`; delete any stray one.
|
|
101
105
|
removeField("name");
|
|
@@ -134,8 +134,7 @@ export function rootPnpmWorkspaceInitial(ctx: RunContext): Record<string, unknow
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
export function
|
|
138
|
-
ensureWorkspaceModulePaths();
|
|
137
|
+
export function rootPnpmWorkspaceToolchainRules(): void {
|
|
139
138
|
ensureWorkspaceListItems("minimumReleaseAgeExclude", MINIMUM_RELEASE_AGE_EXCLUDE);
|
|
140
139
|
ensureWorkspaceMapEntries("allowBuilds", SKIPPED_BUILDS, { keepExisting: true });
|
|
141
140
|
ensureWorkspaceMapEntries("allowBuilds", REQUIRED_BUILDS);
|
|
@@ -151,6 +150,11 @@ export function rootPnpmWorkspaceRules(): void {
|
|
|
151
150
|
ensureCatalogVersion(name, version);
|
|
152
151
|
}
|
|
153
152
|
ensureCatalogAtLeast("turbo", TURBO_VERSION);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function rootPnpmWorkspaceRules(): void {
|
|
156
|
+
ensureWorkspaceModulePaths();
|
|
157
|
+
rootPnpmWorkspaceToolchainRules();
|
|
154
158
|
// Catalog side of the retired-dep cleanup — the per-package side sheds the
|
|
155
159
|
// matching `catalog:` references.
|
|
156
160
|
for (const name of RETIRED_TOOLCHAIN_DEPS) ensureCatalogAbsent(name);
|
|
@@ -28,8 +28,6 @@ export const REQUIRED_BUILDS: Record<string, boolean> = {
|
|
|
28
28
|
/** Install scripts in the SDK tree that only clean up, print, or build optional native code. */
|
|
29
29
|
export const SKIPPED_BUILDS: Record<string, boolean> = {
|
|
30
30
|
"@milaboratories/tengo-tester": false,
|
|
31
|
-
"cpu-features": false,
|
|
32
31
|
esbuild: false,
|
|
33
32
|
protobufjs: false,
|
|
34
|
-
ssh2: false,
|
|
35
33
|
};
|