@platforma-sdk/block-tools 2.11.2 → 2.11.4
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/bin/run.js +9 -5
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +13 -13
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +845 -981
- package/dist/cli.mjs.map +1 -1
- package/dist/cmd/build-meta.d.ts +2 -9
- package/dist/cmd/build-model.d.ts +2 -10
- package/dist/cmd/list-overview-snapshots.d.ts +2 -9
- package/dist/cmd/mark-stable.d.ts +2 -13
- package/dist/cmd/pack.d.ts +2 -9
- package/dist/cmd/publish.d.ts +2 -12
- package/dist/cmd/refresh-registry.d.ts +2 -9
- package/dist/cmd/restore-overview-from-snapshot.d.ts +2 -10
- package/dist/cmd/structure/check.d.ts +2 -10
- package/dist/cmd/structure/init.d.ts +2 -18
- package/dist/cmd/structure/refresh.d.ts +10 -11
- package/dist/cmd/update-deps.d.ts +2 -6
- package/dist/cmd/upload-package-v1.d.ts +2 -14
- package/dist/config-BmJWc8sR.js +3 -0
- package/dist/config-BmJWc8sR.js.map +1 -0
- package/dist/{config-DpfTzcgG.mjs → config-CiC347sB.mjs} +453 -398
- package/dist/config-CiC347sB.mjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +15 -15
- package/dist/registry_v1/config_schema.d.ts +7 -7
- package/dist/registry_v1/flags.d.ts +2 -4
- package/dist/structure/cli/run-structure.d.ts +1 -1
- package/dist/structure/engine/discovery.d.ts +2 -3
- package/dist/structure/rules/block-package-json.d.ts +3 -3
- package/dist/structure/rules/shared/pascal-case.d.ts +1 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/model/block_components.d.ts +11 -0
- package/dist/v2/model/block_meta.d.ts +7 -0
- package/dist/v2/resolve_to_registry.d.ts +37 -0
- package/dist/v2/source_package.d.ts +12 -0
- package/package.json +9 -24
- package/src/cli.test.ts +56 -0
- package/src/cli.ts +50 -0
- package/src/cmd/build-meta.ts +11 -22
- package/src/cmd/build-model.ts +16 -33
- package/src/cmd/list-overview-snapshots.ts +24 -28
- package/src/cmd/mark-stable.ts +35 -55
- package/src/cmd/pack.ts +11 -22
- package/src/cmd/publish.test.ts +35 -0
- package/src/cmd/publish.ts +55 -49
- package/src/cmd/refresh-registry.ts +22 -26
- package/src/cmd/restore-overview-from-snapshot.ts +24 -34
- package/src/cmd/structure/check.ts +19 -28
- package/src/cmd/structure/init.ts +40 -47
- package/src/cmd/structure/refresh.ts +45 -36
- package/src/cmd/update-deps.ts +22 -12
- package/src/cmd/upload-package-v1.ts +42 -60
- package/src/registry_v1/flags.ts +7 -7
- package/src/structure/__tests__/discovery-shortname.test.ts +3 -0
- package/src/structure/__tests__/facade-end-state.test.ts +195 -0
- package/src/structure/__tests__/model-package-json.snapshot.test.ts +1 -1
- package/src/structure/cli/run-structure.ts +2 -2
- package/src/structure/engine/__tests__/discovery.test.ts +22 -26
- package/src/structure/engine/discovery.ts +12 -30
- package/src/structure/rules/block-package-json.ts +146 -64
- package/src/structure/rules/block.ts +40 -5
- package/src/structure/rules/model-package-json.ts +6 -1
- package/src/structure/rules/shared/pascal-case.ts +16 -0
- package/src/structure/rules/software-package-json.ts +6 -1
- package/src/structure/rules/test-package-json.ts +5 -1
- package/src/structure/rules/ui-package-json.ts +5 -1
- package/src/structure/rules/workflow-package-json.ts +5 -1
- package/src/structure/templates/static/block/src/AGENTS.ts +5 -0
- package/src/structure/templates/static/block/src/agents-extra.ts +8 -0
- package/src/structure/templates/static/block/src/block-extra.ts +9 -0
- package/src/structure/templates/static/block/tsconfig.json +4 -0
- package/src/structure/templates/text/block/src/index.tpl.ts +55 -0
- package/src/v2/from_pack_v2.test.ts +142 -0
- package/src/v2/index.ts +1 -0
- package/src/v2/model/block_components.ts +33 -0
- package/src/v2/model/block_meta.ts +18 -0
- package/src/v2/model/content_conversion.ts +0 -1
- package/src/v2/resolve_to_registry.ts +84 -0
- package/src/v2/source_package.ts +34 -1
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -6
- package/dist/cmd/index.d.ts +0 -28
- package/dist/config-DpfTzcgG.mjs.map +0 -1
- package/dist/config-xxVy3IQR.js +0 -3
- package/dist/config-xxVy3IQR.js.map +0 -1
- package/src/cmd/index.ts +0 -31
- package/src/structure/templates/static/block/index.d.ts +0 -6
- package/src/structure/templates/static/block/index.js +0 -8
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { $ as e, A as t, B as n, C as r,
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, Ct as i, D as a, E as o, F as s, G as c, H as l, I as u, J as d, K as f, L as p, M as m, N as h, O as g, P as _, Q as v, R as y, S as b, St as x, T as S, U as C, V as w, W as T, X as E, Y as D, Z as O, _ as k, _t as A, a as j, at as M, b as N, bt as P, c as F, ct as I, d as L, dt as R, et as z, f as B, ft as V, g as H, gt as U, h as W, ht as G, i as K, it as q, j as J, k as Y, l as X, lt as Z, m as Q, mt as $, nt as ee, o as te, ot as ne, p as re, pt as ie, q as ae, r as oe, rt as se, s as ce, st as le, t as ue, tt as de, u as fe, ut as pe, v as me, vt as he, w as ge, wt as _e, x as ve, xt as ye, y as be, yt as xe, z as Se } from "./config-CiC347sB.mjs";
|
|
2
2
|
//#region 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 Ce = /* @__PURE__ */ _e({
|
|
4
|
+
GlobalOverviewPath: () => oe,
|
|
5
|
+
MetaFile: () => K,
|
|
6
|
+
PlPackageConfigData: () => F,
|
|
7
|
+
PlPackageJsonConfigFile: () => X,
|
|
8
|
+
PlPackageYamlConfigFile: () => fe,
|
|
9
|
+
PlRegCommonConfigData: () => L,
|
|
10
|
+
PlRegFullPackageConfigData: () => B,
|
|
11
|
+
PlRegPackageConfig: () => ue,
|
|
12
|
+
PlRegPackageConfigDataShard: () => re,
|
|
13
|
+
packageContentPrefix: () => j,
|
|
14
|
+
packageOverviewPath: () => te,
|
|
15
|
+
payloadFilePath: () => ce
|
|
16
16
|
});
|
|
17
17
|
//#endregion
|
|
18
|
-
export {
|
|
18
|
+
export { c as BlockDescriptionPackageJsonField, f as BlockPackFolderName, N as BlockRegistryV2, ve as ChannelNameRegexp, b as ChannelsFolder, W as FSStorage, r as GlobalOverviewFileName, ge as GlobalOverviewGzFileName, S as GlobalOverviewGzPath, o as GlobalOverviewPath, a as MainPrefix, g as ManifestFileName, Y as ManifestSuffix, t as PackageManifestPattern, J as PackageOverview, m as PackageOverviewFileName, h as PackageOverviewVersionEntry, w as PublishedCoordsFileName, Ce as RegistryV1, me as RegistryV2Reader, H as S3Storage, V as absoluteToBase64, ie as absoluteToBytes, $ as absoluteToString, e as addRelativePathPrefix, ee as blockComponentsManifestToAbsoluteUrl, v as buildBlockPackDist, l as buildPublishedCoords, se as consolidateBlockComponents, z as consolidateBlockPackDescription, ne as consolidateBlockPackMeta, G as cpAbsoluteToRelative, le as embedBlockPackMetaAbsoluteBase64, I as embedBlockPackMetaAbsoluteBytes, Z as embedBlockPackMetaBytes, Q as folderReaderByUrl, be as inferUpdateSuggestions, ae as loadPackDescription, d as loadPackDescriptionFromManifest, D as loadPackDescriptionRaw, U as mapLocalToAbsolute, A as packFolderToRelativeTgz, _ as packageChannelPrefix, s as packageChannelPrefixInsideV2, u as packageContentPrefix, p as packageContentPrefixInsideV2, y as packageOverviewPath, Se as packageOverviewPathInsideV2, n as parseGlobalOverviewReg, E as parsePackageName, he as relativeToContentString, xe as relativeToExplicitBinary64, P as relativeToExplicitBytes, ye as relativeToExplicitString, q as resolveBlockComponents, de as resolveBlockPackDescription, pe as resolveBlockPackMeta, M as resolveManifestBlockComponents, R as resolveManifestBlockPackMeta, x as resolveModuleFile, i as resolveModuleFolder, C as resolveToRegistry, k as storageByUrl, O as tryLoadPackDescription, T as writePublishedCoords };
|
|
19
19
|
|
|
20
20
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -29,8 +29,8 @@ export declare const PlRegCommonConfigData: z.ZodObject<{
|
|
|
29
29
|
registries: Record<string, string>;
|
|
30
30
|
registry?: string | undefined;
|
|
31
31
|
}, {
|
|
32
|
-
registry?: string | undefined;
|
|
33
32
|
registries?: Record<string, string> | undefined;
|
|
33
|
+
registry?: string | undefined;
|
|
34
34
|
}>;
|
|
35
35
|
export type PlRegCommonConfigData = z.infer<typeof PlRegCommonConfigData>;
|
|
36
36
|
export declare const PlRegFullPackageConfigData: z.ZodObject<{
|
|
@@ -38,9 +38,9 @@ export declare const PlRegFullPackageConfigData: z.ZodObject<{
|
|
|
38
38
|
meta: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
|
|
39
39
|
files: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
40
40
|
version: z.ZodString;
|
|
41
|
-
registry: z.ZodString;
|
|
42
41
|
package: z.ZodString;
|
|
43
42
|
registries: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
43
|
+
registry: z.ZodString;
|
|
44
44
|
}, "strip", z.ZodTypeAny, {
|
|
45
45
|
organization: string;
|
|
46
46
|
meta: {} & {
|
|
@@ -48,17 +48,17 @@ export declare const PlRegFullPackageConfigData: z.ZodObject<{
|
|
|
48
48
|
};
|
|
49
49
|
files: Record<string, string>;
|
|
50
50
|
version: string;
|
|
51
|
-
registry: string;
|
|
52
51
|
package: string;
|
|
53
52
|
registries: Record<string, string>;
|
|
53
|
+
registry: string;
|
|
54
54
|
}, {
|
|
55
55
|
organization: string;
|
|
56
56
|
meta: {} & {
|
|
57
57
|
[k: string]: unknown;
|
|
58
58
|
};
|
|
59
59
|
version: string;
|
|
60
|
-
registry: string;
|
|
61
60
|
package: string;
|
|
61
|
+
registry: string;
|
|
62
62
|
files?: Record<string, string> | undefined;
|
|
63
63
|
registries?: Record<string, string> | undefined;
|
|
64
64
|
}>;
|
|
@@ -68,25 +68,25 @@ export declare const PlRegPackageConfigDataShard: z.ZodObject<{
|
|
|
68
68
|
meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
69
69
|
files: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
70
70
|
version: z.ZodOptional<z.ZodString>;
|
|
71
|
-
registry: z.ZodOptional<z.ZodString>;
|
|
72
71
|
package: z.ZodOptional<z.ZodString>;
|
|
73
72
|
registries: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
73
|
+
registry: z.ZodOptional<z.ZodString>;
|
|
74
74
|
}, "strip", z.ZodTypeAny, {
|
|
75
75
|
files: Record<string, string>;
|
|
76
76
|
registries: Record<string, string>;
|
|
77
77
|
organization?: string | undefined;
|
|
78
78
|
meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
79
79
|
version?: string | undefined;
|
|
80
|
-
registry?: string | undefined;
|
|
81
80
|
package?: string | undefined;
|
|
81
|
+
registry?: string | undefined;
|
|
82
82
|
}, {
|
|
83
83
|
organization?: string | undefined;
|
|
84
84
|
meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
85
85
|
files?: Record<string, string> | undefined;
|
|
86
86
|
version?: string | undefined;
|
|
87
|
-
registry?: string | undefined;
|
|
88
87
|
package?: string | undefined;
|
|
89
88
|
registries?: Record<string, string> | undefined;
|
|
89
|
+
registry?: string | undefined;
|
|
90
90
|
}>;
|
|
91
91
|
export type PlRegPackageConfigDataShard = z.infer<typeof PlRegPackageConfigDataShard>;
|
|
92
92
|
export declare const PlPackageJsonConfigFile = "pl.package.json";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { Option } from 'commander';
|
|
1
2
|
export interface TargetFile {
|
|
2
3
|
src: string;
|
|
3
4
|
destName: string;
|
|
4
5
|
}
|
|
5
|
-
export declare
|
|
6
|
-
multiple: false;
|
|
7
|
-
requiredOrDefaulted: false;
|
|
8
|
-
}>;
|
|
6
|
+
export declare function targetFileOption(flags: string, summary: string): Option;
|
|
@@ -6,7 +6,7 @@ export type RunStructureInput = {
|
|
|
6
6
|
isSdkInternal: boolean;
|
|
7
7
|
updateDepsOnly: boolean;
|
|
8
8
|
mode: StructureMode;
|
|
9
|
-
/** `<block-tools>/src/structure/templates
|
|
9
|
+
/** `<block-tools>/src/structure/templates`. */
|
|
10
10
|
templatesRoot: string;
|
|
11
11
|
log: (msg: string) => void;
|
|
12
12
|
};
|
|
@@ -15,6 +15,7 @@ export type PackageJsonLike = {
|
|
|
15
15
|
devDependencies?: Record<string, string>;
|
|
16
16
|
peerDependencies?: Record<string, string>;
|
|
17
17
|
optionalDependencies?: Record<string, string>;
|
|
18
|
+
block?: unknown;
|
|
18
19
|
"block-scope"?: string;
|
|
19
20
|
"block-software"?: unknown;
|
|
20
21
|
};
|
|
@@ -26,11 +27,9 @@ export declare class DiscoveryError extends Error {
|
|
|
26
27
|
* Classify one package.
|
|
27
28
|
*
|
|
28
29
|
* @param wp The workspace package.
|
|
29
|
-
* @param siblingNames Set of all workspace package `name`s (used by
|
|
30
|
-
* rule 4 "block": depends on ≥2 sibling .model/.ui/.workflow).
|
|
31
30
|
* @returns Scope or `undefined` if unclassified.
|
|
32
31
|
*/
|
|
33
|
-
export declare function classifyOne(wp: WorkspacePackage
|
|
32
|
+
export declare function classifyOne(wp: WorkspacePackage): Scope | undefined;
|
|
34
33
|
/**
|
|
35
34
|
* Classify a whole workspace. Throws on the first unclassified package
|
|
36
35
|
* with a message that directs the operator to add `block-scope` to its
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RunContext } from '../engine/api';
|
|
2
2
|
/** The facade's `block.components` map: the dist artifact each module build
|
|
3
|
-
* emits, keyed by role. Fully determined by the discovered modules — the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* emits, keyed by role. Fully determined by the discovered modules — the body
|
|
4
|
+
* rule re-asserts this exact value, so it is engine-managed (NOT an author
|
|
5
|
+
* seed). Mirrors the artifact paths produced by each scope's build:
|
|
6
6
|
* workflow → pl-tengo, model → build-model, ui → ts-builder. */
|
|
7
7
|
export declare function blockComponents(ctx: RunContext): Record<string, string>;
|
|
8
8
|
export declare function blockPackageJsonInitial(ctx: RunContext): Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pascalCase(s: string): string;
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -12,6 +12,17 @@ export type BlockComponentsAbsoluteUrl = BlockComponents<ContentAbsoluteUrl, Con
|
|
|
12
12
|
* resolution; the UI request resolves to a folder containing `index.html`.
|
|
13
13
|
*/
|
|
14
14
|
export declare function resolveBlockComponents(raw: BlockComponentsDescriptionRaw, moduleRoot: string): BlockComponentsDescription;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves a manifest's relative component paths against the `block-pack/`
|
|
17
|
+
* folder of a consumed package. Workflow main and model become absolute-file
|
|
18
|
+
* refs; the UI (a `ui.tgz` archive) resolves to its absolute path carried in
|
|
19
|
+
* the `absolute-folder` slot — `BlockComponentsDescription` types `ui` as a
|
|
20
|
+
* folder, and for manifest-consumed packs that slot holds the tgz file path
|
|
21
|
+
* (the `from-pack-v2` loader reads `.ui.folder` and feeds it to the lazy
|
|
22
|
+
* `local-tgz` frontend). Counterpart to `resolveBlockComponents`, which
|
|
23
|
+
* resolves a raw `package.json` description against authoring source.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveManifestBlockComponents(manifest: BlockComponentsManifest, blockPackDir: string): BlockComponentsDescription;
|
|
15
26
|
/**
|
|
16
27
|
* Copies file references for workflow and model into `dstFolder`, packs the
|
|
17
28
|
* UI folder into `ui.tgz`, returning the manifest form with relative paths.
|
|
@@ -7,6 +7,13 @@ export type BlockPackMetaDescription = BlockPackMeta<ContentAbsoluteTextLocal, C
|
|
|
7
7
|
* normalization) to absolute file paths against the module root.
|
|
8
8
|
*/
|
|
9
9
|
export declare function resolveBlockPackMeta(raw: BlockPackMetaDescriptionRaw, root: string): Promise<BlockPackMetaDescription>;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a manifest's relative text/binary references against the
|
|
12
|
+
* `block-pack/` folder of a consumed package. Counterpart to
|
|
13
|
+
* `resolveBlockPackMeta` (which resolves raw `package.json` meta against
|
|
14
|
+
* authoring source); inlined explicit content passes through unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveManifestBlockPackMeta(manifest: BlockPackMetaManifest, blockPackDir: string): Promise<BlockPackMetaDescription>;
|
|
10
17
|
/**
|
|
11
18
|
* Copies absolute text/binary file references into `dstFolder` and returns
|
|
12
19
|
* the manifest form with relative paths.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV2, BlockPackId } from '@milaboratories/pl-model-middle-layer';
|
|
2
|
+
/** File written by `block-tools publish` into `block-pack/`, carrying the
|
|
3
|
+
* registry coordinates of the published version. Holds only the immutable
|
|
4
|
+
* coordinates (CDN serve URL + version id). No `channel`: channels are moving
|
|
5
|
+
* pointers in the registry — a version can be promoted/moved later — so the
|
|
6
|
+
* channel at publish time is transient state we can't pin here. Update-checking
|
|
7
|
+
* resolves the channel at read time (`BlockPackFromRegistryV2.channel` is
|
|
8
|
+
* optional; the watcher defaults stable → any). */
|
|
9
|
+
export declare const PublishedCoordsFileName = "published.json";
|
|
10
|
+
/** Registry coordinates persisted in `block-pack/published.json`. */
|
|
11
|
+
export interface PublishedCoords {
|
|
12
|
+
/** CDN serve URL the block is fetched from (not the S3 upload bucket). */
|
|
13
|
+
registryUrl: string;
|
|
14
|
+
id: BlockPackId;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Builds the `published.json` payload. Pure (no filesystem) so it is unit
|
|
18
|
+
* testable.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildPublishedCoords(args: {
|
|
21
|
+
registryUrl: string;
|
|
22
|
+
id: BlockPackId;
|
|
23
|
+
}): PublishedCoords;
|
|
24
|
+
/** Writes `block-pack/published.json` into the given block-pack folder. */
|
|
25
|
+
export declare function writePublishedCoords(blockPackDir: string, coords: PublishedCoords): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves a local block locator (`dev-v2` or `from-pack-v2`) to its registry
|
|
28
|
+
* coordinates by reading `published.json`. `published.json` lives inside the
|
|
29
|
+
* block-pack directory (written there by `block-tools publish`), so for
|
|
30
|
+
* `from-pack-v2` we read it directly from `packUrl` (converted to a path at this
|
|
31
|
+
* Node boundary) — the structurer owns the layout, we do not re-derive it. For a
|
|
32
|
+
* `dev-v2` block folder it sits under
|
|
33
|
+
* `<folder>/block-pack/`. The facade's engine-generated `from-pack-v2`
|
|
34
|
+
* BlockPointer feeds this so a consumed block can be installed via the registry
|
|
35
|
+
* path. Throws when the block was never published.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveToRegistry(locator: BlockPackDevV2 | BlockPackFromPackV2): Promise<BlockPackFromRegistryV2>;
|
|
@@ -6,3 +6,15 @@ export declare function parsePackageName(packageName: string): Pick<BlockPackId,
|
|
|
6
6
|
export declare function tryLoadPackDescription(moduleRoot: string, logger?: MiLogger): Promise<BlockPackDescriptionAbsolute | undefined>;
|
|
7
7
|
export declare function loadPackDescriptionRaw(moduleRoot: string): Promise<BlockPackDescriptionRaw>;
|
|
8
8
|
export declare function loadPackDescription(moduleRoot: string): Promise<BlockPackDescriptionAbsolute>;
|
|
9
|
+
/** Folder name (under a consumed package root) holding the v2 block-pack artifacts. */
|
|
10
|
+
export declare const BlockPackFolderName = "block-pack";
|
|
11
|
+
/**
|
|
12
|
+
* Loads a block-pack description from a block-pack directory's `manifest.json`,
|
|
13
|
+
* resolving every relative entry against that directory to an absolute
|
|
14
|
+
* filesystem path. Takes the pack directory directly (the `from-pack-v2`
|
|
15
|
+
* pointer's `packUrl`) — the structurer owns the layout, so this does not
|
|
16
|
+
* re-derive `<root>/block-pack`. Counterpart to `loadPackDescription`, which
|
|
17
|
+
* reads the authoring `block` field from `package.json` and resolves against
|
|
18
|
+
* source.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadPackDescriptionFromManifest(blockPackDir: string): Promise<BlockPackDescriptionAbsolute>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/block-tools",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.4",
|
|
4
4
|
"description": "Utility to manipulate Platforma Blocks and Block Registry",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"bin": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@aws-sdk/client-s3": "3.859.0",
|
|
27
27
|
"@inquirer/prompts": "^7.0.1",
|
|
28
|
-
"@oclif/core": "^4.0.37",
|
|
29
28
|
"canonicalize": "~2.1.0",
|
|
29
|
+
"commander": "^15.0.0",
|
|
30
30
|
"lru-cache": "^11.2.2",
|
|
31
31
|
"mime-types": "^2.1.35",
|
|
32
32
|
"tar": "^7.4.3",
|
|
@@ -34,13 +34,12 @@
|
|
|
34
34
|
"yaml": "^2.8.0",
|
|
35
35
|
"zod": "~3.25.76",
|
|
36
36
|
"@milaboratories/pl-http": "1.2.4",
|
|
37
|
-
"@milaboratories/pl-model-
|
|
38
|
-
"@milaboratories/pl-model-
|
|
39
|
-
"@milaboratories/ts-helpers": "1.8.3",
|
|
37
|
+
"@milaboratories/pl-model-backend": "1.4.8",
|
|
38
|
+
"@milaboratories/pl-model-middle-layer": "1.30.9",
|
|
40
39
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
41
40
|
"@platforma-sdk/blocks-deps-updater": "2.2.0",
|
|
42
|
-
"@milaboratories/ts-helpers
|
|
43
|
-
"@milaboratories/pl-model-
|
|
41
|
+
"@milaboratories/ts-helpers": "1.8.3",
|
|
42
|
+
"@milaboratories/pl-model-common": "1.46.2"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
@@ -48,7 +47,6 @@
|
|
|
48
47
|
"@types/node": "~24.5.2",
|
|
49
48
|
"@types/semver": "^7.7.0",
|
|
50
49
|
"@vitest/coverage-istanbul": "^4.1.3",
|
|
51
|
-
"oclif": "^4.16.2",
|
|
52
50
|
"oxfmt": "0.35.0",
|
|
53
51
|
"rollup-plugin-node-externals": "^8.0.0",
|
|
54
52
|
"semver": "^7.7.2",
|
|
@@ -56,25 +54,12 @@
|
|
|
56
54
|
"vite": "^8.0.6",
|
|
57
55
|
"vite-plugin-dts": "^4.5.3",
|
|
58
56
|
"vitest": "^4.1.3",
|
|
59
|
-
"@milaboratories/
|
|
60
|
-
"@milaboratories/
|
|
61
|
-
"@milaboratories/
|
|
62
|
-
"@milaboratories/ts-builder": "1.5.2"
|
|
63
|
-
},
|
|
64
|
-
"oclif": {
|
|
65
|
-
"bin": "block-tools",
|
|
66
|
-
"commands": {
|
|
67
|
-
"identifier": "COMMANDS",
|
|
68
|
-
"strategy": "explicit",
|
|
69
|
-
"target": "./dist/cli.js"
|
|
70
|
-
},
|
|
71
|
-
"dirname": "block-tools",
|
|
72
|
-
"topicSeparator": " "
|
|
57
|
+
"@milaboratories/ts-builder": "1.6.0",
|
|
58
|
+
"@milaboratories/ts-configs": "1.3.0",
|
|
59
|
+
"@milaboratories/build-configs": "2.0.0"
|
|
73
60
|
},
|
|
74
61
|
"scripts": {
|
|
75
|
-
"oclif:index": "oclif-index --commands-root=./src/cmd/ --index-file=./src/cmd/index.ts && node --run fmt",
|
|
76
62
|
"build": "vite build",
|
|
77
|
-
"readme": "oclif readme",
|
|
78
63
|
"test": "vitest run --coverage",
|
|
79
64
|
"do-pack": "rm -f *.tgz && pnpm pack && mv *.tgz package.tgz",
|
|
80
65
|
"formatter:check": "ts-builder formatter --check",
|
package/src/cli.test.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import type { Command } from "commander";
|
|
3
|
+
import { buildProgram } from "./cli";
|
|
4
|
+
|
|
5
|
+
function subcommand(cmd: Command, name: string): Command {
|
|
6
|
+
const c = cmd.commands.find((x) => x.name() === name);
|
|
7
|
+
if (!c) throw new Error(`subcommand "${name}" not found`);
|
|
8
|
+
return c;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function longNames(cmd: Command): string[] {
|
|
12
|
+
return cmd.options.map((o) => o.long ?? o.short ?? o.name());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe("block-tools CLI structure", () => {
|
|
16
|
+
const program = buildProgram();
|
|
17
|
+
|
|
18
|
+
it("exposes the full command surface (10 commands + structure topic)", () => {
|
|
19
|
+
expect(program.commands.map((c) => c.name()).sort()).toEqual([
|
|
20
|
+
"build-meta",
|
|
21
|
+
"build-model",
|
|
22
|
+
"list-overview-snapshots",
|
|
23
|
+
"mark-stable",
|
|
24
|
+
"pack",
|
|
25
|
+
"publish",
|
|
26
|
+
"refresh-registry",
|
|
27
|
+
"restore-overview-from-snapshot",
|
|
28
|
+
"structure",
|
|
29
|
+
"update-deps",
|
|
30
|
+
"upload-package-v1",
|
|
31
|
+
]);
|
|
32
|
+
expect(
|
|
33
|
+
subcommand(program, "structure")
|
|
34
|
+
.commands.map((c) => c.name())
|
|
35
|
+
.sort(),
|
|
36
|
+
).toEqual(["check", "init", "refresh"]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("preserves key flags + env bindings", () => {
|
|
40
|
+
const publish = subcommand(program, "publish");
|
|
41
|
+
const pnames = longNames(publish);
|
|
42
|
+
for (const f of ["--registry", "--manifest", "--version-override", "--refresh", "--unstable"]) {
|
|
43
|
+
expect(pnames).toContain(f);
|
|
44
|
+
}
|
|
45
|
+
// --no-refresh negation and PL_REGISTRY env preserved
|
|
46
|
+
expect(pnames).toContain("--no-refresh");
|
|
47
|
+
expect(publish.options.find((o) => o.long === "--registry")?.envVar).toBe("PL_REGISTRY");
|
|
48
|
+
|
|
49
|
+
// structure init keeps its positional [path] and the with/no-software pair
|
|
50
|
+
const init = subcommand(subcommand(program, "structure"), "init");
|
|
51
|
+
const inames = longNames(init);
|
|
52
|
+
expect(inames).toContain("--with-software");
|
|
53
|
+
expect(inames).toContain("--no-software");
|
|
54
|
+
expect(init.registeredArguments.map((a) => a.name())).toContain("path");
|
|
55
|
+
});
|
|
56
|
+
});
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { buildMetaCommand } from "./cmd/build-meta";
|
|
3
|
+
import { buildModelCommand } from "./cmd/build-model";
|
|
4
|
+
import { packCommand } from "./cmd/pack";
|
|
5
|
+
import { publishCommand } from "./cmd/publish";
|
|
6
|
+
import { refreshRegistryCommand } from "./cmd/refresh-registry";
|
|
7
|
+
import { markStableCommand } from "./cmd/mark-stable";
|
|
8
|
+
import { updateDepsCommand } from "./cmd/update-deps";
|
|
9
|
+
import { listOverviewSnapshotsCommand } from "./cmd/list-overview-snapshots";
|
|
10
|
+
import { restoreOverviewFromSnapshotCommand } from "./cmd/restore-overview-from-snapshot";
|
|
11
|
+
import { uploadPackageV1Command } from "./cmd/upload-package-v1";
|
|
12
|
+
import { structureCheckCommand } from "./cmd/structure/check";
|
|
13
|
+
import { structureInitCommand } from "./cmd/structure/init";
|
|
14
|
+
import { structureRefreshCommand } from "./cmd/structure/refresh";
|
|
15
|
+
|
|
16
|
+
// `packageRoot` is the package install root (the dir containing `src/` and
|
|
17
|
+
// `bin/`); the `structure` commands resolve their templates under it. bin/run.js
|
|
18
|
+
// passes it in; defaults to cwd for tests/introspection.
|
|
19
|
+
export function buildProgram(packageRoot: string = process.cwd()): Command {
|
|
20
|
+
const program = new Command();
|
|
21
|
+
program
|
|
22
|
+
.name("block-tools")
|
|
23
|
+
.description("Utility to manipulate Platforma Blocks and Block Registry");
|
|
24
|
+
|
|
25
|
+
program.addCommand(buildMetaCommand());
|
|
26
|
+
program.addCommand(buildModelCommand());
|
|
27
|
+
program.addCommand(packCommand());
|
|
28
|
+
program.addCommand(publishCommand());
|
|
29
|
+
program.addCommand(refreshRegistryCommand());
|
|
30
|
+
program.addCommand(markStableCommand());
|
|
31
|
+
program.addCommand(updateDepsCommand(packageRoot));
|
|
32
|
+
program.addCommand(listOverviewSnapshotsCommand());
|
|
33
|
+
program.addCommand(restoreOverviewFromSnapshotCommand());
|
|
34
|
+
program.addCommand(uploadPackageV1Command());
|
|
35
|
+
|
|
36
|
+
// `structure` subcommands: check | init | refresh.
|
|
37
|
+
const structure = new Command("structure").description(
|
|
38
|
+
"Manage block scaffolding against the canonical structure (check / init / refresh)",
|
|
39
|
+
);
|
|
40
|
+
structure.addCommand(structureCheckCommand(packageRoot));
|
|
41
|
+
structure.addCommand(structureInitCommand(packageRoot));
|
|
42
|
+
structure.addCommand(structureRefreshCommand(packageRoot));
|
|
43
|
+
program.addCommand(structure);
|
|
44
|
+
|
|
45
|
+
return program;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function run(argv: string[], packageRoot: string): Promise<void> {
|
|
49
|
+
await buildProgram(packageRoot).parseAsync(argv);
|
|
50
|
+
}
|
package/src/cmd/build-meta.ts
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import { Command
|
|
1
|
+
import { Command } from "commander";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { loadPackDescriptionRaw } from "../v2";
|
|
5
5
|
import { embedBlockPackMetaAbsoluteBase64, resolveBlockPackMeta } from "../v2/model/block_meta";
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
export function buildMetaCommand(): Command {
|
|
8
|
+
const cmd = new Command("build-meta").description(
|
|
9
9
|
"Extracts meta information from blocks package.json and outputs meta.json with embedded binary " +
|
|
10
|
-
|
|
10
|
+
"and textual information linked from the meta section.",
|
|
11
|
+
);
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
char: "i",
|
|
15
|
-
summary: "input module path",
|
|
16
|
-
helpValue: "<path>",
|
|
17
|
-
default: ".",
|
|
18
|
-
}),
|
|
13
|
+
cmd.option("-i, --modulePath <path>", "input module path", ".");
|
|
14
|
+
cmd.requiredOption("-o, --destination <path>", "output meta.json file");
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
char: "o",
|
|
22
|
-
summary: "output meta.json file",
|
|
23
|
-
helpValue: "<path>",
|
|
24
|
-
required: true,
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
public async run(): Promise<void> {
|
|
29
|
-
const { flags } = await this.parse(BuildMeta);
|
|
16
|
+
cmd.action(async (flags) => {
|
|
30
17
|
const modulePath = path.resolve(flags.modulePath);
|
|
31
18
|
const descriptionRaw = await loadPackDescriptionRaw(modulePath);
|
|
32
19
|
const metaEmbedded = await embedBlockPackMetaAbsoluteBase64(
|
|
@@ -34,5 +21,7 @@ export default class BuildMeta extends Command {
|
|
|
34
21
|
);
|
|
35
22
|
|
|
36
23
|
await fs.promises.writeFile(path.resolve(flags.destination), JSON.stringify(metaEmbedded));
|
|
37
|
-
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return cmd;
|
|
38
27
|
}
|
package/src/cmd/build-model.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command
|
|
1
|
+
import { Command } from "commander";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
@@ -13,44 +13,26 @@ async function getFileContent(path: string) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
"Extracts and outputs block model JSON from pre-built block model module"
|
|
16
|
+
export function buildModelCommand(): Command {
|
|
17
|
+
const cmd = new Command("build-model").description(
|
|
18
|
+
"Extracts and outputs block model JSON from pre-built block model module",
|
|
19
|
+
);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
cmd.option("-i, --modulePath <path>", "input module path", ".");
|
|
22
|
+
cmd.option(
|
|
23
|
+
"-b, --sourceBundle <path>",
|
|
24
|
+
"bundled model code to embed into the model for callback-based rendering to work",
|
|
25
|
+
"./dist/bundle.js",
|
|
26
|
+
);
|
|
27
|
+
cmd.option("-o, --destination <path>", "output model file", "./dist/model.json");
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
char: "b",
|
|
30
|
-
summary: "bundled model code to embed into the model for callback-based rendering to work",
|
|
31
|
-
helpValue: "<path>",
|
|
32
|
-
default: "./dist/bundle.js",
|
|
33
|
-
}),
|
|
34
|
-
|
|
35
|
-
destination: Flags.string({
|
|
36
|
-
char: "o",
|
|
37
|
-
summary: "output model file",
|
|
38
|
-
helpValue: "<path>",
|
|
39
|
-
default: "./dist/model.json",
|
|
40
|
-
}),
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
public async run(): Promise<void> {
|
|
44
|
-
const { flags } = await this.parse(BuildModel);
|
|
29
|
+
cmd.action(async (flags) => {
|
|
45
30
|
const modulePath = path.resolve(flags.modulePath); // i.e. folder with package.json file
|
|
46
|
-
// eslint-disable-next-line prefer-const, @typescript-eslint/no-unsafe-assignment
|
|
47
31
|
let { model, platforma } = require(modulePath);
|
|
48
32
|
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
50
33
|
if (!model) model = platforma;
|
|
51
34
|
if (!model) throw new Error('"model" export not found');
|
|
52
35
|
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
54
36
|
const { config } = model;
|
|
55
37
|
|
|
56
38
|
if (!config)
|
|
@@ -64,7 +46,6 @@ export default class BuildModel extends Command {
|
|
|
64
46
|
|
|
65
47
|
const code = await getFileContent(flags.sourceBundle);
|
|
66
48
|
if (code !== undefined) {
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
68
49
|
config.code = {
|
|
69
50
|
type: "plain",
|
|
70
51
|
content: code,
|
|
@@ -72,5 +53,7 @@ export default class BuildModel extends Command {
|
|
|
72
53
|
}
|
|
73
54
|
|
|
74
55
|
await fs.promises.writeFile(path.resolve(flags.destination), JSON.stringify(config));
|
|
75
|
-
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return cmd;
|
|
76
59
|
}
|