@platforma-sdk/block-tools 2.11.2 → 2.11.3
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 +12 -12
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +740 -930
- 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-DpfTzcgG.mjs.map +1 -1
- package/dist/config-xxVy3IQR.js.map +1 -1
- 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/v2/registry/schema_public.d.ts +3600 -3600
- package/package.json +4 -19
- 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.ts +35 -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/cli/run-structure.ts +2 -2
- package/src/v2/model/content_conversion.ts +0 -1
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -6
- package/dist/cmd/index.d.ts +0 -28
- package/src/cmd/index.ts +0 -31
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import { Command,
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
2
|
import { BlockRegistryV2 } from "../v2";
|
|
3
3
|
import { storageByUrl } from "../io";
|
|
4
|
-
import {
|
|
4
|
+
import { ConsoleLoggerAdapter } from "@milaboratories/ts-helpers";
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
6
|
+
export function refreshRegistryCommand(): Command {
|
|
7
|
+
const cmd = new Command("refresh-registry").description(
|
|
8
|
+
"Refresh overview files based on published but not proecessed artefacts",
|
|
9
|
+
);
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
registry
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
cmd.addOption(
|
|
12
|
+
new Option("-r, --registry <address>", "full address of the registry")
|
|
13
|
+
.env("PL_REGISTRY")
|
|
14
|
+
.makeOptionMandatory(),
|
|
15
|
+
);
|
|
16
|
+
cmd.addOption(
|
|
17
|
+
new Option("-m, --mode <mode>", 'refresh mode (allowed valiues: "force", "normal", "dry-run")')
|
|
18
|
+
.choices(["force", "normal", "dry-run"])
|
|
19
|
+
.env("PL_REGISTRY_REFRESH_DRY_RUN")
|
|
20
|
+
.default("normal"),
|
|
21
|
+
);
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
char: "m",
|
|
20
|
-
summary: 'refresh mode (allowed valiues: "force", "normal", "dry-run")',
|
|
21
|
-
helpValue: "<mode>",
|
|
22
|
-
options: ["force", "normal", "dry-run"],
|
|
23
|
-
env: "PL_REGISTRY_REFRESH_DRY_RUN",
|
|
24
|
-
default: "normal",
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
public async run(): Promise<void> {
|
|
29
|
-
const { flags } = await this.parse(RefreshRegistry);
|
|
23
|
+
cmd.action(async (flags) => {
|
|
30
24
|
const storage = storageByUrl(flags.registry);
|
|
31
|
-
const registry = new BlockRegistryV2(storage, new
|
|
25
|
+
const registry = new BlockRegistryV2(storage, new ConsoleLoggerAdapter());
|
|
32
26
|
await registry.updateIfNeeded(flags.mode as "force" | "normal" | "dry-run");
|
|
33
|
-
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return cmd;
|
|
34
30
|
}
|
|
@@ -1,44 +1,32 @@
|
|
|
1
|
-
import { Command,
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
2
|
import { BlockRegistryV2 } from "../v2/registry/registry";
|
|
3
3
|
import { storageByUrl } from "../io/storage";
|
|
4
|
-
import {
|
|
4
|
+
import { ConsoleLoggerAdapter } from "@milaboratories/ts-helpers";
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
6
|
+
export function restoreOverviewFromSnapshotCommand(): Command {
|
|
7
|
+
const cmd = new Command("restore-overview-from-snapshot").description(
|
|
8
|
+
"Restore global overview from a snapshot",
|
|
9
|
+
);
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
registry
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}),
|
|
11
|
+
cmd.addOption(
|
|
12
|
+
new Option("-r, --registry <address>", "full address of the registry")
|
|
13
|
+
.env("PL_REGISTRY")
|
|
14
|
+
.makeOptionMandatory(),
|
|
15
|
+
);
|
|
16
|
+
cmd.requiredOption("-s, --snapshot <timestamp>", "snapshot timestamp ID to restore from");
|
|
17
|
+
cmd.option("--skip-confirmation", "skip confirmation prompt (use with caution)", false);
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
summary: "snapshot timestamp ID to restore from",
|
|
21
|
-
helpValue: "<timestamp>",
|
|
22
|
-
required: true,
|
|
23
|
-
}),
|
|
24
|
-
|
|
25
|
-
"skip-confirmation": Flags.boolean({
|
|
26
|
-
summary: "skip confirmation prompt (use with caution)",
|
|
27
|
-
default: false,
|
|
28
|
-
}),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
public async run(): Promise<void> {
|
|
32
|
-
const { flags } = await this.parse(RestoreOverviewFromSnapshot);
|
|
19
|
+
cmd.action(async (flags) => {
|
|
20
|
+
const logger = new ConsoleLoggerAdapter();
|
|
33
21
|
const storage = storageByUrl(flags.registry);
|
|
34
|
-
const registry = new BlockRegistryV2(storage,
|
|
22
|
+
const registry = new BlockRegistryV2(storage, logger);
|
|
35
23
|
|
|
36
24
|
// Check if snapshot exists
|
|
37
25
|
const snapshots = await registry.listGlobalOverviewSnapshots();
|
|
38
26
|
const targetSnapshot = snapshots.find((s) => s.timestamp === flags.snapshot);
|
|
39
27
|
|
|
40
28
|
if (!targetSnapshot) {
|
|
41
|
-
|
|
29
|
+
throw new Error(
|
|
42
30
|
`Snapshot '${flags.snapshot}' not found. Available snapshots:\n${
|
|
43
31
|
snapshots.map((s) => ` - ${s.timestamp}`).join("\n") || " (none)"
|
|
44
32
|
}`,
|
|
@@ -46,7 +34,7 @@ export default class RestoreOverviewFromSnapshot extends Command {
|
|
|
46
34
|
}
|
|
47
35
|
|
|
48
36
|
// Confirmation prompt (unless skipped)
|
|
49
|
-
if (!flags
|
|
37
|
+
if (!flags.skipConfirmation) {
|
|
50
38
|
const readline = await import("node:readline");
|
|
51
39
|
const rl = readline.createInterface({
|
|
52
40
|
input: process.stdin,
|
|
@@ -64,7 +52,7 @@ export default class RestoreOverviewFromSnapshot extends Command {
|
|
|
64
52
|
rl.close();
|
|
65
53
|
|
|
66
54
|
if (answer.toLowerCase() !== "y" && answer.toLowerCase() !== "yes") {
|
|
67
|
-
|
|
55
|
+
logger.info("Restore cancelled.");
|
|
68
56
|
return;
|
|
69
57
|
}
|
|
70
58
|
}
|
|
@@ -72,9 +60,11 @@ export default class RestoreOverviewFromSnapshot extends Command {
|
|
|
72
60
|
// Perform restore
|
|
73
61
|
try {
|
|
74
62
|
await registry.restoreGlobalOverviewFromSnapshot(flags.snapshot);
|
|
75
|
-
|
|
63
|
+
logger.info(`✅ Successfully restored global overview from snapshot '${flags.snapshot}'`);
|
|
76
64
|
} catch (error) {
|
|
77
|
-
|
|
65
|
+
throw new Error(`Failed to restore from snapshot: ${String(error)}`);
|
|
78
66
|
}
|
|
79
|
-
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return cmd;
|
|
80
70
|
}
|
|
@@ -1,51 +1,42 @@
|
|
|
1
|
-
import { Command
|
|
1
|
+
import { Command } from "commander";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { ConsoleLoggerAdapter } from "@milaboratories/ts-helpers";
|
|
3
4
|
import { runStructureForPath, formatChanges } from "../../structure/cli/run-structure";
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
"Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate."
|
|
8
|
-
|
|
9
|
-
static override examples = [
|
|
10
|
-
"<%= config.bin %> <%= command.id %> ./my-block",
|
|
11
|
-
"<%= config.bin %> <%= command.id %> --sdk-internal etc/blocks/*",
|
|
12
|
-
];
|
|
6
|
+
export function structureCheckCommand(packageRoot: string): Command {
|
|
7
|
+
const cmd = new Command("check").description(
|
|
8
|
+
"Check block(s) against the canonical structure (read-only). Exits non-zero if any diff would land — used as the CI gate.",
|
|
9
|
+
);
|
|
13
10
|
|
|
14
11
|
// Variadic positional block paths (shell-expanded globs).
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
static override flags = {
|
|
18
|
-
"sdk-internal": Flags.boolean({
|
|
19
|
-
description: "block(s) live inside the SDK monorepo; skip root-scope rules",
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
12
|
+
cmd.argument("[paths...]", "block path(s); defaults to the current directory");
|
|
13
|
+
cmd.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules");
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const paths =
|
|
26
|
-
const templatesRoot = path.join(
|
|
15
|
+
cmd.action(async (argv: string[], flags) => {
|
|
16
|
+
const logger = new ConsoleLoggerAdapter();
|
|
17
|
+
const paths = argv.length > 0 ? argv : ["."];
|
|
18
|
+
const templatesRoot = path.join(packageRoot, "src", "structure", "templates");
|
|
27
19
|
|
|
28
20
|
let anyChanged = false;
|
|
29
21
|
for (const p of paths) {
|
|
30
22
|
const res = await runStructureForPath({
|
|
31
23
|
blockPath: p,
|
|
32
|
-
isSdkInternal: flags
|
|
24
|
+
isSdkInternal: Boolean(flags.sdkInternal),
|
|
33
25
|
updateDepsOnly: false,
|
|
34
26
|
mode: "check",
|
|
35
27
|
templatesRoot,
|
|
36
|
-
log: (m) =>
|
|
28
|
+
log: (m) => logger.info(m),
|
|
37
29
|
});
|
|
38
|
-
|
|
30
|
+
logger.info(formatChanges(p, res.changes));
|
|
39
31
|
if (res.changes.length > 0) anyChanged = true;
|
|
40
32
|
}
|
|
41
33
|
|
|
42
34
|
if (anyChanged) {
|
|
43
|
-
|
|
35
|
+
throw new Error(
|
|
44
36
|
"Structure check failed: one or more blocks are out of date. Run `structure refresh`.",
|
|
45
|
-
{
|
|
46
|
-
exit: 1,
|
|
47
|
-
},
|
|
48
37
|
);
|
|
49
38
|
}
|
|
50
|
-
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return cmd;
|
|
51
42
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { ConsoleLoggerAdapter } from "@milaboratories/ts-helpers";
|
|
3
4
|
import {
|
|
4
5
|
resolveBlockVars,
|
|
5
6
|
runInit,
|
|
@@ -7,59 +8,51 @@ import {
|
|
|
7
8
|
type InitFlagValues,
|
|
8
9
|
} from "../../structure/init-block-constructor";
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
"Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive."
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
public async run(): Promise<void> {
|
|
41
|
-
const { args, flags } = await this.parse(StructureInit);
|
|
42
|
-
|
|
43
|
-
if (flags["with-software"] && flags["no-software"]) {
|
|
44
|
-
this.error("--with-software and --no-software are mutually exclusive.");
|
|
11
|
+
export function structureInitCommand(packageRoot: string): Command {
|
|
12
|
+
const cmd = new Command("init").description(
|
|
13
|
+
"Scaffold a fresh Platforma block from the canonical structure. Missing flags are prompted unless --non-interactive.",
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
cmd.argument("[path]", "target directory (default: <short-name> under the current directory)");
|
|
17
|
+
cmd.option("--npm-org <org>", "npm org, e.g. @platforma-open");
|
|
18
|
+
cmd.option("--org-scope <scope>", "org scope, e.g. my-org");
|
|
19
|
+
cmd.option("--short-name <name>", "block short name, e.g. mixcr-clonotyping");
|
|
20
|
+
cmd.option("--with-software", "include a software module");
|
|
21
|
+
cmd.option("--no-software", "omit the software module");
|
|
22
|
+
cmd.addOption(
|
|
23
|
+
new Option("--platform <platform>", "software platform (single-valued)").choices([
|
|
24
|
+
...SUPPORTED_PLATFORMS,
|
|
25
|
+
]),
|
|
26
|
+
);
|
|
27
|
+
cmd.option("--non-interactive", "error on any missing flag instead of prompting");
|
|
28
|
+
|
|
29
|
+
cmd.action(async (argPath: string | undefined, flags) => {
|
|
30
|
+
const logger = new ConsoleLoggerAdapter();
|
|
31
|
+
|
|
32
|
+
// commander maps `--with-software` -> flags.withSoftware===true and
|
|
33
|
+
// `--no-software` -> flags.software===false
|
|
34
|
+
const withSoftwareFlag = flags.withSoftware === true;
|
|
35
|
+
const noSoftwareFlag = flags.software === false;
|
|
36
|
+
if (withSoftwareFlag && noSoftwareFlag) {
|
|
37
|
+
throw new Error("--with-software and --no-software are mutually exclusive.");
|
|
45
38
|
}
|
|
46
|
-
const withSoftware =
|
|
39
|
+
const withSoftware = withSoftwareFlag ? true : noSoftwareFlag ? false : undefined;
|
|
47
40
|
|
|
48
41
|
const flagValues: InitFlagValues = {
|
|
49
|
-
npmOrg: flags
|
|
50
|
-
orgScope: flags
|
|
51
|
-
shortName: flags
|
|
42
|
+
npmOrg: flags.npmOrg,
|
|
43
|
+
orgScope: flags.orgScope,
|
|
44
|
+
shortName: flags.shortName,
|
|
52
45
|
withSoftware,
|
|
53
46
|
platform: flags.platform,
|
|
54
|
-
nonInteractive: flags
|
|
47
|
+
nonInteractive: flags.nonInteractive,
|
|
55
48
|
};
|
|
56
49
|
|
|
57
50
|
const vars = await resolveBlockVars(flagValues);
|
|
58
|
-
const blockPath =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
const blockPath = argPath ? path.resolve(argPath) : path.resolve(process.cwd(), vars.shortName);
|
|
52
|
+
const templatesRoot = path.join(packageRoot, "src", "structure", "templates");
|
|
53
|
+
|
|
54
|
+
await runInit({ vars, blockPath, templatesRoot, log: (m) => logger.info(m) });
|
|
55
|
+
});
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
}
|
|
57
|
+
return cmd;
|
|
65
58
|
}
|
|
@@ -1,44 +1,53 @@
|
|
|
1
|
-
import { Command
|
|
1
|
+
import { Command } from "commander";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import type { MiLogger } from "@milaboratories/ts-helpers";
|
|
4
|
+
import { ConsoleLoggerAdapter } from "@milaboratories/ts-helpers";
|
|
3
5
|
import { runStructureForPath, formatChanges } from "../../structure/cli/run-structure";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
// Shared by `structure refresh` and the deprecated `update-deps` alias.
|
|
8
|
+
export async function runRefresh(opts: {
|
|
9
|
+
paths: string[];
|
|
10
|
+
isSdkInternal: boolean;
|
|
11
|
+
updateDepsOnly: boolean;
|
|
12
|
+
templatesRoot: string;
|
|
13
|
+
logger: MiLogger;
|
|
14
|
+
}): Promise<void> {
|
|
15
|
+
for (const p of opts.paths) {
|
|
16
|
+
const res = await runStructureForPath({
|
|
17
|
+
blockPath: p,
|
|
18
|
+
isSdkInternal: opts.isSdkInternal,
|
|
19
|
+
updateDepsOnly: opts.updateDepsOnly,
|
|
20
|
+
mode: "refresh",
|
|
21
|
+
templatesRoot: opts.templatesRoot,
|
|
22
|
+
log: (m) => opts.logger.info(m),
|
|
23
|
+
});
|
|
24
|
+
opts.logger.info(formatChanges(p, res.changes));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
14
27
|
|
|
15
|
-
|
|
28
|
+
export function structureRefreshCommand(packageRoot: string): Command {
|
|
29
|
+
const cmd = new Command("refresh").description(
|
|
30
|
+
"Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only fires only catalog-bump rules (network).",
|
|
31
|
+
);
|
|
16
32
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"fire ONLY catalog-bump rules (npm network). Follow with `pnpm install` then a plain refresh.",
|
|
24
|
-
}),
|
|
25
|
-
};
|
|
33
|
+
cmd.argument("[paths...]", "block path(s); defaults to the current directory");
|
|
34
|
+
cmd.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules");
|
|
35
|
+
cmd.option(
|
|
36
|
+
"--update-deps-only",
|
|
37
|
+
"fire ONLY catalog-bump rules (npm network). Follow with `pnpm install` then a plain refresh.",
|
|
38
|
+
);
|
|
26
39
|
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
40
|
+
cmd.action(async (argv: string[], flags) => {
|
|
41
|
+
const paths = argv.length > 0 ? argv : ["."];
|
|
42
|
+
const templatesRoot = path.join(packageRoot, "src", "structure", "templates");
|
|
43
|
+
await runRefresh({
|
|
44
|
+
paths,
|
|
45
|
+
isSdkInternal: Boolean(flags.sdkInternal),
|
|
46
|
+
updateDepsOnly: Boolean(flags.updateDepsOnly),
|
|
47
|
+
templatesRoot,
|
|
48
|
+
logger: new ConsoleLoggerAdapter(),
|
|
49
|
+
});
|
|
50
|
+
});
|
|
31
51
|
|
|
32
|
-
|
|
33
|
-
const res = await runStructureForPath({
|
|
34
|
-
blockPath: p,
|
|
35
|
-
isSdkInternal: flags["sdk-internal"],
|
|
36
|
-
updateDepsOnly: flags["update-deps-only"],
|
|
37
|
-
mode: "refresh",
|
|
38
|
-
templatesRoot,
|
|
39
|
-
log: (m) => this.log(m),
|
|
40
|
-
});
|
|
41
|
-
this.log(formatChanges(p, res.changes));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
52
|
+
return cmd;
|
|
44
53
|
}
|
package/src/cmd/update-deps.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { Command } from "
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { ConsoleLoggerAdapter } from "@milaboratories/ts-helpers";
|
|
4
|
+
import { runRefresh } from "./structure/refresh";
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Deprecated. Phase-2 forwarding alias (spec.md § "Coexistence And
|
|
@@ -7,19 +10,26 @@ import { Command } from "@oclif/core";
|
|
|
7
10
|
* semantics. Prints a deprecation warning; will be removed once the
|
|
8
11
|
* structurer path has been live without surprises.
|
|
9
12
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
"[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it."
|
|
13
|
+
export function updateDepsCommand(packageRoot: string): Command {
|
|
14
|
+
const cmd = new Command("update-deps").description(
|
|
15
|
+
"[DEPRECATED] Use `block-tools structure refresh --update-deps-only`. This alias delegates to it.",
|
|
16
|
+
);
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.warn(
|
|
18
|
+
cmd.action(async () => {
|
|
19
|
+
const logger = new ConsoleLoggerAdapter();
|
|
20
|
+
logger.warn(
|
|
18
21
|
"`block-tools update-deps` is deprecated and will be removed in a future release. " +
|
|
19
22
|
"Use `block-tools structure refresh --update-deps-only` instead. Delegating now.",
|
|
20
23
|
);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const templatesRoot = path.join(packageRoot, "src", "structure", "templates");
|
|
25
|
+
await runRefresh({
|
|
26
|
+
paths: ["."],
|
|
27
|
+
isSdkInternal: false,
|
|
28
|
+
updateDepsOnly: true,
|
|
29
|
+
templatesRoot,
|
|
30
|
+
logger,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return cmd;
|
|
25
35
|
}
|
|
@@ -1,67 +1,47 @@
|
|
|
1
|
-
import { Command,
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
2
|
import { getConfig } from "../registry_v1/config";
|
|
3
|
-
import {
|
|
3
|
+
import { targetFileOption } from "../registry_v1/flags";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import YAML from "yaml";
|
|
6
6
|
import { PlRegPackageConfigDataShard } from "../registry_v1/config_schema";
|
|
7
|
-
import {
|
|
7
|
+
import { ConsoleLoggerAdapter } from "@milaboratories/ts-helpers";
|
|
8
8
|
|
|
9
9
|
type BasicConfigField = keyof PlRegPackageConfigDataShard &
|
|
10
10
|
("registry" | "organization" | "package" | "version");
|
|
11
11
|
const BasicConfigFields: BasicConfigField[] = ["registry", "organization", "package", "version"];
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
env
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
exists: true,
|
|
46
|
-
}),
|
|
47
|
-
|
|
48
|
-
file: targetFile({
|
|
49
|
-
char: "f",
|
|
50
|
-
summary: "package files",
|
|
51
|
-
multiple: true,
|
|
52
|
-
default: [],
|
|
53
|
-
}),
|
|
54
|
-
|
|
55
|
-
refresh: Flags.boolean({
|
|
56
|
-
summary: "refresh repository after adding the package",
|
|
57
|
-
default: true,
|
|
58
|
-
allowNo: true,
|
|
59
|
-
env: "PL_REGISTRY_REFRESH",
|
|
60
|
-
}),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
public async run(): Promise<void> {
|
|
64
|
-
const { flags } = await this.parse(UploadPackageV1);
|
|
13
|
+
export function uploadPackageV1Command(): Command {
|
|
14
|
+
const cmd = new Command("upload-package-v1").description(
|
|
15
|
+
"Uploads V1 package and refreshes the registry",
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
cmd.addOption(
|
|
19
|
+
new Option(
|
|
20
|
+
"-r, --registry <address|alias>",
|
|
21
|
+
"full address of the registry or alias from .pl.reg",
|
|
22
|
+
).env("PL_REGISTRY"),
|
|
23
|
+
);
|
|
24
|
+
cmd.addOption(
|
|
25
|
+
new Option("-o, --organization <organization>", "target organisation").env(
|
|
26
|
+
"PL_PACKAGE_ORGANIZATION",
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
cmd.addOption(new Option("-p, --package <package>", "target package").env("PL_PACKAGE_NAME"));
|
|
30
|
+
cmd.addOption(new Option("-v, --version <version>", "target version").env("PL_PACKAGE_VERSION"));
|
|
31
|
+
cmd.option(
|
|
32
|
+
"-m, --meta <path>",
|
|
33
|
+
"json file containing meta information to associate with tha package",
|
|
34
|
+
);
|
|
35
|
+
cmd.addOption(targetFileOption("-f, --file <file>", "package files"));
|
|
36
|
+
cmd.addOption(
|
|
37
|
+
new Option("--refresh", "refresh repository after adding the package")
|
|
38
|
+
.default(true)
|
|
39
|
+
.env("PL_REGISTRY_REFRESH"),
|
|
40
|
+
);
|
|
41
|
+
cmd.option("--no-refresh", "do not refresh repository after adding the package");
|
|
42
|
+
|
|
43
|
+
cmd.action(async (flags) => {
|
|
44
|
+
const logger = new ConsoleLoggerAdapter();
|
|
65
45
|
const configFromFlags: PlRegPackageConfigDataShard = PlRegPackageConfigDataShard.parse({});
|
|
66
46
|
|
|
67
47
|
for (const field of BasicConfigFields) if (flags[field]) configFromFlags[field] = flags[field];
|
|
@@ -83,23 +63,25 @@ export default class UploadPackageV1 extends Command {
|
|
|
83
63
|
|
|
84
64
|
const conf = await getConfig(configFromFlags);
|
|
85
65
|
|
|
86
|
-
|
|
66
|
+
logger.info(YAML.stringify(conf.conf));
|
|
87
67
|
|
|
88
|
-
const registry = conf.createRegistry(
|
|
68
|
+
const registry = conf.createRegistry(logger);
|
|
89
69
|
const name = conf.fullPackageName;
|
|
90
70
|
|
|
91
71
|
const builder = registry.constructNewPackage(name);
|
|
92
72
|
|
|
93
73
|
for (const [dst, src] of Object.entries(conf.conf.files)) {
|
|
94
|
-
|
|
74
|
+
logger.info(`Uploading ${src} -> ${dst} ...`);
|
|
95
75
|
const content = await fs.promises.readFile(src);
|
|
96
76
|
await builder.addFile(dst, content);
|
|
97
77
|
}
|
|
98
78
|
|
|
99
|
-
|
|
79
|
+
logger.info(`Uploading meta information...`);
|
|
100
80
|
await builder.writeMeta(conf.conf.meta);
|
|
101
81
|
await builder.finish();
|
|
102
82
|
|
|
103
83
|
if (flags.refresh) await registry.updateIfNeeded();
|
|
104
|
-
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return cmd;
|
|
105
87
|
}
|
package/src/registry_v1/flags.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Option } from "commander";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
export interface TargetFile {
|
|
@@ -16,9 +16,9 @@ function parseTargetFile(arg: string): TargetFile {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
19
|
+
// Repeatable `file_path | package_name=file_path` option.
|
|
20
|
+
export function targetFileOption(flags: string, summary: string): Option {
|
|
21
|
+
return new Option(flags, summary)
|
|
22
|
+
.argParser((arg: string, prev?: TargetFile[]) => [...(prev ?? []), parseTargetFile(arg)])
|
|
23
|
+
.default([] as TargetFile[]);
|
|
24
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Shared driver for the `structure check` and `structure refresh`
|
|
2
|
-
//
|
|
2
|
+
// commands. Wraps DISCOVERY (discover-fs) + the engine runner for
|
|
3
3
|
// one block path, handling the standalone vs `--sdk-internal` split, the
|
|
4
4
|
// `--update-deps-only` registry prefetch, and the post-run recheck's
|
|
5
5
|
// fresh re-discovery. Each block path is processed independently (no
|
|
@@ -26,7 +26,7 @@ export type RunStructureInput = {
|
|
|
26
26
|
isSdkInternal: boolean;
|
|
27
27
|
updateDepsOnly: boolean;
|
|
28
28
|
mode: StructureMode;
|
|
29
|
-
/** `<block-tools>/src/structure/templates
|
|
29
|
+
/** `<block-tools>/src/structure/templates`. */
|
|
30
30
|
templatesRoot: string;
|
|
31
31
|
log: (msg: string) => void;
|
|
32
32
|
};
|