@platforma-sdk/block-tools 2.6.44 → 2.6.45
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/README.md +16 -9
- package/bin/dev.js +4 -4
- package/bin/run.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +16 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/cmd/index.d.ts +8 -8
- package/dist/cmd/mark-stable.d.ts +1 -1
- package/dist/cmd/publish.d.ts +1 -1
- package/dist/cmd/restore-overview-from-snapshot.d.ts +1 -1
- package/dist/{config-DKBY0B2u.mjs → config-Cc8_zV3b.mjs} +48 -17
- package/dist/config-Cc8_zV3b.mjs.map +1 -0
- package/dist/config-Ycas5fbX.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/dist/registry_v1/config_schema.d.ts +7 -7
- package/dist/registry_v1/v1_repo_schema.d.ts +1 -1
- package/dist/v2/model/block_components.d.ts +19 -19
- package/dist/v2/model/block_description.d.ts +102 -102
- package/dist/v2/model/block_meta.d.ts +20 -20
- package/dist/v2/model/content_conversion.d.ts +2 -2
- package/dist/v2/registry/registry.d.ts +1 -1
- package/dist/v2/source_package.d.ts +1 -1
- package/package.json +31 -29
- package/src/cmd/build-meta.ts +15 -15
- package/src/cmd/build-model.ts +23 -26
- package/src/cmd/index.ts +20 -20
- package/src/cmd/list-overview-snapshots.ts +12 -12
- package/src/cmd/mark-stable.ts +30 -33
- package/src/cmd/pack.ts +15 -15
- package/src/cmd/publish.ts +46 -34
- package/src/cmd/refresh-registry.ts +15 -15
- package/src/cmd/restore-overview-from-snapshot.ts +27 -25
- package/src/cmd/update-deps.ts +8 -8
- package/src/cmd/upload-package-v1.ts +33 -33
- package/src/common_types.ts +1 -1
- package/src/io/folder_reader.test.ts +13 -13
- package/src/io/folder_reader.ts +18 -20
- package/src/io/index.ts +2 -2
- package/src/io/storage.test.ts +48 -48
- package/src/io/storage.ts +20 -15
- package/src/lib.ts +3 -3
- package/src/registry_v1/config.ts +11 -11
- package/src/registry_v1/config_schema.ts +5 -5
- package/src/registry_v1/flags.ts +4 -4
- package/src/registry_v1/index.ts +3 -3
- package/src/registry_v1/registry.test.ts +54 -54
- package/src/registry_v1/registry.ts +29 -25
- package/src/registry_v1/v1_repo_schema.ts +3 -3
- package/src/util.ts +6 -9
- package/src/v2/build_dist.test.ts +8 -9
- package/src/v2/build_dist.ts +10 -13
- package/src/v2/index.ts +4 -4
- package/src/v2/model/block_components.ts +5 -5
- package/src/v2/model/block_description.ts +12 -8
- package/src/v2/model/block_meta.ts +4 -5
- package/src/v2/model/content_conversion.ts +44 -44
- package/src/v2/model/index.ts +4 -4
- package/src/v2/registry/index.ts +3 -3
- package/src/v2/registry/registry.test.ts +223 -197
- package/src/v2/registry/registry.ts +93 -66
- package/src/v2/registry/registry_reader.test.ts +15 -15
- package/src/v2/registry/registry_reader.ts +29 -27
- package/src/v2/registry/schema_internal.ts +11 -10
- package/src/v2/registry/schema_public.ts +56 -47
- package/src/v2/source_package.test.ts +15 -15
- package/src/v2/source_package.ts +33 -26
- package/dist/config-DKBY0B2u.mjs.map +0 -1
package/src/cmd/mark-stable.ts
CHANGED
|
@@ -1,53 +1,50 @@
|
|
|
1
|
-
import { Command, Flags } from
|
|
2
|
-
import { BlockRegistryV2, loadPackDescriptionRaw } from
|
|
3
|
-
import path from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@milaboratories/pl-model-middle-layer';
|
|
8
|
-
import { storageByUrl } from '../io';
|
|
9
|
-
import { OclifLoggerAdapter } from '@milaboratories/ts-helpers-oclif';
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { BlockRegistryV2, loadPackDescriptionRaw } from "../v2";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { overrideDescriptionVersion, StableChannel } from "@milaboratories/pl-model-middle-layer";
|
|
5
|
+
import { storageByUrl } from "../io";
|
|
6
|
+
import { OclifLoggerAdapter } from "@milaboratories/ts-helpers-oclif";
|
|
10
7
|
|
|
11
8
|
export default class MarkStable extends Command {
|
|
12
|
-
static description =
|
|
9
|
+
static description = "Mark target block stable";
|
|
13
10
|
|
|
14
11
|
static flags = {
|
|
15
|
-
|
|
16
|
-
char:
|
|
17
|
-
summary:
|
|
18
|
-
helpValue:
|
|
19
|
-
default:
|
|
12
|
+
modulePath: Flags.string({
|
|
13
|
+
char: "i",
|
|
14
|
+
summary: "input module path",
|
|
15
|
+
helpValue: "<path>",
|
|
16
|
+
default: ".",
|
|
20
17
|
}),
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
char:
|
|
19
|
+
channel: Flags.string({
|
|
20
|
+
char: "c",
|
|
24
21
|
hidden: true,
|
|
25
|
-
summary:
|
|
26
|
-
helpValue:
|
|
22
|
+
summary: "custom channel",
|
|
23
|
+
helpValue: "<channel name>",
|
|
27
24
|
default: StableChannel,
|
|
28
25
|
}),
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
char:
|
|
32
|
-
summary:
|
|
27
|
+
"version-override": Flags.file({
|
|
28
|
+
char: "v",
|
|
29
|
+
summary: "override package version",
|
|
33
30
|
}),
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
char:
|
|
37
|
-
summary:
|
|
38
|
-
helpValue:
|
|
39
|
-
env:
|
|
32
|
+
registry: Flags.string({
|
|
33
|
+
char: "r",
|
|
34
|
+
summary: "full address of the registry",
|
|
35
|
+
helpValue: "<address>",
|
|
36
|
+
env: "PL_REGISTRY",
|
|
40
37
|
required: true,
|
|
41
38
|
}),
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
summary:
|
|
40
|
+
refresh: Flags.boolean({
|
|
41
|
+
summary: "refresh repository after adding the package",
|
|
45
42
|
default: true,
|
|
46
43
|
allowNo: true,
|
|
47
|
-
env:
|
|
44
|
+
env: "PL_REGISTRY_REFRESH",
|
|
48
45
|
}),
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
unmark: Flags.boolean({
|
|
51
48
|
summary:
|
|
52
49
|
'reverses meaning of this command, flag can be used to remove "stable" flag from the package',
|
|
53
50
|
default: false,
|
|
@@ -57,8 +54,8 @@ export default class MarkStable extends Command {
|
|
|
57
54
|
public async run(): Promise<void> {
|
|
58
55
|
const { flags } = await this.parse(MarkStable);
|
|
59
56
|
let description = await loadPackDescriptionRaw(path.resolve(flags.modulePath));
|
|
60
|
-
if (flags[
|
|
61
|
-
description = overrideDescriptionVersion(description, flags[
|
|
57
|
+
if (flags["version-override"])
|
|
58
|
+
description = overrideDescriptionVersion(description, flags["version-override"]);
|
|
62
59
|
const storage = storageByUrl(flags.registry);
|
|
63
60
|
const registry = new BlockRegistryV2(storage, new OclifLoggerAdapter(this));
|
|
64
61
|
|
package/src/cmd/pack.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Command, Flags } from
|
|
2
|
-
import { loadPackDescription } from
|
|
3
|
-
import path from
|
|
4
|
-
import { buildBlockPackDist } from
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { loadPackDescription } from "../v2/source_package";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { buildBlockPackDist } from "../v2/build_dist";
|
|
5
5
|
|
|
6
6
|
export default class PackBlock extends Command {
|
|
7
|
-
static description
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
static description =
|
|
8
|
+
"Builds block pack and outputs a block pack manifest consolidating all " +
|
|
9
|
+
"references assets into a single folder";
|
|
10
10
|
|
|
11
11
|
static flags = {
|
|
12
12
|
modulePath: Flags.string({
|
|
13
|
-
char:
|
|
14
|
-
summary:
|
|
15
|
-
helpValue:
|
|
16
|
-
default:
|
|
13
|
+
char: "i",
|
|
14
|
+
summary: "input module path",
|
|
15
|
+
helpValue: "<path>",
|
|
16
|
+
default: ".",
|
|
17
17
|
}),
|
|
18
18
|
|
|
19
19
|
destinationPath: Flags.string({
|
|
20
|
-
char:
|
|
21
|
-
summary:
|
|
22
|
-
helpValue:
|
|
23
|
-
default:
|
|
20
|
+
char: "o",
|
|
21
|
+
summary: "output folder",
|
|
22
|
+
helpValue: "<path>",
|
|
23
|
+
default: "./block-pack",
|
|
24
24
|
}),
|
|
25
25
|
};
|
|
26
26
|
|
package/src/cmd/publish.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Command, Flags } from
|
|
2
|
-
import fs from
|
|
3
|
-
import { OclifLoggerAdapter } from
|
|
4
|
-
import { ManifestFileName } from
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { OclifLoggerAdapter } from "@milaboratories/ts-helpers-oclif";
|
|
4
|
+
import { ManifestFileName } from "../v2/registry/schema_public";
|
|
5
|
+
import {
|
|
6
|
+
BlockPackManifest,
|
|
7
|
+
overrideManifestVersion,
|
|
8
|
+
StableChannel,
|
|
9
|
+
} from "@milaboratories/pl-model-middle-layer";
|
|
10
|
+
import { storageByUrl } from "../io/storage";
|
|
11
|
+
import { BlockRegistryV2 } from "../v2/registry/registry";
|
|
12
|
+
import path from "node:path";
|
|
9
13
|
|
|
10
14
|
function simpleDeepMerge<T extends Record<string, unknown>>(
|
|
11
15
|
target: Record<string, unknown>,
|
|
@@ -14,9 +18,12 @@ function simpleDeepMerge<T extends Record<string, unknown>>(
|
|
|
14
18
|
const result = { ...target };
|
|
15
19
|
|
|
16
20
|
for (const key in source) {
|
|
17
|
-
if (source[key] && typeof source[key] ===
|
|
18
|
-
if (result[key] && typeof result[key] ===
|
|
19
|
-
result[key] = simpleDeepMerge(
|
|
21
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
22
|
+
if (result[key] && typeof result[key] === "object" && !Array.isArray(result[key])) {
|
|
23
|
+
result[key] = simpleDeepMerge(
|
|
24
|
+
result[key] as Record<string, unknown>,
|
|
25
|
+
source[key] as Record<string, unknown>,
|
|
26
|
+
);
|
|
20
27
|
} else {
|
|
21
28
|
result[key] = source[key];
|
|
22
29
|
}
|
|
@@ -29,41 +36,41 @@ function simpleDeepMerge<T extends Record<string, unknown>>(
|
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
export default class Publish extends Command {
|
|
32
|
-
static description
|
|
33
|
-
|
|
39
|
+
static description =
|
|
40
|
+
"Publishes the block package and refreshes the registry (for v2 block-pack schema)";
|
|
34
41
|
|
|
35
42
|
static flags = {
|
|
36
|
-
|
|
37
|
-
char:
|
|
38
|
-
summary:
|
|
39
|
-
helpValue:
|
|
40
|
-
env:
|
|
43
|
+
registry: Flags.string({
|
|
44
|
+
char: "r",
|
|
45
|
+
summary: "full address of the registry",
|
|
46
|
+
helpValue: "<address>",
|
|
47
|
+
env: "PL_REGISTRY",
|
|
41
48
|
required: true,
|
|
42
49
|
}),
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
char:
|
|
46
|
-
summary:
|
|
51
|
+
manifest: Flags.file({
|
|
52
|
+
char: "m",
|
|
53
|
+
summary: "manifest file path",
|
|
47
54
|
exists: true,
|
|
48
55
|
default: `./block-pack/${ManifestFileName}`,
|
|
49
56
|
}),
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
char:
|
|
53
|
-
summary:
|
|
58
|
+
"version-override": Flags.file({
|
|
59
|
+
char: "v",
|
|
60
|
+
summary: "override package version",
|
|
54
61
|
}),
|
|
55
62
|
|
|
56
|
-
|
|
57
|
-
summary:
|
|
63
|
+
refresh: Flags.boolean({
|
|
64
|
+
summary: "refresh repository after adding the package",
|
|
58
65
|
default: true,
|
|
59
66
|
allowNo: true,
|
|
60
|
-
env:
|
|
67
|
+
env: "PL_REGISTRY_REFRESH",
|
|
61
68
|
}),
|
|
62
69
|
|
|
63
|
-
|
|
64
|
-
summary:
|
|
70
|
+
unstable: Flags.boolean({
|
|
71
|
+
summary: "do not add the published package to stable channel",
|
|
65
72
|
default: false,
|
|
66
|
-
env:
|
|
73
|
+
env: "PL_PUBLISH_UNSTABLE",
|
|
67
74
|
}),
|
|
68
75
|
};
|
|
69
76
|
|
|
@@ -71,16 +78,21 @@ export default class Publish extends Command {
|
|
|
71
78
|
const { flags } = await this.parse(Publish);
|
|
72
79
|
|
|
73
80
|
const manifestPath = path.resolve(flags.manifest);
|
|
74
|
-
const rawManifest = JSON.parse(
|
|
81
|
+
const rawManifest = JSON.parse(
|
|
82
|
+
await fs.promises.readFile(manifestPath, { encoding: "utf-8" }),
|
|
83
|
+
) as Record<string, unknown>;
|
|
75
84
|
let manifest = BlockPackManifest.parse(rawManifest);
|
|
76
85
|
// To keep extra fields from the manifest and keep coerced fields
|
|
77
|
-
manifest = simpleDeepMerge(
|
|
86
|
+
manifest = simpleDeepMerge(
|
|
87
|
+
rawManifest,
|
|
88
|
+
manifest as BlockPackManifest & Record<string, unknown>,
|
|
89
|
+
);
|
|
78
90
|
const manifestRoot = path.dirname(manifestPath);
|
|
79
91
|
|
|
80
92
|
this.log(`Manifest root = ${manifestRoot}`);
|
|
81
93
|
|
|
82
|
-
if (flags[
|
|
83
|
-
manifest = overrideManifestVersion(manifest, flags[
|
|
94
|
+
if (flags["version-override"])
|
|
95
|
+
manifest = overrideManifestVersion(manifest, flags["version-override"]);
|
|
84
96
|
|
|
85
97
|
const storage = storageByUrl(flags.registry);
|
|
86
98
|
const registry = new BlockRegistryV2(storage, new OclifLoggerAdapter(this));
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Command, Flags } from
|
|
2
|
-
import { BlockRegistryV2 } from
|
|
3
|
-
import { storageByUrl } from
|
|
4
|
-
import { OclifLoggerAdapter } from
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { BlockRegistryV2 } from "../v2";
|
|
3
|
+
import { storageByUrl } from "../io";
|
|
4
|
+
import { OclifLoggerAdapter } from "@milaboratories/ts-helpers-oclif";
|
|
5
5
|
|
|
6
6
|
export default class RefreshRegistry extends Command {
|
|
7
|
-
static description =
|
|
7
|
+
static description = "Refresh overview files based on published but not proecessed artefacts";
|
|
8
8
|
|
|
9
9
|
static flags = {
|
|
10
10
|
registry: Flags.string({
|
|
11
|
-
char:
|
|
12
|
-
summary:
|
|
13
|
-
helpValue:
|
|
14
|
-
env:
|
|
11
|
+
char: "r",
|
|
12
|
+
summary: "full address of the registry",
|
|
13
|
+
helpValue: "<address>",
|
|
14
|
+
env: "PL_REGISTRY",
|
|
15
15
|
required: true,
|
|
16
16
|
}),
|
|
17
17
|
|
|
18
18
|
mode: Flags.string({
|
|
19
|
-
char:
|
|
19
|
+
char: "m",
|
|
20
20
|
summary: 'refresh mode (allowed valiues: "force", "normal", "dry-run")',
|
|
21
|
-
helpValue:
|
|
22
|
-
options: [
|
|
23
|
-
env:
|
|
24
|
-
default:
|
|
21
|
+
helpValue: "<mode>",
|
|
22
|
+
options: ["force", "normal", "dry-run"],
|
|
23
|
+
env: "PL_REGISTRY_REFRESH_DRY_RUN",
|
|
24
|
+
default: "normal",
|
|
25
25
|
}),
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -29,6 +29,6 @@ export default class RefreshRegistry extends Command {
|
|
|
29
29
|
const { flags } = await this.parse(RefreshRegistry);
|
|
30
30
|
const storage = storageByUrl(flags.registry);
|
|
31
31
|
const registry = new BlockRegistryV2(storage, new OclifLoggerAdapter(this));
|
|
32
|
-
await registry.updateIfNeeded(flags.mode as
|
|
32
|
+
await registry.updateIfNeeded(flags.mode as "force" | "normal" | "dry-run");
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { Command, Flags } from
|
|
2
|
-
import { BlockRegistryV2 } from
|
|
3
|
-
import { storageByUrl } from
|
|
4
|
-
import { OclifLoggerAdapter } from
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { BlockRegistryV2 } from "../v2/registry/registry";
|
|
3
|
+
import { storageByUrl } from "../io/storage";
|
|
4
|
+
import { OclifLoggerAdapter } from "@milaboratories/ts-helpers-oclif";
|
|
5
5
|
|
|
6
6
|
export default class RestoreOverviewFromSnapshot extends Command {
|
|
7
|
-
static description =
|
|
7
|
+
static description = "Restore global overview from a snapshot";
|
|
8
8
|
|
|
9
9
|
static flags = {
|
|
10
|
-
|
|
11
|
-
char:
|
|
12
|
-
summary:
|
|
13
|
-
helpValue:
|
|
14
|
-
env:
|
|
10
|
+
registry: Flags.string({
|
|
11
|
+
char: "r",
|
|
12
|
+
summary: "full address of the registry",
|
|
13
|
+
helpValue: "<address>",
|
|
14
|
+
env: "PL_REGISTRY",
|
|
15
15
|
required: true,
|
|
16
16
|
}),
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
char:
|
|
20
|
-
summary:
|
|
21
|
-
helpValue:
|
|
18
|
+
snapshot: Flags.string({
|
|
19
|
+
char: "s",
|
|
20
|
+
summary: "snapshot timestamp ID to restore from",
|
|
21
|
+
helpValue: "<timestamp>",
|
|
22
22
|
required: true,
|
|
23
23
|
}),
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
summary:
|
|
25
|
+
"skip-confirmation": Flags.boolean({
|
|
26
|
+
summary: "skip confirmation prompt (use with caution)",
|
|
27
27
|
default: false,
|
|
28
28
|
}),
|
|
29
29
|
};
|
|
@@ -38,14 +38,16 @@ export default class RestoreOverviewFromSnapshot extends Command {
|
|
|
38
38
|
const targetSnapshot = snapshots.find((s) => s.timestamp === flags.snapshot);
|
|
39
39
|
|
|
40
40
|
if (!targetSnapshot) {
|
|
41
|
-
this.error(
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
this.error(
|
|
42
|
+
`Snapshot '${flags.snapshot}' not found. Available snapshots:\n${
|
|
43
|
+
snapshots.map((s) => ` - ${s.timestamp}`).join("\n") || " (none)"
|
|
44
|
+
}`,
|
|
45
|
+
);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
// Confirmation prompt (unless skipped)
|
|
47
|
-
if (!flags[
|
|
48
|
-
const readline = await import(
|
|
49
|
+
if (!flags["skip-confirmation"]) {
|
|
50
|
+
const readline = await import("node:readline");
|
|
49
51
|
const rl = readline.createInterface({
|
|
50
52
|
input: process.stdin,
|
|
51
53
|
output: process.stdout,
|
|
@@ -53,16 +55,16 @@ export default class RestoreOverviewFromSnapshot extends Command {
|
|
|
53
55
|
|
|
54
56
|
const answer = await new Promise<string>((resolve) => {
|
|
55
57
|
rl.question(
|
|
56
|
-
`⚠️ This will overwrite the current global overview with snapshot '${flags.snapshot}'.\n`
|
|
57
|
-
|
|
58
|
+
`⚠️ This will overwrite the current global overview with snapshot '${flags.snapshot}'.\n` +
|
|
59
|
+
`Are you sure you want to continue? (y/N): `,
|
|
58
60
|
resolve,
|
|
59
61
|
);
|
|
60
62
|
});
|
|
61
63
|
|
|
62
64
|
rl.close();
|
|
63
65
|
|
|
64
|
-
if (answer.toLowerCase() !==
|
|
65
|
-
this.log(
|
|
66
|
+
if (answer.toLowerCase() !== "y" && answer.toLowerCase() !== "yes") {
|
|
67
|
+
this.log("Restore cancelled.");
|
|
66
68
|
return;
|
|
67
69
|
}
|
|
68
70
|
}
|
package/src/cmd/update-deps.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Command } from
|
|
2
|
-
import { execFileSync } from
|
|
3
|
-
import { createRequire } from
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
4
|
|
|
5
5
|
export default class UpdateDeps extends Command {
|
|
6
|
-
static override description
|
|
7
|
-
|
|
6
|
+
static override description =
|
|
7
|
+
"Updates @platforma-sdk and @milaboratories packages in pnpm-workspace.yaml catalog to their latest versions from npm registry.";
|
|
8
8
|
|
|
9
|
-
static override examples = [
|
|
9
|
+
static override examples = ["<%= config.bin %> <%= command.id %>"];
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/require-await -- oclif requires async but implementation is sync
|
|
12
12
|
public async run(): Promise<void> {
|
|
13
13
|
const require = createRequire(import.meta.url);
|
|
14
|
-
const updaterPath = require.resolve(
|
|
14
|
+
const updaterPath = require.resolve("@platforma-sdk/blocks-deps-updater/scripts/updater.js");
|
|
15
15
|
|
|
16
16
|
execFileSync(process.execPath, [updaterPath], {
|
|
17
|
-
stdio:
|
|
17
|
+
stdio: "inherit",
|
|
18
18
|
cwd: process.cwd(),
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { Command, Flags } from
|
|
2
|
-
import { getConfig } from
|
|
3
|
-
import { targetFile } from
|
|
4
|
-
import fs from
|
|
5
|
-
import YAML from
|
|
6
|
-
import { PlRegPackageConfigDataShard } from
|
|
7
|
-
import { OclifLoggerAdapter } from
|
|
1
|
+
import { Command, Flags } from "@oclif/core";
|
|
2
|
+
import { getConfig } from "../registry_v1/config";
|
|
3
|
+
import { targetFile } from "../registry_v1/flags";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import YAML from "yaml";
|
|
6
|
+
import { PlRegPackageConfigDataShard } from "../registry_v1/config_schema";
|
|
7
|
+
import { OclifLoggerAdapter } from "@milaboratories/ts-helpers-oclif";
|
|
8
8
|
|
|
9
9
|
type BasicConfigField = keyof PlRegPackageConfigDataShard &
|
|
10
|
-
(
|
|
11
|
-
const BasicConfigFields: BasicConfigField[] = [
|
|
10
|
+
("registry" | "organization" | "package" | "version");
|
|
11
|
+
const BasicConfigFields: BasicConfigField[] = ["registry", "organization", "package", "version"];
|
|
12
12
|
|
|
13
13
|
export default class UploadPackageV1 extends Command {
|
|
14
|
-
static description =
|
|
14
|
+
static description = "Uploads V1 package and refreshes the registry";
|
|
15
15
|
|
|
16
16
|
static flags = {
|
|
17
17
|
registry: Flags.string({
|
|
18
|
-
char:
|
|
19
|
-
summary:
|
|
20
|
-
helpValue:
|
|
21
|
-
env:
|
|
18
|
+
char: "r",
|
|
19
|
+
summary: "full address of the registry or alias from .pl.reg",
|
|
20
|
+
helpValue: "<address|alias>",
|
|
21
|
+
env: "PL_REGISTRY",
|
|
22
22
|
}),
|
|
23
23
|
|
|
24
24
|
organization: Flags.string({
|
|
25
|
-
char:
|
|
26
|
-
summary:
|
|
27
|
-
env:
|
|
25
|
+
char: "o",
|
|
26
|
+
summary: "target organisation",
|
|
27
|
+
env: "PL_PACKAGE_ORGANIZATION",
|
|
28
28
|
}),
|
|
29
29
|
|
|
30
30
|
package: Flags.string({
|
|
31
|
-
char:
|
|
32
|
-
summary:
|
|
33
|
-
env:
|
|
31
|
+
char: "p",
|
|
32
|
+
summary: "target package",
|
|
33
|
+
env: "PL_PACKAGE_NAME",
|
|
34
34
|
}),
|
|
35
35
|
|
|
36
36
|
version: Flags.string({
|
|
37
|
-
char:
|
|
38
|
-
summary:
|
|
39
|
-
env:
|
|
37
|
+
char: "v",
|
|
38
|
+
summary: "target version",
|
|
39
|
+
env: "PL_PACKAGE_VERSION",
|
|
40
40
|
}),
|
|
41
41
|
|
|
42
42
|
meta: Flags.file({
|
|
43
|
-
char:
|
|
44
|
-
summary:
|
|
43
|
+
char: "m",
|
|
44
|
+
summary: "json file containing meta information to associate with tha package",
|
|
45
45
|
exists: true,
|
|
46
46
|
}),
|
|
47
47
|
|
|
48
48
|
file: targetFile({
|
|
49
|
-
char:
|
|
50
|
-
summary:
|
|
49
|
+
char: "f",
|
|
50
|
+
summary: "package files",
|
|
51
51
|
multiple: true,
|
|
52
52
|
default: [],
|
|
53
53
|
}),
|
|
54
54
|
|
|
55
55
|
refresh: Flags.boolean({
|
|
56
|
-
summary:
|
|
56
|
+
summary: "refresh repository after adding the package",
|
|
57
57
|
default: true,
|
|
58
58
|
allowNo: true,
|
|
59
|
-
env:
|
|
59
|
+
env: "PL_REGISTRY_REFRESH",
|
|
60
60
|
}),
|
|
61
61
|
};
|
|
62
62
|
|
|
@@ -67,13 +67,13 @@ export default class UploadPackageV1 extends Command {
|
|
|
67
67
|
for (const field of BasicConfigFields) if (flags[field]) configFromFlags[field] = flags[field];
|
|
68
68
|
|
|
69
69
|
if (flags.meta) {
|
|
70
|
-
if (flags.meta.endsWith(
|
|
70
|
+
if (flags.meta.endsWith(".json"))
|
|
71
71
|
configFromFlags.meta = JSON.parse(
|
|
72
|
-
await fs.promises.readFile(flags.meta, { encoding:
|
|
72
|
+
await fs.promises.readFile(flags.meta, { encoding: "utf-8" }),
|
|
73
73
|
) as Record<string, unknown>;
|
|
74
|
-
else if (flags.meta.endsWith(
|
|
74
|
+
else if (flags.meta.endsWith(".yaml"))
|
|
75
75
|
configFromFlags.meta = YAML.parse(
|
|
76
|
-
await fs.promises.readFile(flags.meta, { encoding:
|
|
76
|
+
await fs.promises.readFile(flags.meta, { encoding: "utf-8" }),
|
|
77
77
|
) as Record<string, unknown>;
|
|
78
78
|
}
|
|
79
79
|
|
package/src/common_types.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { expect, test } from
|
|
2
|
-
import { folderReaderByUrl } from
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { folderReaderByUrl } from "./folder_reader";
|
|
3
3
|
|
|
4
|
-
test(
|
|
5
|
-
const reader = folderReaderByUrl(
|
|
6
|
-
const content = await reader.getContentReader()(
|
|
4
|
+
test("test fs reader", async () => {
|
|
5
|
+
const reader = folderReaderByUrl("file:.");
|
|
6
|
+
const content = await reader.getContentReader()("package.json");
|
|
7
7
|
expect(content).toBeDefined();
|
|
8
8
|
expect(content.length).toBeGreaterThan(10);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
test(
|
|
12
|
-
const reader = folderReaderByUrl(
|
|
13
|
-
const content = await reader.getContentReader()(
|
|
14
|
-
expect(content?.toString(
|
|
11
|
+
test("test url reader with slash", async () => {
|
|
12
|
+
const reader = folderReaderByUrl("https://cdn.milaboratory.com/");
|
|
13
|
+
const content = await reader.getContentReader()("ping");
|
|
14
|
+
expect(content?.toString("utf8")).toStrictEqual("pong");
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
test(
|
|
18
|
-
const reader = folderReaderByUrl(
|
|
19
|
-
const content = await reader.getContentReader()(
|
|
20
|
-
expect(content?.toString(
|
|
17
|
+
test("test url reader without slash", async () => {
|
|
18
|
+
const reader = folderReaderByUrl("https://cdn.milaboratory.com");
|
|
19
|
+
const content = await reader.getContentReader()("ping");
|
|
20
|
+
expect(content?.toString("utf8")).toStrictEqual("pong");
|
|
21
21
|
});
|