@kubohiroya/sb3-toolchain 0.19.0 → 0.20.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/CHANGELOG.md +13 -0
- package/README.ja.md +10 -1
- package/README.md +11 -1
- package/dist/cli.d.ts +11 -1
- package/dist/cli.js +73 -2
- package/dist/cli.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/extension-bundle-configuration.d.ts +4 -2
- package/dist/extension-bundle-configuration.js +9 -3
- package/dist/extension-bundle-configuration.js.map +1 -1
- package/dist/extension-bundle-metadata.d.ts +3 -0
- package/dist/extension-bundle-metadata.js +73 -0
- package/dist/extension-bundle-metadata.js.map +1 -0
- package/dist/extension-bundle.js +17 -3
- package/dist/extension-bundle.js.map +1 -1
- package/dist/extension-sb3-replacement.d.ts +22 -0
- package/dist/extension-sb3-replacement.js +176 -0
- package/dist/extension-sb3-replacement.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/types.d.ts +14 -0
- package/docs/extension-bundles.md +30 -0
- package/docs/index.html +2 -2
- package/docs/ja/extension-bundles.md +30 -0
- package/docs/ja/sb3-extension-replacement.md +41 -0
- package/docs/ja/workflows.md +2 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.20.0 - 2026-10-29
|
|
4
|
+
|
|
5
|
+
- Kamishibai作品SB3のRuntimeバンドルとBlock Scriptを一括更新する `extensions replace-sb3` とJavaScript APIを追加。
|
|
6
|
+
- `--from`省略時は公式サイトの公開済みブロック台本SB3を自動取得し、公開状態・バージョン・サイズ・SHA-256を検証。指定時はローカルSB3を使用。
|
|
7
|
+
- 作品の台本・素材・保存データ・無関係な機能拡張を保持し、入力や提供元の上書き、自動ダウングレード、検証失敗時の部分更新を防止。
|
|
8
|
+
|
|
9
|
+
Rollback: `@kubohiroya/sb3-toolchain@0.19.1`へ固定し、元の作品SB3を開く。
|
|
10
|
+
|
|
11
|
+
## 0.19.1 - 2026-10-29
|
|
12
|
+
|
|
13
|
+
- Preserve explicitly configured bundle presentation metadata in classic and module headers, source configuration, and the CLI.
|
|
14
|
+
- Keep generated bytes unchanged when metadata is omitted, and retain member license notices and sandbox requirements.
|
|
15
|
+
|
|
3
16
|
## 0.19.0 - 2026-10-28
|
|
4
17
|
|
|
5
18
|
- Refresh family dependencies and release registration.
|
package/README.ja.md
CHANGED
|
@@ -31,7 +31,7 @@ Scratch 3およびTurboWarpの`.sb3`プロジェクトを、Gitで差分を確
|
|
|
31
31
|
再現可能なインストールのため、検証済みのnpmバージョンを固定します。
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
pnpm add --save-dev --save-exact @kubohiroya/sb3-toolchain@0.
|
|
34
|
+
pnpm add --save-dev --save-exact @kubohiroya/sb3-toolchain@0.20.0
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## クイックスタート
|
|
@@ -44,6 +44,15 @@ sb3-toolchain check app
|
|
|
44
44
|
sb3-toolchain build app --output dist/project.sb3
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
Kamishibai作品SB3のRuntimeバンドルとBlock Scriptは、一発コマンドで更新できます。
|
|
48
|
+
`--from`省略時は公式サイトの公開済みブロック台本を自動取得します。
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
sb3-toolchain extensions replace-sb3 input.sb3 --output updated.sb3
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
提供元の指定方法、保持するデータ、検証と制限は[SB3の機能拡張更新](docs/ja/sb3-extension-replacement.md)を参照してください。
|
|
55
|
+
|
|
47
56
|
プロジェクトリポジトリに推奨する信頼できる唯一の情報源、再import、置換保護、機能拡張更新、CIの
|
|
48
57
|
ワークフローについては、[`docs/ja/workflows.md`](docs/ja/workflows.md)を参照してください。
|
|
49
58
|
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ expanded sources and rebuilding bit-for-bit identical SB3 files from the same in
|
|
|
32
32
|
Pin the verified npm version for reproducible installation.
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
pnpm add --save-dev --save-exact @kubohiroya/sb3-toolchain@0.
|
|
35
|
+
pnpm add --save-dev --save-exact @kubohiroya/sb3-toolchain@0.20.0
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
## Quick start
|
|
@@ -45,6 +45,16 @@ sb3-toolchain check app
|
|
|
45
45
|
sb3-toolchain build app --output dist/project.sb3
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
Update a Kamishibai SB3's runtime bundle and Block Script together. Omitting `--from`
|
|
49
|
+
downloads and verifies the published block SB3 from the official samples site.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
sb3-toolchain extensions replace-sb3 input.sb3 --output updated.sb3
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
See the [replacement guide (Japanese)](docs/ja/sb3-extension-replacement.md) for local donors,
|
|
56
|
+
preserved story data, validation, and limits.
|
|
57
|
+
|
|
48
58
|
See [`docs/workflows.md`](docs/workflows.md) for the recommended source-of-truth, re-import,
|
|
49
59
|
replacement protection, extension update, and CI workflows for a project repository.
|
|
50
60
|
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ExtensionBundleMetadata } from './types';
|
|
1
2
|
import { FetchImplementation } from './extension-sync';
|
|
2
3
|
export interface HelpCliOptions {
|
|
3
4
|
command: 'help';
|
|
@@ -55,6 +56,7 @@ export interface ExtensionsBundleCliOptions {
|
|
|
55
56
|
action: 'bundle';
|
|
56
57
|
bundleId: string;
|
|
57
58
|
bundleName: string;
|
|
59
|
+
metadata?: ExtensionBundleMetadata;
|
|
58
60
|
command: 'extensions';
|
|
59
61
|
extensionIds: string[];
|
|
60
62
|
recoveryCapsule: boolean;
|
|
@@ -78,7 +80,15 @@ export interface ExtensionsUnbundleArchiveCliOptions {
|
|
|
78
80
|
outputPath: string;
|
|
79
81
|
yes: boolean;
|
|
80
82
|
}
|
|
81
|
-
export
|
|
83
|
+
export interface ExtensionsReplaceSb3CliOptions {
|
|
84
|
+
action: 'replace-sb3';
|
|
85
|
+
command: 'extensions';
|
|
86
|
+
fromPath?: string;
|
|
87
|
+
inputPath: string;
|
|
88
|
+
outputPath: string;
|
|
89
|
+
yes: boolean;
|
|
90
|
+
}
|
|
91
|
+
export type ExtensionsCliOptions = ExtensionsReplaceSb3CliOptions | ExtensionsStatusCliOptions | ExtensionsMutationCliOptions | ExtensionsMigrateIdCliOptions | ExtensionsBundleCliOptions | ExtensionsUnbundleSourceCliOptions | ExtensionsUnbundleArchiveCliOptions;
|
|
82
92
|
export type CliOptions = HelpCliOptions | VersionCliOptions | ImportCliOptions | CheckCliOptions | BuildCliOptions | ExtensionsCliOptions;
|
|
83
93
|
export interface RunCliOptions {
|
|
84
94
|
fetch?: FetchImplementation;
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert } from "./assert.js";
|
|
2
|
+
import { validateExtensionBundleMetadata } from "./extension-bundle-metadata.js";
|
|
2
3
|
import { createDeterministicSb3, validateSb3Source } from "./source.js";
|
|
3
4
|
import { buildSb3 } from "./build.js";
|
|
4
5
|
import { packageVersion } from "./constants.js";
|
|
@@ -6,6 +7,7 @@ import { importSb3 } from "./import.js";
|
|
|
6
7
|
import { unbundleSb3 } from "./extension-bundle-archive.js";
|
|
7
8
|
import { bundleExtensions, unbundleExtensions } from "./extension-bundle-configuration.js";
|
|
8
9
|
import { migrateExtensionId } from "./extension-id-migration.js";
|
|
10
|
+
import { replaceSb3Extensions } from "./extension-sb3-replacement.js";
|
|
9
11
|
import { extensionStatus, syncExtensions, updateExtensions } from "./extension-sync.js";
|
|
10
12
|
import process from "node:process";
|
|
11
13
|
import path from "node:path";
|
|
@@ -16,11 +18,12 @@ function usage() {
|
|
|
16
18
|
sb3-toolchain import INPUT.sb3 --output SOURCE_DIR [--yes] [--discard-local-changes]
|
|
17
19
|
sb3-toolchain check SOURCE_DIR [--project-assets MANIFEST.json] [--allow-asset-root DIR ...]
|
|
18
20
|
sb3-toolchain build SOURCE_DIR --output OUTPUT.sb3 [--project-assets MANIFEST.json] [--allow-asset-root DIR ...] [--clean-up-blocks] [--yes]
|
|
21
|
+
sb3-toolchain extensions replace-sb3 INPUT.sb3 [--from DONOR.sb3] --output OUTPUT.sb3 [--yes]
|
|
19
22
|
sb3-toolchain extensions status SOURCE_DIR
|
|
20
23
|
sb3-toolchain extensions sync SOURCE_DIR [--yes]
|
|
21
24
|
sb3-toolchain extensions update SOURCE_DIR [EXTENSION_ID] [--migrate-id NEW_ID] [--artifact PATH] [--api-manifest-artifact PATH] [--allow-breaking-api --yes]
|
|
22
25
|
sb3-toolchain extensions migrate-id SOURCE_DIR --from OLD_ID --to NEW_ID [--yes]
|
|
23
|
-
sb3-toolchain extensions bundle SOURCE_DIR --id BUNDLE_ID --name NAME [EXTENSION_ID ...] [--build-mode classic|module] [--share PACKAGE@EXACT_VERSION] [--include-recovery-capsule] [--yes]
|
|
26
|
+
sb3-toolchain extensions bundle SOURCE_DIR --id BUNDLE_ID --name NAME [EXTENSION_ID ...] [--metadata-json JSON] [--build-mode classic|module] [--share PACKAGE@EXACT_VERSION] [--include-recovery-capsule] [--yes]
|
|
24
27
|
sb3-toolchain extensions unbundle SOURCE_DIR BUNDLE_ID [--yes]
|
|
25
28
|
sb3-toolchain extensions unbundle INPUT.sb3 BUNDLE_ID --output OUTPUT.sb3 [--yes]
|
|
26
29
|
|
|
@@ -41,6 +44,12 @@ Project asset additions:
|
|
|
41
44
|
backdrops, costumes, and sounds only to the generated SB3. Input files are confined to the
|
|
42
45
|
manifest directory unless --allow-asset-root explicitly permits another root.
|
|
43
46
|
|
|
47
|
+
Kamishibai SB3 replacement:
|
|
48
|
+
extensions replace-sb3 replaces the runtime bundle and Block Script in INPUT.sb3.
|
|
49
|
+
Omitting --from downloads the published block SB3 from the official samples site
|
|
50
|
+
and verifies its size and SHA-256. --from uses a local donor without network access.
|
|
51
|
+
The input is preserved; output must use a different path. Story data is not migrated.
|
|
52
|
+
|
|
44
53
|
Replacement safety:
|
|
45
54
|
Differing outputs require interactive confirmation or --yes.
|
|
46
55
|
Import refuses to discard uncommitted Git changes unless
|
|
@@ -235,6 +244,7 @@ function parseExtensionIdMigrationArguments(arguments_) {
|
|
|
235
244
|
function parseExtensionBundleArguments(arguments_) {
|
|
236
245
|
let bundleId;
|
|
237
246
|
let bundleName;
|
|
247
|
+
let metadata;
|
|
238
248
|
let recoveryCapsule = false;
|
|
239
249
|
let sourceDirectory;
|
|
240
250
|
const extensionIds = [];
|
|
@@ -249,6 +259,17 @@ function parseExtensionBundleArguments(arguments_) {
|
|
|
249
259
|
} else if (argument === "--name") {
|
|
250
260
|
bundleName = takeValue(arguments_, index, "--name");
|
|
251
261
|
index += 1;
|
|
262
|
+
} else if (argument === "--metadata-json") {
|
|
263
|
+
assert(metadata === void 0, "--metadata-json may only be specified once.");
|
|
264
|
+
const value = takeValue(arguments_, index, "--metadata-json");
|
|
265
|
+
let parsed;
|
|
266
|
+
try {
|
|
267
|
+
parsed = JSON.parse(value);
|
|
268
|
+
} catch {
|
|
269
|
+
throw new Error("--metadata-json must contain a JSON object.");
|
|
270
|
+
}
|
|
271
|
+
metadata = validateExtensionBundleMetadata(parsed);
|
|
272
|
+
index += 1;
|
|
252
273
|
} else if (argument === "--yes") yes = true;
|
|
253
274
|
else if (argument === "--include-recovery-capsule") recoveryCapsule = true;
|
|
254
275
|
else if (argument === "--build-mode") {
|
|
@@ -283,6 +304,7 @@ function parseExtensionBundleArguments(arguments_) {
|
|
|
283
304
|
action: "bundle",
|
|
284
305
|
bundleId,
|
|
285
306
|
bundleName,
|
|
307
|
+
...metadata === void 0 ? {} : { metadata },
|
|
286
308
|
command: "extensions",
|
|
287
309
|
extensionIds,
|
|
288
310
|
recoveryCapsule,
|
|
@@ -334,9 +356,43 @@ function parseExtensionUnbundleArguments(arguments_) {
|
|
|
334
356
|
yes
|
|
335
357
|
};
|
|
336
358
|
}
|
|
359
|
+
function parseExtensionReplaceSb3Arguments(arguments_) {
|
|
360
|
+
let fromPath;
|
|
361
|
+
let inputPath;
|
|
362
|
+
let outputPath;
|
|
363
|
+
let yes = false;
|
|
364
|
+
for (let index = 0; index < arguments_.length; index += 1) {
|
|
365
|
+
const argument = arguments_[index];
|
|
366
|
+
if (argument === "--from") {
|
|
367
|
+
assert(!fromPath, "--from may only be specified once.");
|
|
368
|
+
fromPath = path.resolve(takeValue(arguments_, index, "--from"));
|
|
369
|
+
index += 1;
|
|
370
|
+
} else if (argument === "--output") {
|
|
371
|
+
assert(!outputPath, "--output may only be specified once.");
|
|
372
|
+
outputPath = path.resolve(takeValue(arguments_, index, "--output"));
|
|
373
|
+
index += 1;
|
|
374
|
+
} else if (argument === "--yes") yes = true;
|
|
375
|
+
else {
|
|
376
|
+
assert(!argument.startsWith("-"), `Unknown option: ${argument}`);
|
|
377
|
+
assert(!inputPath, "Only one input SB3 may be specified.");
|
|
378
|
+
inputPath = path.resolve(argument);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
assert(inputPath, "The extensions replace-sb3 command requires INPUT.sb3.");
|
|
382
|
+
assert(outputPath, "The extensions replace-sb3 command requires --output OUTPUT.sb3.");
|
|
383
|
+
return {
|
|
384
|
+
action: "replace-sb3",
|
|
385
|
+
command: "extensions",
|
|
386
|
+
fromPath,
|
|
387
|
+
inputPath,
|
|
388
|
+
outputPath,
|
|
389
|
+
yes
|
|
390
|
+
};
|
|
391
|
+
}
|
|
337
392
|
function parseExtensionsArguments(arguments_) {
|
|
338
393
|
const [action, ...actionArguments] = arguments_;
|
|
339
|
-
assert(action === "bundle" || action === "migrate-id" || action === "status" || action === "sync" || action === "unbundle" || action === "update", "The extensions command requires status, sync, update, migrate-id, bundle, or
|
|
394
|
+
assert(action === "replace-sb3" || action === "bundle" || action === "migrate-id" || action === "status" || action === "sync" || action === "unbundle" || action === "update", "The extensions command requires status, sync, update, migrate-id, bundle, unbundle, or replace-sb3.");
|
|
395
|
+
if (action === "replace-sb3") return parseExtensionReplaceSb3Arguments(actionArguments);
|
|
340
396
|
if (action === "status") {
|
|
341
397
|
assert(actionArguments.length === 1 && !actionArguments[0].startsWith("-"), "The extensions status command requires exactly one SOURCE_DIR.");
|
|
342
398
|
return {
|
|
@@ -460,10 +516,25 @@ async function runCli(arguments_, { fetch: fetchImplementation = globalThis.fetc
|
|
|
460
516
|
return;
|
|
461
517
|
}
|
|
462
518
|
if (options.command === "extensions") {
|
|
519
|
+
if (options.action === "replace-sb3") {
|
|
520
|
+
const result = await replaceSb3Extensions({
|
|
521
|
+
confirmReplace: confirmBuildReplacement,
|
|
522
|
+
fetch: fetchImplementation,
|
|
523
|
+
fromPath: options.fromPath,
|
|
524
|
+
inputPath: options.inputPath,
|
|
525
|
+
outputPath: options.outputPath,
|
|
526
|
+
yes: options.yes
|
|
527
|
+
});
|
|
528
|
+
log(`${result.changed ? "Wrote" : "Already up to date"}: ${result.outputPath} (${result.extensionIds.join(", ")}).`);
|
|
529
|
+
log(`Donor: ${result.donor.source}; version=${result.donor.version ?? "unknown"}; sha256=${result.donor.sha256}`);
|
|
530
|
+
if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
463
533
|
if (options.action === "bundle") {
|
|
464
534
|
const result = await bundleExtensions({
|
|
465
535
|
bundleId: options.bundleId,
|
|
466
536
|
bundleName: options.bundleName,
|
|
537
|
+
metadata: options.metadata,
|
|
467
538
|
extensionIds: options.extensionIds,
|
|
468
539
|
recoveryCapsule: options.recoveryCapsule,
|
|
469
540
|
buildMode: options.buildMode,
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["// SPDX-License-Identifier: MPL-2.0\n\nimport path from 'node:path';\nimport process from 'node:process';\nimport {createInterface} from 'node:readline/promises';\n\nimport {assert} from './assert';\nimport {buildSb3} from './build';\nimport {packageVersion} from './constants';\nimport {unbundleSb3} from './extension-bundle-archive';\nimport {bundleExtensions, unbundleExtensions} from './extension-bundle-configuration';\nimport {migrateExtensionId} from './extension-id-migration';\nimport type {ExtensionIdMigrationCounts, ExtensionIdReference} from './extension-id-migration';\nimport {extensionStatus, syncExtensions, updateExtensions} from './extension-sync';\nimport type {ExtensionSyncConfirmContext, FetchImplementation} from './extension-sync';\nimport {importSb3} from './import';\nimport type {OutputReplacementContext} from './import';\nimport type {DirectoryDifferences} from './output-safety';\nimport {createDeterministicSb3, validateSb3Source} from './source';\n\nexport interface HelpCliOptions {\n command: 'help';\n}\n\nexport interface VersionCliOptions {\n command: 'version';\n}\n\nexport interface ImportCliOptions {\n command: 'import';\n discardLocalChanges: boolean;\n inputPath: string;\n outputDirectory: string;\n yes: boolean;\n}\n\nexport interface CheckCliOptions {\n allowedAssetRoots?: string[];\n command: 'check';\n projectAssetsPath?: string;\n sourceDirectory: string;\n}\n\nexport interface BuildCliOptions {\n allowedAssetRoots?: string[];\n cleanUpBlocks?: boolean;\n command: 'build';\n outputPath: string;\n projectAssetsPath?: string;\n sourceDirectory: string;\n yes: boolean;\n}\n\nexport interface ExtensionsStatusCliOptions {\n action: 'status';\n command: 'extensions';\n sourceDirectory: string;\n}\n\nexport interface ExtensionsMutationCliOptions {\n action: 'sync' | 'update';\n allowBreakingApi?: boolean;\n apiManifestArtifact?: string;\n command: 'extensions';\n extensionId?: string;\n migrateToId?: string;\n sourceArtifact?: string;\n sourceDirectory: string;\n yes: boolean;\n}\n\nexport interface ExtensionsMigrateIdCliOptions {\n action: 'migrate-id';\n command: 'extensions';\n fromId: string;\n sourceDirectory: string;\n toId: string;\n yes: boolean;\n}\n\nexport interface ExtensionsBundleCliOptions {\n action: 'bundle';\n bundleId: string;\n bundleName: string;\n command: 'extensions';\n extensionIds: string[];\n recoveryCapsule: boolean;\n sourceDirectory: string;\n yes: boolean;\n buildMode?: 'classic' | 'module';\n sharedDependencies?: Record<string, string>;\n}\n\nexport interface ExtensionsUnbundleSourceCliOptions {\n action: 'unbundle';\n bundleId: string;\n command: 'extensions';\n sourceDirectory: string;\n yes: boolean;\n}\n\nexport interface ExtensionsUnbundleArchiveCliOptions {\n action: 'unbundle';\n bundleId: string;\n command: 'extensions';\n inputPath: string;\n outputPath: string;\n yes: boolean;\n}\n\nexport type ExtensionsCliOptions =\n | ExtensionsStatusCliOptions\n | ExtensionsMutationCliOptions\n | ExtensionsMigrateIdCliOptions\n | ExtensionsBundleCliOptions\n | ExtensionsUnbundleSourceCliOptions\n | ExtensionsUnbundleArchiveCliOptions;\n\nexport type CliOptions =\n | HelpCliOptions\n | VersionCliOptions\n | ImportCliOptions\n | CheckCliOptions\n | BuildCliOptions\n | ExtensionsCliOptions;\n\nexport interface RunCliOptions {\n fetch?: FetchImplementation;\n log?: (message: string) => void;\n}\n\ninterface MigrationLogResult {\n applied: boolean;\n artifactReady: boolean;\n counts: ExtensionIdMigrationCounts;\n fromId: string | undefined;\n toId: string | undefined;\n totalChanges: number;\n unclassifiedReferences: ExtensionIdReference[];\n}\n\nexport function usage() {\n return `Usage:\n sb3-toolchain import INPUT.sb3 --output SOURCE_DIR [--yes] [--discard-local-changes]\n sb3-toolchain check SOURCE_DIR [--project-assets MANIFEST.json] [--allow-asset-root DIR ...]\n sb3-toolchain build SOURCE_DIR --output OUTPUT.sb3 [--project-assets MANIFEST.json] [--allow-asset-root DIR ...] [--clean-up-blocks] [--yes]\n sb3-toolchain extensions status SOURCE_DIR\n sb3-toolchain extensions sync SOURCE_DIR [--yes]\n sb3-toolchain extensions update SOURCE_DIR [EXTENSION_ID] [--migrate-id NEW_ID] [--artifact PATH] [--api-manifest-artifact PATH] [--allow-breaking-api --yes]\n sb3-toolchain extensions migrate-id SOURCE_DIR --from OLD_ID --to NEW_ID [--yes]\n sb3-toolchain extensions bundle SOURCE_DIR --id BUNDLE_ID --name NAME [EXTENSION_ID ...] [--build-mode classic|module] [--share PACKAGE@EXACT_VERSION] [--include-recovery-capsule] [--yes]\n sb3-toolchain extensions unbundle SOURCE_DIR BUNDLE_ID [--yes]\n sb3-toolchain extensions unbundle INPUT.sb3 BUNDLE_ID --output OUTPUT.sb3 [--yes]\n\nCommands:\n import Expand an SB3 into Git-friendly source files.\n check Validate an expanded SB3 source directory.\n build Build a deterministic SB3 from expanded sources.\n extensions Inspect, restore, or update managed embedded extensions.\n\nBuild layout cleanup:\n --clean-up-blocks applies a deterministic TurboWarp-style \"Clean up Blocks\"\n layout to every target in the generated SB3. It never deletes blocks,\n variables, lists, or comments. The expanded source is unchanged, but the\n generated SB3 might not be able to undo the coordinate changes.\n\nProject asset additions:\n --project-assets validates a JSON or YAML manifest and adds its sprites,\n backdrops, costumes, and sounds only to the generated SB3. Input files are confined to the\n manifest directory unless --allow-asset-root explicitly permits another root.\n\nReplacement safety:\n Differing outputs require interactive confirmation or --yes.\n Import refuses to discard uncommitted Git changes unless\n --discard-local-changes is also specified. --force is not supported.`;\n}\n\nfunction takeValue(arguments_: string[], index: number, option: string): string {\n const value = arguments_[index + 1];\n assert(value && !value.startsWith('-'), `${option} requires a value.`);\n return value;\n}\n\nfunction parseImportArguments(arguments_: string[]): ImportCliOptions {\n let inputPath: string | undefined;\n let outputDirectory: string | undefined;\n let discardLocalChanges = false;\n let yes = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--output') {\n outputDirectory = path.resolve(takeValue(arguments_, index, '--output'));\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else if (argument === '--discard-local-changes') {\n discardLocalChanges = true;\n } else {\n assert(\n argument !== '--force',\n '--force is intentionally unsupported. Use --yes and, only when necessary, ' +\n '--discard-local-changes.',\n );\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!inputPath, 'Only one input SB3 may be specified.');\n inputPath = path.resolve(argument);\n }\n }\n\n assert(inputPath, 'The import command requires INPUT.sb3.');\n assert(outputDirectory, 'The import command requires --output SOURCE_DIR.');\n return {command: 'import', discardLocalChanges, inputPath, outputDirectory, yes};\n}\n\nfunction parseCheckArguments(arguments_: string[]): CheckCliOptions {\n const allowedAssetRoots: string[] = [];\n let projectAssetsPath: string | undefined;\n let sourceDirectory: string | undefined;\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--project-assets') {\n projectAssetsPath = path.resolve(takeValue(arguments_, index, '--project-assets'));\n index += 1;\n } else if (argument === '--allow-asset-root') {\n allowedAssetRoots.push(path.resolve(takeValue(arguments_, index, '--allow-asset-root')));\n index += 1;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!sourceDirectory, 'Only one SB3 source directory may be specified.');\n sourceDirectory = path.resolve(argument);\n }\n }\n assert(sourceDirectory, 'The check command requires SOURCE_DIR.');\n assert(\n allowedAssetRoots.length === 0 || projectAssetsPath,\n '--allow-asset-root requires --project-assets.',\n );\n return {\n ...(allowedAssetRoots.length > 0 ? {allowedAssetRoots} : {}),\n command: 'check',\n ...(projectAssetsPath ? {projectAssetsPath} : {}),\n sourceDirectory,\n };\n}\n\nfunction parseBuildArguments(arguments_: string[]): BuildCliOptions {\n const allowedAssetRoots: string[] = [];\n let cleanUpBlocks = false;\n let sourceDirectory: string | undefined;\n let outputPath: string | undefined;\n let projectAssetsPath: string | undefined;\n let yes = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--clean-up-blocks') {\n cleanUpBlocks = true;\n } else if (argument === '--project-assets') {\n projectAssetsPath = path.resolve(takeValue(arguments_, index, '--project-assets'));\n index += 1;\n } else if (argument === '--allow-asset-root') {\n allowedAssetRoots.push(path.resolve(takeValue(arguments_, index, '--allow-asset-root')));\n index += 1;\n } else if (argument === '--output') {\n outputPath = path.resolve(takeValue(arguments_, index, '--output'));\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!sourceDirectory, 'Only one SB3 source directory may be specified.');\n sourceDirectory = path.resolve(argument);\n }\n }\n\n assert(sourceDirectory, 'The build command requires SOURCE_DIR.');\n assert(outputPath, 'The build command requires --output OUTPUT.sb3.');\n assert(\n allowedAssetRoots.length === 0 || projectAssetsPath,\n '--allow-asset-root requires --project-assets.',\n );\n return {\n ...(allowedAssetRoots.length > 0 ? {allowedAssetRoots} : {}),\n ...(cleanUpBlocks ? {cleanUpBlocks} : {}),\n command: 'build',\n outputPath,\n ...(projectAssetsPath ? {projectAssetsPath} : {}),\n sourceDirectory,\n yes,\n };\n}\n\nfunction parseExtensionMutationArguments(\n action: 'sync' | 'update',\n arguments_: string[],\n): ExtensionsMutationCliOptions {\n let allowBreakingApi = false;\n let apiManifestArtifact: string | undefined;\n let sourceDirectory: string | undefined;\n let extensionId: string | undefined;\n let migrateToId: string | undefined;\n let sourceArtifact: string | undefined;\n let yes = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--yes') {\n yes = true;\n } else if (argument === '--allow-breaking-api') {\n assert(action === 'update', '--allow-breaking-api is only valid for extensions update.');\n allowBreakingApi = true;\n } else if (argument === '--migrate-id') {\n assert(action === 'update', '--migrate-id is only valid for extensions update.');\n migrateToId = takeValue(arguments_, index, '--migrate-id');\n index += 1;\n } else if (argument === '--artifact') {\n assert(action === 'update', '--artifact is only valid for extensions update.');\n sourceArtifact = takeValue(arguments_, index, '--artifact');\n index += 1;\n } else if (argument === '--api-manifest-artifact') {\n assert(action === 'update', '--api-manifest-artifact is only valid for extensions update.');\n apiManifestArtifact = takeValue(arguments_, index, '--api-manifest-artifact');\n index += 1;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n if (!sourceDirectory) {\n sourceDirectory = path.resolve(argument);\n } else {\n assert(action === 'update', `The extensions ${action} command accepts only SOURCE_DIR.`);\n assert(!extensionId, 'Only one EXTENSION_ID may be specified.');\n assert(\n /^[A-Za-z0-9._-]+$/u.test(argument),\n `Invalid embedded extension ID: ${JSON.stringify(argument)}`,\n );\n extensionId = argument;\n }\n }\n }\n\n assert(sourceDirectory, `The extensions ${action} command requires SOURCE_DIR.`);\n assert(\n migrateToId === undefined || extensionId !== undefined,\n '--migrate-id requires an explicit existing EXTENSION_ID.',\n );\n assert(\n sourceArtifact === undefined || migrateToId !== undefined,\n '--artifact requires --migrate-id.',\n );\n assert(\n apiManifestArtifact === undefined || migrateToId !== undefined,\n '--api-manifest-artifact requires --migrate-id.',\n );\n assert(!allowBreakingApi || yes, '--allow-breaking-api requires --yes.');\n return {\n action,\n ...(allowBreakingApi ? {allowBreakingApi} : {}),\n ...(apiManifestArtifact ? {apiManifestArtifact} : {}),\n command: 'extensions',\n extensionId,\n migrateToId,\n sourceArtifact,\n sourceDirectory,\n yes,\n };\n}\n\nfunction parseExtensionIdMigrationArguments(arguments_: string[]): ExtensionsMigrateIdCliOptions {\n let fromId: string | undefined;\n let sourceDirectory: string | undefined;\n let toId: string | undefined;\n let yes = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--from') {\n fromId = takeValue(arguments_, index, '--from');\n index += 1;\n } else if (argument === '--to') {\n toId = takeValue(arguments_, index, '--to');\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!sourceDirectory, 'Only one SB3 source directory may be specified.');\n sourceDirectory = path.resolve(argument);\n }\n }\n assert(sourceDirectory, 'The extensions migrate-id command requires SOURCE_DIR.');\n assert(fromId, 'The extensions migrate-id command requires --from OLD_ID.');\n assert(toId, 'The extensions migrate-id command requires --to NEW_ID.');\n return {\n action: 'migrate-id',\n command: 'extensions',\n fromId,\n sourceDirectory,\n toId,\n yes,\n };\n}\n\nfunction parseExtensionBundleArguments(arguments_: string[]): ExtensionsBundleCliOptions {\n let bundleId: string | undefined;\n let bundleName: string | undefined;\n let recoveryCapsule = false;\n let sourceDirectory: string | undefined;\n const extensionIds: string[] = [];\n let yes = false;\n let buildMode: 'classic' | 'module' | undefined;\n const sharedDependencies: Record<string, string> = {};\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--id') {\n bundleId = takeValue(arguments_, index, '--id');\n index += 1;\n } else if (argument === '--name') {\n bundleName = takeValue(arguments_, index, '--name');\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else if (argument === '--include-recovery-capsule') {\n recoveryCapsule = true;\n } else if (argument === '--build-mode') {\n const value = takeValue(arguments_, index, '--build-mode');\n assert(value === 'classic' || value === 'module', '--build-mode must be classic or module.');\n buildMode = value;\n index += 1;\n } else if (argument === '--share') {\n const value = takeValue(arguments_, index, '--share');\n const separator = value.lastIndexOf('@');\n assert(separator > 0, '--share requires PACKAGE@EXACT_VERSION.');\n const name = value.slice(0, separator);\n assert(\n /^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/u.test(name),\n `Invalid shared dependency name: ${name}`,\n );\n assert(\n /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/u.test(value.slice(separator + 1)),\n '--share requires an exact semantic version.',\n );\n assert(!Object.hasOwn(sharedDependencies, name), `Duplicate shared dependency: ${name}`);\n sharedDependencies[name] = value.slice(separator + 1);\n index += 1;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n if (!sourceDirectory) {\n sourceDirectory = path.resolve(argument);\n } else {\n assert(\n /^[a-z0-9]+$/u.test(argument),\n `Bundle member ID must use TurboWarp's [a-z0-9]+ format: ${JSON.stringify(argument)}`,\n );\n extensionIds.push(argument);\n }\n }\n }\n assert(sourceDirectory, 'The extensions bundle command requires SOURCE_DIR.');\n assert(bundleId, 'The extensions bundle command requires --id BUNDLE_ID.');\n assert(bundleName, 'The extensions bundle command requires --name NAME.');\n assert(\n !Object.keys(sharedDependencies).length || buildMode === 'module',\n '--share requires --build-mode module.',\n );\n return {\n action: 'bundle',\n bundleId,\n bundleName,\n command: 'extensions',\n extensionIds,\n recoveryCapsule,\n sourceDirectory,\n yes,\n ...(buildMode === undefined ? {} : {buildMode}),\n ...(Object.keys(sharedDependencies).length ? {sharedDependencies} : {}),\n };\n}\n\nfunction parseExtensionUnbundleArguments(\n arguments_: string[],\n): ExtensionsUnbundleSourceCliOptions | ExtensionsUnbundleArchiveCliOptions {\n let bundleId: string | undefined;\n let input: string | undefined;\n let outputPath: string | undefined;\n let yes = false;\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--yes') {\n yes = true;\n } else if (argument === '--output') {\n outputPath = path.resolve(takeValue(arguments_, index, '--output'));\n index += 1;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n if (!input) {\n input = path.resolve(argument);\n } else {\n assert(!bundleId, 'Only one BUNDLE_ID may be specified.');\n bundleId = argument;\n }\n }\n }\n assert(input, 'The extensions unbundle command requires SOURCE_DIR or INPUT.sb3.');\n assert(bundleId, 'The extensions unbundle command requires BUNDLE_ID.');\n if (path.extname(input).toLowerCase() === '.sb3') {\n assert(outputPath, 'SB3 unbundle requires --output OUTPUT.sb3.');\n return {\n action: 'unbundle',\n bundleId,\n command: 'extensions',\n inputPath: input,\n outputPath,\n yes,\n };\n }\n assert(!outputPath, '--output is only valid when unbundling an SB3 file.');\n return {\n action: 'unbundle',\n bundleId,\n command: 'extensions',\n sourceDirectory: input,\n yes,\n };\n}\n\nfunction parseExtensionsArguments(arguments_: string[]): ExtensionsCliOptions {\n const [action, ...actionArguments] = arguments_;\n assert(\n action === 'bundle' ||\n action === 'migrate-id' ||\n action === 'status' ||\n action === 'sync' ||\n action === 'unbundle' ||\n action === 'update',\n 'The extensions command requires status, sync, update, migrate-id, bundle, or unbundle.',\n );\n if (action === 'status') {\n assert(\n actionArguments.length === 1 && !actionArguments[0].startsWith('-'),\n 'The extensions status command requires exactly one SOURCE_DIR.',\n );\n return {\n action,\n command: 'extensions',\n sourceDirectory: path.resolve(actionArguments[0]),\n };\n }\n if (action === 'migrate-id') {\n return parseExtensionIdMigrationArguments(actionArguments);\n }\n if (action === 'bundle') {\n return parseExtensionBundleArguments(actionArguments);\n }\n if (action === 'unbundle') {\n return parseExtensionUnbundleArguments(actionArguments);\n }\n return parseExtensionMutationArguments(action, actionArguments);\n}\n\nexport function parseCliArguments(arguments_: string[]): CliOptions {\n const normalized = arguments_.filter((argument) => argument !== '--');\n if (normalized.length === 0 || normalized[0] === '--help' || normalized[0] === '-h') {\n return {command: 'help'};\n }\n if (normalized[0] === '--version' || normalized[0] === '-v') {\n return {command: 'version'};\n }\n\n const [command, ...commandArguments] = normalized;\n if (commandArguments.includes('--help') || commandArguments.includes('-h')) {\n return {command: 'help'};\n }\n if (command === 'import') return parseImportArguments(commandArguments);\n if (command === 'check') return parseCheckArguments(commandArguments);\n if (command === 'build') return parseBuildArguments(commandArguments);\n if (command === 'extensions') return parseExtensionsArguments(commandArguments);\n throw new Error(`Unknown command: ${command}`);\n}\n\nfunction formatDifferenceLines(differences: DirectoryDifferences): string {\n const labels: Record<string, string> = {added: '+', modified: '~', removed: '-'};\n const lines = Object.entries(differences).flatMap(([kind, paths]) =>\n paths.map((relativePath: string) => `${labels[kind]} ${relativePath}`),\n );\n const visibleLines = lines.slice(0, 12);\n if (lines.length > visibleLines.length) {\n visibleLines.push(`... and ${lines.length - visibleLines.length} more`);\n }\n return visibleLines.join('\\n');\n}\n\nasync function confirmImportReplacement(context: OutputReplacementContext): Promise<boolean> {\n const {comparison, discardLocalChanges, gitState, outputDirectory} = context;\n assert(\n process.stdin.isTTY && process.stdout.isTTY,\n `Output directory already exists: ${outputDirectory}. ` +\n 'Non-interactive replacement requires --yes.',\n );\n const readline = createInterface({input: process.stdin, output: process.stdout});\n try {\n const gitMessage = gitState.clean\n ? 'Git state: clean'\n : 'Git state: uncommitted changes will be discarded';\n const answer = await readline.question(\n `Existing SB3 source differs from the import candidate:\\n` +\n ` ${outputDirectory}\\n` +\n `${formatDifferenceLines(comparison.differences)}\\n` +\n `${gitMessage}\\n` +\n `${discardLocalChanges ? 'WARNING: --discard-local-changes is active.\\n' : ''}` +\n 'Replace the existing source directory? [y/N] ',\n );\n return /^(?:y|yes)$/iu.test(answer.trim());\n } finally {\n readline.close();\n }\n}\n\nasync function confirmBuildReplacement(outputPath: string): Promise<boolean> {\n assert(\n process.stdin.isTTY && process.stdout.isTTY,\n `Existing SB3 output differs: ${outputPath}. Non-interactive replacement requires --yes.`,\n );\n const readline = createInterface({input: process.stdin, output: process.stdout});\n try {\n const answer = await readline.question(\n `Existing generated SB3 will be replaced:\\n ${outputPath}\\nContinue? [y/N] `,\n );\n return /^(?:y|yes)$/iu.test(answer.trim());\n } finally {\n readline.close();\n }\n}\n\nasync function confirmExtensionReplacement({\n comparison,\n sourceDirectory,\n}: ExtensionSyncConfirmContext): Promise<boolean> {\n assert(\n process.stdin.isTTY && process.stdout.isTTY,\n `Managed extension files differ in ${sourceDirectory}. ` +\n 'Non-interactive replacement requires --yes.',\n );\n const readline = createInterface({input: process.stdin, output: process.stdout});\n try {\n const answer = await readline.question(\n `Managed extension changes will be installed:\\n` +\n ` ${sourceDirectory}\\n` +\n `${formatDifferenceLines(comparison.differences)}\\n` +\n 'Replace these files? [y/N] ',\n );\n return /^(?:y|yes)$/iu.test(answer.trim());\n } finally {\n readline.close();\n }\n}\n\nfunction logMigrationResult(result: MigrationLogResult, log: (message: string) => void): void {\n const counts = Object.entries(result.counts)\n .filter(([, count]) => count > 0)\n .map(([kind, count]) => `${kind}=${count}`)\n .join(', ');\n const action = result.applied ? 'Migrated' : 'Dry run';\n log(\n `${action}: ${result.fromId} -> ${result.toId}; ` +\n `${result.totalChanges} classified changes (${counts || 'none'}); ` +\n `artifact=${result.artifactReady ? 'ready' : 'requires-new-ID'}.`,\n );\n for (const reference of result.unclassifiedReferences) {\n log(\n `Unclassified ${reference.kind}: ${reference.file}${reference.path} = ` +\n JSON.stringify(reference.value),\n );\n }\n}\n\nexport async function runCli(\n arguments_: string[],\n {fetch: fetchImplementation = globalThis.fetch, log = console.log}: RunCliOptions = {},\n): Promise<void> {\n const options = parseCliArguments(arguments_);\n if (options.command === 'help') {\n log(usage());\n return;\n }\n if (options.command === 'version') {\n log(packageVersion);\n return;\n }\n if (options.command === 'check') {\n assert(\n 'sourceDirectory' in options && !('action' in options),\n 'Internal CLI check command routing error.',\n );\n if (options.projectAssetsPath) {\n const result = await createDeterministicSb3(options.sourceDirectory, {\n allowedAssetRoots: options.allowedAssetRoots,\n projectAssetsPath: options.projectAssetsPath,\n });\n log(\n `Valid SB3 source with project assets: ${result.source.resolvedSourceDirectory} ` +\n `(${result.entryCount} entries, ${result.assetCount} assets, ` +\n `${result.assetReferenceCount} references, ${result.embeddedExtensionCount} embedded extensions).`,\n );\n return;\n }\n const result = await validateSb3Source(options.sourceDirectory);\n log(\n `Valid SB3 source: ${result.resolvedSourceDirectory} ` +\n `(${result.sourceManifest.archiveEntries.length} entries, ` +\n `${result.assetContents.size} assets, ${result.assetReferenceCount} references, ` +\n `${result.extensions.length} embedded extensions).`,\n );\n return;\n }\n if (\n options.command === 'build' &&\n 'outputPath' in options &&\n 'sourceDirectory' in options &&\n !('action' in options)\n ) {\n const result = await buildSb3({\n allowedAssetRoots: options.allowedAssetRoots,\n cleanUpBlocks: options.cleanUpBlocks,\n confirmReplace: confirmBuildReplacement,\n outputPath: options.outputPath,\n projectAssetsPath: options.projectAssetsPath,\n sourceDirectory: options.sourceDirectory,\n yes: options.yes,\n });\n const action = result.changed ? 'Built' : 'Already up to date';\n const cleanUpMessage = result.blockCleanUp\n ? `, ${result.blockCleanUp.movedScriptCount}/${result.blockCleanUp.scriptCount} scripts laid out`\n : '';\n log(\n `${action}: ${result.outputPath} (${result.entryCount} entries, ` +\n `${result.assetCount} assets, ${result.embeddedExtensionCount} embedded extensions` +\n `${cleanUpMessage}).`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.command === 'extensions') {\n if (options.action === 'bundle') {\n const result = await bundleExtensions({\n bundleId: options.bundleId,\n bundleName: options.bundleName,\n extensionIds: options.extensionIds,\n recoveryCapsule: options.recoveryCapsule,\n buildMode: options.buildMode,\n sharedDependencies: options.sharedDependencies,\n sourceDirectory: options.sourceDirectory,\n yes: options.yes,\n });\n log(\n `${result.applied ? 'Configured' : 'Dry run'} extension bundle: ${result.bundleId} ` +\n `(${result.members.join(', ')}).`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.action === 'unbundle') {\n if ('inputPath' in options) {\n const result = await unbundleSb3({\n bundleId: options.bundleId,\n inputPath: options.inputPath,\n outputPath: options.outputPath,\n yes: options.yes,\n });\n log(\n `${result.applied ? 'Wrote' : 'Dry run'} unbundled SB3: ${result.bundleId} ` +\n `(${result.members.join(', ')}) -> ${result.outputPath}.`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n const result = await unbundleExtensions({\n bundleId: options.bundleId,\n sourceDirectory: options.sourceDirectory,\n yes: options.yes,\n });\n log(\n `${result.applied ? 'Removed' : 'Dry run'} extension bundle: ${result.bundleId} ` +\n `(${result.members.join(', ')}).`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.action === 'migrate-id') {\n const result = await migrateExtensionId({\n fromId: options.fromId,\n sourceDirectory: options.sourceDirectory,\n toId: options.toId,\n yes: options.yes,\n });\n logMigrationResult(result, log);\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.action === 'status') {\n const statuses = await extensionStatus(options.sourceDirectory, {\n fetch: fetchImplementation,\n });\n if (statuses.length === 0) {\n log(`No managed embedded extensions: ${options.sourceDirectory}`);\n return;\n }\n for (const status of statuses) {\n if ('package' in status) {\n log(\n `${status.id}: ${status.state}; local=${status.local}; ` +\n `${status.package}@${status.version} (installed ${status.installedVersion})`,\n );\n continue;\n }\n log(\n `${status.id}: ${status.state}; local=${status.local}; ` +\n `${status.ref} -> ${status.remoteCommit} ` +\n `(installed ${status.resolvedCommit})`,\n );\n }\n return;\n }\n\n const operationOptions = {\n confirmReplace: confirmExtensionReplacement,\n fetch: fetchImplementation,\n sourceDirectory: options.sourceDirectory,\n yes: options.yes,\n };\n const result =\n options.action === 'sync'\n ? await syncExtensions(operationOptions)\n : await updateExtensions({\n ...operationOptions,\n allowBreakingApi: options.allowBreakingApi,\n apiManifestArtifact: options.apiManifestArtifact,\n extensionId: options.extensionId,\n migrateToId: options.migrateToId,\n sourceArtifact: options.sourceArtifact,\n });\n const action = result.changed ? 'Updated' : 'Already up to date';\n log(\n `${action}: ${result.sourceDirectory} ` +\n `(${result.extensions.map((extension) => extension.id).join(', ')}).`,\n );\n if (result.migration) {\n logMigrationResult(\n {\n applied: result.changed,\n artifactReady: true,\n ...result.migration,\n },\n log,\n );\n }\n for (const compatibility of result.apiCompatibility) {\n for (const change of compatibility.changes) {\n log(\n `API ${compatibility.id}: ${change.breaking ? 'breaking' : 'compatible'} ` +\n `${change.kind} ${change.path}`,\n );\n }\n }\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n\n assert(\n options.command === 'import' && 'inputPath' in options,\n 'Internal CLI command routing error.',\n );\n const result = await importSb3({\n confirmReplace: confirmImportReplacement,\n discardLocalChanges: options.discardLocalChanges,\n inputPath: options.inputPath,\n outputDirectory: options.outputDirectory,\n yes: options.yes,\n });\n if (result.changed) {\n const differenceMessage = result.differenceCounts\n ? ` Changes: +${result.differenceCounts.added} ` +\n `~${result.differenceCounts.modified} -${result.differenceCounts.removed}.`\n : '';\n log(\n `Imported ${result.archiveEntryCount} SB3 entries into ${result.outputDirectory} ` +\n `(${result.assetCount} assets, ${result.embeddedExtensionCount} embedded extensions).` +\n differenceMessage,\n );\n } else {\n log(`Already up to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AO,iBAAiB;CAEvE,IAAI,OAAO,wBAAwB,IAAI,OAAO,sBAAsB;AACtE"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["// SPDX-License-Identifier: MPL-2.0\n\nimport path from 'node:path';\nimport process from 'node:process';\nimport {createInterface} from 'node:readline/promises';\n\nimport {assert} from './assert';\nimport {buildSb3} from './build';\nimport {packageVersion} from './constants';\nimport {unbundleSb3} from './extension-bundle-archive';\nimport {bundleExtensions, unbundleExtensions} from './extension-bundle-configuration';\nimport {validateExtensionBundleMetadata} from './extension-bundle-metadata';\nimport type {ExtensionBundleMetadata} from './types';\nimport {migrateExtensionId} from './extension-id-migration';\nimport {replaceSb3Extensions} from './extension-sb3-replacement';\nimport type {ExtensionIdMigrationCounts, ExtensionIdReference} from './extension-id-migration';\nimport {extensionStatus, syncExtensions, updateExtensions} from './extension-sync';\nimport type {ExtensionSyncConfirmContext, FetchImplementation} from './extension-sync';\nimport {importSb3} from './import';\nimport type {OutputReplacementContext} from './import';\nimport type {DirectoryDifferences} from './output-safety';\nimport {createDeterministicSb3, validateSb3Source} from './source';\n\nexport interface HelpCliOptions {\n command: 'help';\n}\n\nexport interface VersionCliOptions {\n command: 'version';\n}\n\nexport interface ImportCliOptions {\n command: 'import';\n discardLocalChanges: boolean;\n inputPath: string;\n outputDirectory: string;\n yes: boolean;\n}\n\nexport interface CheckCliOptions {\n allowedAssetRoots?: string[];\n command: 'check';\n projectAssetsPath?: string;\n sourceDirectory: string;\n}\n\nexport interface BuildCliOptions {\n allowedAssetRoots?: string[];\n cleanUpBlocks?: boolean;\n command: 'build';\n outputPath: string;\n projectAssetsPath?: string;\n sourceDirectory: string;\n yes: boolean;\n}\n\nexport interface ExtensionsStatusCliOptions {\n action: 'status';\n command: 'extensions';\n sourceDirectory: string;\n}\n\nexport interface ExtensionsMutationCliOptions {\n action: 'sync' | 'update';\n allowBreakingApi?: boolean;\n apiManifestArtifact?: string;\n command: 'extensions';\n extensionId?: string;\n migrateToId?: string;\n sourceArtifact?: string;\n sourceDirectory: string;\n yes: boolean;\n}\n\nexport interface ExtensionsMigrateIdCliOptions {\n action: 'migrate-id';\n command: 'extensions';\n fromId: string;\n sourceDirectory: string;\n toId: string;\n yes: boolean;\n}\n\nexport interface ExtensionsBundleCliOptions {\n action: 'bundle';\n bundleId: string;\n bundleName: string;\n metadata?: ExtensionBundleMetadata;\n command: 'extensions';\n extensionIds: string[];\n recoveryCapsule: boolean;\n sourceDirectory: string;\n yes: boolean;\n buildMode?: 'classic' | 'module';\n sharedDependencies?: Record<string, string>;\n}\n\nexport interface ExtensionsUnbundleSourceCliOptions {\n action: 'unbundle';\n bundleId: string;\n command: 'extensions';\n sourceDirectory: string;\n yes: boolean;\n}\n\nexport interface ExtensionsUnbundleArchiveCliOptions {\n action: 'unbundle';\n bundleId: string;\n command: 'extensions';\n inputPath: string;\n outputPath: string;\n yes: boolean;\n}\n\nexport interface ExtensionsReplaceSb3CliOptions {\n action: 'replace-sb3';\n command: 'extensions';\n fromPath?: string;\n inputPath: string;\n outputPath: string;\n yes: boolean;\n}\n\nexport type ExtensionsCliOptions =\n | ExtensionsReplaceSb3CliOptions\n | ExtensionsStatusCliOptions\n | ExtensionsMutationCliOptions\n | ExtensionsMigrateIdCliOptions\n | ExtensionsBundleCliOptions\n | ExtensionsUnbundleSourceCliOptions\n | ExtensionsUnbundleArchiveCliOptions;\n\nexport type CliOptions =\n | HelpCliOptions\n | VersionCliOptions\n | ImportCliOptions\n | CheckCliOptions\n | BuildCliOptions\n | ExtensionsCliOptions;\n\nexport interface RunCliOptions {\n fetch?: FetchImplementation;\n log?: (message: string) => void;\n}\n\ninterface MigrationLogResult {\n applied: boolean;\n artifactReady: boolean;\n counts: ExtensionIdMigrationCounts;\n fromId: string | undefined;\n toId: string | undefined;\n totalChanges: number;\n unclassifiedReferences: ExtensionIdReference[];\n}\n\nexport function usage() {\n return `Usage:\n sb3-toolchain import INPUT.sb3 --output SOURCE_DIR [--yes] [--discard-local-changes]\n sb3-toolchain check SOURCE_DIR [--project-assets MANIFEST.json] [--allow-asset-root DIR ...]\n sb3-toolchain build SOURCE_DIR --output OUTPUT.sb3 [--project-assets MANIFEST.json] [--allow-asset-root DIR ...] [--clean-up-blocks] [--yes]\n sb3-toolchain extensions replace-sb3 INPUT.sb3 [--from DONOR.sb3] --output OUTPUT.sb3 [--yes]\n sb3-toolchain extensions status SOURCE_DIR\n sb3-toolchain extensions sync SOURCE_DIR [--yes]\n sb3-toolchain extensions update SOURCE_DIR [EXTENSION_ID] [--migrate-id NEW_ID] [--artifact PATH] [--api-manifest-artifact PATH] [--allow-breaking-api --yes]\n sb3-toolchain extensions migrate-id SOURCE_DIR --from OLD_ID --to NEW_ID [--yes]\n sb3-toolchain extensions bundle SOURCE_DIR --id BUNDLE_ID --name NAME [EXTENSION_ID ...] [--metadata-json JSON] [--build-mode classic|module] [--share PACKAGE@EXACT_VERSION] [--include-recovery-capsule] [--yes]\n sb3-toolchain extensions unbundle SOURCE_DIR BUNDLE_ID [--yes]\n sb3-toolchain extensions unbundle INPUT.sb3 BUNDLE_ID --output OUTPUT.sb3 [--yes]\n\nCommands:\n import Expand an SB3 into Git-friendly source files.\n check Validate an expanded SB3 source directory.\n build Build a deterministic SB3 from expanded sources.\n extensions Inspect, restore, or update managed embedded extensions.\n\nBuild layout cleanup:\n --clean-up-blocks applies a deterministic TurboWarp-style \"Clean up Blocks\"\n layout to every target in the generated SB3. It never deletes blocks,\n variables, lists, or comments. The expanded source is unchanged, but the\n generated SB3 might not be able to undo the coordinate changes.\n\nProject asset additions:\n --project-assets validates a JSON or YAML manifest and adds its sprites,\n backdrops, costumes, and sounds only to the generated SB3. Input files are confined to the\n manifest directory unless --allow-asset-root explicitly permits another root.\n\nKamishibai SB3 replacement:\n extensions replace-sb3 replaces the runtime bundle and Block Script in INPUT.sb3.\n Omitting --from downloads the published block SB3 from the official samples site\n and verifies its size and SHA-256. --from uses a local donor without network access.\n The input is preserved; output must use a different path. Story data is not migrated.\n\nReplacement safety:\n Differing outputs require interactive confirmation or --yes.\n Import refuses to discard uncommitted Git changes unless\n --discard-local-changes is also specified. --force is not supported.`;\n}\n\nfunction takeValue(arguments_: string[], index: number, option: string): string {\n const value = arguments_[index + 1];\n assert(value && !value.startsWith('-'), `${option} requires a value.`);\n return value;\n}\n\nfunction parseImportArguments(arguments_: string[]): ImportCliOptions {\n let inputPath: string | undefined;\n let outputDirectory: string | undefined;\n let discardLocalChanges = false;\n let yes = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--output') {\n outputDirectory = path.resolve(takeValue(arguments_, index, '--output'));\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else if (argument === '--discard-local-changes') {\n discardLocalChanges = true;\n } else {\n assert(\n argument !== '--force',\n '--force is intentionally unsupported. Use --yes and, only when necessary, ' +\n '--discard-local-changes.',\n );\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!inputPath, 'Only one input SB3 may be specified.');\n inputPath = path.resolve(argument);\n }\n }\n\n assert(inputPath, 'The import command requires INPUT.sb3.');\n assert(outputDirectory, 'The import command requires --output SOURCE_DIR.');\n return {command: 'import', discardLocalChanges, inputPath, outputDirectory, yes};\n}\n\nfunction parseCheckArguments(arguments_: string[]): CheckCliOptions {\n const allowedAssetRoots: string[] = [];\n let projectAssetsPath: string | undefined;\n let sourceDirectory: string | undefined;\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--project-assets') {\n projectAssetsPath = path.resolve(takeValue(arguments_, index, '--project-assets'));\n index += 1;\n } else if (argument === '--allow-asset-root') {\n allowedAssetRoots.push(path.resolve(takeValue(arguments_, index, '--allow-asset-root')));\n index += 1;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!sourceDirectory, 'Only one SB3 source directory may be specified.');\n sourceDirectory = path.resolve(argument);\n }\n }\n assert(sourceDirectory, 'The check command requires SOURCE_DIR.');\n assert(\n allowedAssetRoots.length === 0 || projectAssetsPath,\n '--allow-asset-root requires --project-assets.',\n );\n return {\n ...(allowedAssetRoots.length > 0 ? {allowedAssetRoots} : {}),\n command: 'check',\n ...(projectAssetsPath ? {projectAssetsPath} : {}),\n sourceDirectory,\n };\n}\n\nfunction parseBuildArguments(arguments_: string[]): BuildCliOptions {\n const allowedAssetRoots: string[] = [];\n let cleanUpBlocks = false;\n let sourceDirectory: string | undefined;\n let outputPath: string | undefined;\n let projectAssetsPath: string | undefined;\n let yes = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--clean-up-blocks') {\n cleanUpBlocks = true;\n } else if (argument === '--project-assets') {\n projectAssetsPath = path.resolve(takeValue(arguments_, index, '--project-assets'));\n index += 1;\n } else if (argument === '--allow-asset-root') {\n allowedAssetRoots.push(path.resolve(takeValue(arguments_, index, '--allow-asset-root')));\n index += 1;\n } else if (argument === '--output') {\n outputPath = path.resolve(takeValue(arguments_, index, '--output'));\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!sourceDirectory, 'Only one SB3 source directory may be specified.');\n sourceDirectory = path.resolve(argument);\n }\n }\n\n assert(sourceDirectory, 'The build command requires SOURCE_DIR.');\n assert(outputPath, 'The build command requires --output OUTPUT.sb3.');\n assert(\n allowedAssetRoots.length === 0 || projectAssetsPath,\n '--allow-asset-root requires --project-assets.',\n );\n return {\n ...(allowedAssetRoots.length > 0 ? {allowedAssetRoots} : {}),\n ...(cleanUpBlocks ? {cleanUpBlocks} : {}),\n command: 'build',\n outputPath,\n ...(projectAssetsPath ? {projectAssetsPath} : {}),\n sourceDirectory,\n yes,\n };\n}\n\nfunction parseExtensionMutationArguments(\n action: 'sync' | 'update',\n arguments_: string[],\n): ExtensionsMutationCliOptions {\n let allowBreakingApi = false;\n let apiManifestArtifact: string | undefined;\n let sourceDirectory: string | undefined;\n let extensionId: string | undefined;\n let migrateToId: string | undefined;\n let sourceArtifact: string | undefined;\n let yes = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--yes') {\n yes = true;\n } else if (argument === '--allow-breaking-api') {\n assert(action === 'update', '--allow-breaking-api is only valid for extensions update.');\n allowBreakingApi = true;\n } else if (argument === '--migrate-id') {\n assert(action === 'update', '--migrate-id is only valid for extensions update.');\n migrateToId = takeValue(arguments_, index, '--migrate-id');\n index += 1;\n } else if (argument === '--artifact') {\n assert(action === 'update', '--artifact is only valid for extensions update.');\n sourceArtifact = takeValue(arguments_, index, '--artifact');\n index += 1;\n } else if (argument === '--api-manifest-artifact') {\n assert(action === 'update', '--api-manifest-artifact is only valid for extensions update.');\n apiManifestArtifact = takeValue(arguments_, index, '--api-manifest-artifact');\n index += 1;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n if (!sourceDirectory) {\n sourceDirectory = path.resolve(argument);\n } else {\n assert(action === 'update', `The extensions ${action} command accepts only SOURCE_DIR.`);\n assert(!extensionId, 'Only one EXTENSION_ID may be specified.');\n assert(\n /^[A-Za-z0-9._-]+$/u.test(argument),\n `Invalid embedded extension ID: ${JSON.stringify(argument)}`,\n );\n extensionId = argument;\n }\n }\n }\n\n assert(sourceDirectory, `The extensions ${action} command requires SOURCE_DIR.`);\n assert(\n migrateToId === undefined || extensionId !== undefined,\n '--migrate-id requires an explicit existing EXTENSION_ID.',\n );\n assert(\n sourceArtifact === undefined || migrateToId !== undefined,\n '--artifact requires --migrate-id.',\n );\n assert(\n apiManifestArtifact === undefined || migrateToId !== undefined,\n '--api-manifest-artifact requires --migrate-id.',\n );\n assert(!allowBreakingApi || yes, '--allow-breaking-api requires --yes.');\n return {\n action,\n ...(allowBreakingApi ? {allowBreakingApi} : {}),\n ...(apiManifestArtifact ? {apiManifestArtifact} : {}),\n command: 'extensions',\n extensionId,\n migrateToId,\n sourceArtifact,\n sourceDirectory,\n yes,\n };\n}\n\nfunction parseExtensionIdMigrationArguments(arguments_: string[]): ExtensionsMigrateIdCliOptions {\n let fromId: string | undefined;\n let sourceDirectory: string | undefined;\n let toId: string | undefined;\n let yes = false;\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--from') {\n fromId = takeValue(arguments_, index, '--from');\n index += 1;\n } else if (argument === '--to') {\n toId = takeValue(arguments_, index, '--to');\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!sourceDirectory, 'Only one SB3 source directory may be specified.');\n sourceDirectory = path.resolve(argument);\n }\n }\n assert(sourceDirectory, 'The extensions migrate-id command requires SOURCE_DIR.');\n assert(fromId, 'The extensions migrate-id command requires --from OLD_ID.');\n assert(toId, 'The extensions migrate-id command requires --to NEW_ID.');\n return {\n action: 'migrate-id',\n command: 'extensions',\n fromId,\n sourceDirectory,\n toId,\n yes,\n };\n}\n\nfunction parseExtensionBundleArguments(arguments_: string[]): ExtensionsBundleCliOptions {\n let bundleId: string | undefined;\n let bundleName: string | undefined;\n let metadata: ExtensionBundleMetadata | undefined;\n let recoveryCapsule = false;\n let sourceDirectory: string | undefined;\n const extensionIds: string[] = [];\n let yes = false;\n let buildMode: 'classic' | 'module' | undefined;\n const sharedDependencies: Record<string, string> = {};\n\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--id') {\n bundleId = takeValue(arguments_, index, '--id');\n index += 1;\n } else if (argument === '--name') {\n bundleName = takeValue(arguments_, index, '--name');\n index += 1;\n } else if (argument === '--metadata-json') {\n assert(metadata === undefined, '--metadata-json may only be specified once.');\n const value = takeValue(arguments_, index, '--metadata-json');\n let parsed: unknown;\n try {\n parsed = JSON.parse(value);\n } catch {\n throw new Error('--metadata-json must contain a JSON object.');\n }\n metadata = validateExtensionBundleMetadata(parsed);\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else if (argument === '--include-recovery-capsule') {\n recoveryCapsule = true;\n } else if (argument === '--build-mode') {\n const value = takeValue(arguments_, index, '--build-mode');\n assert(value === 'classic' || value === 'module', '--build-mode must be classic or module.');\n buildMode = value;\n index += 1;\n } else if (argument === '--share') {\n const value = takeValue(arguments_, index, '--share');\n const separator = value.lastIndexOf('@');\n assert(separator > 0, '--share requires PACKAGE@EXACT_VERSION.');\n const name = value.slice(0, separator);\n assert(\n /^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/u.test(name),\n `Invalid shared dependency name: ${name}`,\n );\n assert(\n /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/u.test(value.slice(separator + 1)),\n '--share requires an exact semantic version.',\n );\n assert(!Object.hasOwn(sharedDependencies, name), `Duplicate shared dependency: ${name}`);\n sharedDependencies[name] = value.slice(separator + 1);\n index += 1;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n if (!sourceDirectory) {\n sourceDirectory = path.resolve(argument);\n } else {\n assert(\n /^[a-z0-9]+$/u.test(argument),\n `Bundle member ID must use TurboWarp's [a-z0-9]+ format: ${JSON.stringify(argument)}`,\n );\n extensionIds.push(argument);\n }\n }\n }\n assert(sourceDirectory, 'The extensions bundle command requires SOURCE_DIR.');\n assert(bundleId, 'The extensions bundle command requires --id BUNDLE_ID.');\n assert(bundleName, 'The extensions bundle command requires --name NAME.');\n assert(\n !Object.keys(sharedDependencies).length || buildMode === 'module',\n '--share requires --build-mode module.',\n );\n return {\n action: 'bundle',\n bundleId,\n bundleName,\n ...(metadata === undefined ? {} : {metadata}),\n command: 'extensions',\n extensionIds,\n recoveryCapsule,\n sourceDirectory,\n yes,\n ...(buildMode === undefined ? {} : {buildMode}),\n ...(Object.keys(sharedDependencies).length ? {sharedDependencies} : {}),\n };\n}\n\nfunction parseExtensionUnbundleArguments(\n arguments_: string[],\n): ExtensionsUnbundleSourceCliOptions | ExtensionsUnbundleArchiveCliOptions {\n let bundleId: string | undefined;\n let input: string | undefined;\n let outputPath: string | undefined;\n let yes = false;\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--yes') {\n yes = true;\n } else if (argument === '--output') {\n outputPath = path.resolve(takeValue(arguments_, index, '--output'));\n index += 1;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n if (!input) {\n input = path.resolve(argument);\n } else {\n assert(!bundleId, 'Only one BUNDLE_ID may be specified.');\n bundleId = argument;\n }\n }\n }\n assert(input, 'The extensions unbundle command requires SOURCE_DIR or INPUT.sb3.');\n assert(bundleId, 'The extensions unbundle command requires BUNDLE_ID.');\n if (path.extname(input).toLowerCase() === '.sb3') {\n assert(outputPath, 'SB3 unbundle requires --output OUTPUT.sb3.');\n return {\n action: 'unbundle',\n bundleId,\n command: 'extensions',\n inputPath: input,\n outputPath,\n yes,\n };\n }\n assert(!outputPath, '--output is only valid when unbundling an SB3 file.');\n return {\n action: 'unbundle',\n bundleId,\n command: 'extensions',\n sourceDirectory: input,\n yes,\n };\n}\n\nfunction parseExtensionReplaceSb3Arguments(arguments_: string[]): ExtensionsReplaceSb3CliOptions {\n let fromPath: string | undefined;\n let inputPath: string | undefined;\n let outputPath: string | undefined;\n let yes = false;\n for (let index = 0; index < arguments_.length; index += 1) {\n const argument = arguments_[index];\n if (argument === '--from') {\n assert(!fromPath, '--from may only be specified once.');\n fromPath = path.resolve(takeValue(arguments_, index, '--from'));\n index += 1;\n } else if (argument === '--output') {\n assert(!outputPath, '--output may only be specified once.');\n outputPath = path.resolve(takeValue(arguments_, index, '--output'));\n index += 1;\n } else if (argument === '--yes') {\n yes = true;\n } else {\n assert(!argument.startsWith('-'), `Unknown option: ${argument}`);\n assert(!inputPath, 'Only one input SB3 may be specified.');\n inputPath = path.resolve(argument);\n }\n }\n assert(inputPath, 'The extensions replace-sb3 command requires INPUT.sb3.');\n assert(outputPath, 'The extensions replace-sb3 command requires --output OUTPUT.sb3.');\n return {action: 'replace-sb3', command: 'extensions', fromPath, inputPath, outputPath, yes};\n}\n\nfunction parseExtensionsArguments(arguments_: string[]): ExtensionsCliOptions {\n const [action, ...actionArguments] = arguments_;\n assert(\n action === 'replace-sb3' ||\n action === 'bundle' ||\n action === 'migrate-id' ||\n action === 'status' ||\n action === 'sync' ||\n action === 'unbundle' ||\n action === 'update',\n 'The extensions command requires status, sync, update, migrate-id, bundle, unbundle, or replace-sb3.',\n );\n if (action === 'replace-sb3') return parseExtensionReplaceSb3Arguments(actionArguments);\n if (action === 'status') {\n assert(\n actionArguments.length === 1 && !actionArguments[0].startsWith('-'),\n 'The extensions status command requires exactly one SOURCE_DIR.',\n );\n return {\n action,\n command: 'extensions',\n sourceDirectory: path.resolve(actionArguments[0]),\n };\n }\n if (action === 'migrate-id') {\n return parseExtensionIdMigrationArguments(actionArguments);\n }\n if (action === 'bundle') {\n return parseExtensionBundleArguments(actionArguments);\n }\n if (action === 'unbundle') {\n return parseExtensionUnbundleArguments(actionArguments);\n }\n return parseExtensionMutationArguments(action, actionArguments);\n}\n\nexport function parseCliArguments(arguments_: string[]): CliOptions {\n const normalized = arguments_.filter((argument) => argument !== '--');\n if (normalized.length === 0 || normalized[0] === '--help' || normalized[0] === '-h') {\n return {command: 'help'};\n }\n if (normalized[0] === '--version' || normalized[0] === '-v') {\n return {command: 'version'};\n }\n\n const [command, ...commandArguments] = normalized;\n if (commandArguments.includes('--help') || commandArguments.includes('-h')) {\n return {command: 'help'};\n }\n if (command === 'import') return parseImportArguments(commandArguments);\n if (command === 'check') return parseCheckArguments(commandArguments);\n if (command === 'build') return parseBuildArguments(commandArguments);\n if (command === 'extensions') return parseExtensionsArguments(commandArguments);\n throw new Error(`Unknown command: ${command}`);\n}\n\nfunction formatDifferenceLines(differences: DirectoryDifferences): string {\n const labels: Record<string, string> = {added: '+', modified: '~', removed: '-'};\n const lines = Object.entries(differences).flatMap(([kind, paths]) =>\n paths.map((relativePath: string) => `${labels[kind]} ${relativePath}`),\n );\n const visibleLines = lines.slice(0, 12);\n if (lines.length > visibleLines.length) {\n visibleLines.push(`... and ${lines.length - visibleLines.length} more`);\n }\n return visibleLines.join('\\n');\n}\n\nasync function confirmImportReplacement(context: OutputReplacementContext): Promise<boolean> {\n const {comparison, discardLocalChanges, gitState, outputDirectory} = context;\n assert(\n process.stdin.isTTY && process.stdout.isTTY,\n `Output directory already exists: ${outputDirectory}. ` +\n 'Non-interactive replacement requires --yes.',\n );\n const readline = createInterface({input: process.stdin, output: process.stdout});\n try {\n const gitMessage = gitState.clean\n ? 'Git state: clean'\n : 'Git state: uncommitted changes will be discarded';\n const answer = await readline.question(\n `Existing SB3 source differs from the import candidate:\\n` +\n ` ${outputDirectory}\\n` +\n `${formatDifferenceLines(comparison.differences)}\\n` +\n `${gitMessage}\\n` +\n `${discardLocalChanges ? 'WARNING: --discard-local-changes is active.\\n' : ''}` +\n 'Replace the existing source directory? [y/N] ',\n );\n return /^(?:y|yes)$/iu.test(answer.trim());\n } finally {\n readline.close();\n }\n}\n\nasync function confirmBuildReplacement(outputPath: string): Promise<boolean> {\n assert(\n process.stdin.isTTY && process.stdout.isTTY,\n `Existing SB3 output differs: ${outputPath}. Non-interactive replacement requires --yes.`,\n );\n const readline = createInterface({input: process.stdin, output: process.stdout});\n try {\n const answer = await readline.question(\n `Existing generated SB3 will be replaced:\\n ${outputPath}\\nContinue? [y/N] `,\n );\n return /^(?:y|yes)$/iu.test(answer.trim());\n } finally {\n readline.close();\n }\n}\n\nasync function confirmExtensionReplacement({\n comparison,\n sourceDirectory,\n}: ExtensionSyncConfirmContext): Promise<boolean> {\n assert(\n process.stdin.isTTY && process.stdout.isTTY,\n `Managed extension files differ in ${sourceDirectory}. ` +\n 'Non-interactive replacement requires --yes.',\n );\n const readline = createInterface({input: process.stdin, output: process.stdout});\n try {\n const answer = await readline.question(\n `Managed extension changes will be installed:\\n` +\n ` ${sourceDirectory}\\n` +\n `${formatDifferenceLines(comparison.differences)}\\n` +\n 'Replace these files? [y/N] ',\n );\n return /^(?:y|yes)$/iu.test(answer.trim());\n } finally {\n readline.close();\n }\n}\n\nfunction logMigrationResult(result: MigrationLogResult, log: (message: string) => void): void {\n const counts = Object.entries(result.counts)\n .filter(([, count]) => count > 0)\n .map(([kind, count]) => `${kind}=${count}`)\n .join(', ');\n const action = result.applied ? 'Migrated' : 'Dry run';\n log(\n `${action}: ${result.fromId} -> ${result.toId}; ` +\n `${result.totalChanges} classified changes (${counts || 'none'}); ` +\n `artifact=${result.artifactReady ? 'ready' : 'requires-new-ID'}.`,\n );\n for (const reference of result.unclassifiedReferences) {\n log(\n `Unclassified ${reference.kind}: ${reference.file}${reference.path} = ` +\n JSON.stringify(reference.value),\n );\n }\n}\n\nexport async function runCli(\n arguments_: string[],\n {fetch: fetchImplementation = globalThis.fetch, log = console.log}: RunCliOptions = {},\n): Promise<void> {\n const options = parseCliArguments(arguments_);\n if (options.command === 'help') {\n log(usage());\n return;\n }\n if (options.command === 'version') {\n log(packageVersion);\n return;\n }\n if (options.command === 'check') {\n assert(\n 'sourceDirectory' in options && !('action' in options),\n 'Internal CLI check command routing error.',\n );\n if (options.projectAssetsPath) {\n const result = await createDeterministicSb3(options.sourceDirectory, {\n allowedAssetRoots: options.allowedAssetRoots,\n projectAssetsPath: options.projectAssetsPath,\n });\n log(\n `Valid SB3 source with project assets: ${result.source.resolvedSourceDirectory} ` +\n `(${result.entryCount} entries, ${result.assetCount} assets, ` +\n `${result.assetReferenceCount} references, ${result.embeddedExtensionCount} embedded extensions).`,\n );\n return;\n }\n const result = await validateSb3Source(options.sourceDirectory);\n log(\n `Valid SB3 source: ${result.resolvedSourceDirectory} ` +\n `(${result.sourceManifest.archiveEntries.length} entries, ` +\n `${result.assetContents.size} assets, ${result.assetReferenceCount} references, ` +\n `${result.extensions.length} embedded extensions).`,\n );\n return;\n }\n if (\n options.command === 'build' &&\n 'outputPath' in options &&\n 'sourceDirectory' in options &&\n !('action' in options)\n ) {\n const result = await buildSb3({\n allowedAssetRoots: options.allowedAssetRoots,\n cleanUpBlocks: options.cleanUpBlocks,\n confirmReplace: confirmBuildReplacement,\n outputPath: options.outputPath,\n projectAssetsPath: options.projectAssetsPath,\n sourceDirectory: options.sourceDirectory,\n yes: options.yes,\n });\n const action = result.changed ? 'Built' : 'Already up to date';\n const cleanUpMessage = result.blockCleanUp\n ? `, ${result.blockCleanUp.movedScriptCount}/${result.blockCleanUp.scriptCount} scripts laid out`\n : '';\n log(\n `${action}: ${result.outputPath} (${result.entryCount} entries, ` +\n `${result.assetCount} assets, ${result.embeddedExtensionCount} embedded extensions` +\n `${cleanUpMessage}).`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.command === 'extensions') {\n if (options.action === 'replace-sb3') {\n const result = await replaceSb3Extensions({\n confirmReplace: confirmBuildReplacement,\n fetch: fetchImplementation,\n fromPath: options.fromPath,\n inputPath: options.inputPath,\n outputPath: options.outputPath,\n yes: options.yes,\n });\n log(\n `${result.changed ? 'Wrote' : 'Already up to date'}: ${result.outputPath} (${result.extensionIds.join(', ')}).`,\n );\n log(\n `Donor: ${result.donor.source}; version=${result.donor.version ?? 'unknown'}; sha256=${result.donor.sha256}`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.action === 'bundle') {\n const result = await bundleExtensions({\n bundleId: options.bundleId,\n bundleName: options.bundleName,\n metadata: options.metadata,\n extensionIds: options.extensionIds,\n recoveryCapsule: options.recoveryCapsule,\n buildMode: options.buildMode,\n sharedDependencies: options.sharedDependencies,\n sourceDirectory: options.sourceDirectory,\n yes: options.yes,\n });\n log(\n `${result.applied ? 'Configured' : 'Dry run'} extension bundle: ${result.bundleId} ` +\n `(${result.members.join(', ')}).`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.action === 'unbundle') {\n if ('inputPath' in options) {\n const result = await unbundleSb3({\n bundleId: options.bundleId,\n inputPath: options.inputPath,\n outputPath: options.outputPath,\n yes: options.yes,\n });\n log(\n `${result.applied ? 'Wrote' : 'Dry run'} unbundled SB3: ${result.bundleId} ` +\n `(${result.members.join(', ')}) -> ${result.outputPath}.`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n const result = await unbundleExtensions({\n bundleId: options.bundleId,\n sourceDirectory: options.sourceDirectory,\n yes: options.yes,\n });\n log(\n `${result.applied ? 'Removed' : 'Dry run'} extension bundle: ${result.bundleId} ` +\n `(${result.members.join(', ')}).`,\n );\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.action === 'migrate-id') {\n const result = await migrateExtensionId({\n fromId: options.fromId,\n sourceDirectory: options.sourceDirectory,\n toId: options.toId,\n yes: options.yes,\n });\n logMigrationResult(result, log);\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n if (options.action === 'status') {\n const statuses = await extensionStatus(options.sourceDirectory, {\n fetch: fetchImplementation,\n });\n if (statuses.length === 0) {\n log(`No managed embedded extensions: ${options.sourceDirectory}`);\n return;\n }\n for (const status of statuses) {\n if ('package' in status) {\n log(\n `${status.id}: ${status.state}; local=${status.local}; ` +\n `${status.package}@${status.version} (installed ${status.installedVersion})`,\n );\n continue;\n }\n log(\n `${status.id}: ${status.state}; local=${status.local}; ` +\n `${status.ref} -> ${status.remoteCommit} ` +\n `(installed ${status.resolvedCommit})`,\n );\n }\n return;\n }\n\n const operationOptions = {\n confirmReplace: confirmExtensionReplacement,\n fetch: fetchImplementation,\n sourceDirectory: options.sourceDirectory,\n yes: options.yes,\n };\n const result =\n options.action === 'sync'\n ? await syncExtensions(operationOptions)\n : await updateExtensions({\n ...operationOptions,\n allowBreakingApi: options.allowBreakingApi,\n apiManifestArtifact: options.apiManifestArtifact,\n extensionId: options.extensionId,\n migrateToId: options.migrateToId,\n sourceArtifact: options.sourceArtifact,\n });\n const action = result.changed ? 'Updated' : 'Already up to date';\n log(\n `${action}: ${result.sourceDirectory} ` +\n `(${result.extensions.map((extension) => extension.id).join(', ')}).`,\n );\n if (result.migration) {\n logMigrationResult(\n {\n applied: result.changed,\n artifactReady: true,\n ...result.migration,\n },\n log,\n );\n }\n for (const compatibility of result.apiCompatibility) {\n for (const change of compatibility.changes) {\n log(\n `API ${compatibility.id}: ${change.breaking ? 'breaking' : 'compatible'} ` +\n `${change.kind} ${change.path}`,\n );\n }\n }\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n return;\n }\n\n assert(\n options.command === 'import' && 'inputPath' in options,\n 'Internal CLI command routing error.',\n );\n const result = await importSb3({\n confirmReplace: confirmImportReplacement,\n discardLocalChanges: options.discardLocalChanges,\n inputPath: options.inputPath,\n outputDirectory: options.outputDirectory,\n yes: options.yes,\n });\n if (result.changed) {\n const differenceMessage = result.differenceCounts\n ? ` Changes: +${result.differenceCounts.added} ` +\n `~${result.differenceCounts.modified} -${result.differenceCounts.removed}.`\n : '';\n log(\n `Imported ${result.archiveEntryCount} SB3 entries into ${result.outputDirectory} ` +\n `(${result.assetCount} assets, ${result.embeddedExtensionCount} embedded extensions).` +\n differenceMessage,\n );\n } else {\n log(`Already up to date; no files changed: ${result.outputDirectory}`);\n }\n if (result.rollbackCleanupWarning) log(result.rollbackCleanupWarning);\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2JA,SAAgB,QAAQ;CACtB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCT;AAEA,SAAS,UAAU,YAAsB,OAAe,QAAwB;CAC9E,MAAM,QAAQ,WAAW,QAAQ;CACjC,OAAO,SAAS,CAAC,MAAM,WAAW,GAAG,GAAG,GAAG,OAAO,mBAAmB;CACrE,OAAO;AACT;AAEA,SAAS,qBAAqB,YAAwC;CACpE,IAAI;CACJ,IAAI;CACJ,IAAI,sBAAsB;CAC1B,IAAI,MAAM;CAEV,KAAK,IAAI,QAAQ,GAAG,QAAQ,WAAW,QAAQ,SAAS,GAAG;EACzD,MAAM,WAAW,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= "0.
|
|
2
|
+
export declare const packageVersion = "0.20.0";
|
package/dist/constants.js
CHANGED
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["// SPDX-License-Identifier: MPL-2.0\n\nexport const packageName = '@kubohiroya/sb3-toolchain';\nexport const packageVersion = '0.
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["// SPDX-License-Identifier: MPL-2.0\n\nexport const packageName = '@kubohiroya/sb3-toolchain';\nexport const packageVersion = '0.20.0';\n"],"mappings":";AAEA,IAAa,cAAc;AAC3B,IAAa,iBAAiB"}
|
|
@@ -12,6 +12,7 @@ interface ExtensionBundleComponentMetadata {
|
|
|
12
12
|
export interface ExtensionBundleConfigurationInput {
|
|
13
13
|
bundleId: string;
|
|
14
14
|
bundleName: string;
|
|
15
|
+
metadata?: ExtensionBundleConfiguration['metadata'];
|
|
15
16
|
extensionIds?: string[];
|
|
16
17
|
recoveryCapsule?: boolean;
|
|
17
18
|
sourceDirectory: string;
|
|
@@ -23,6 +24,7 @@ export interface ExtensionBundlePlanResult {
|
|
|
23
24
|
applied: boolean;
|
|
24
25
|
bundleId: string;
|
|
25
26
|
bundleName: string;
|
|
27
|
+
metadata?: ExtensionBundleConfiguration['metadata'];
|
|
26
28
|
changed: boolean;
|
|
27
29
|
components: ExtensionBundleComponentMetadata[];
|
|
28
30
|
counts: ExtensionBundlePlan['counts'];
|
|
@@ -46,8 +48,8 @@ export interface ExtensionUnbundleApplyResult extends ExtensionUnbundlePlanResul
|
|
|
46
48
|
comparison?: DirectoryComparison;
|
|
47
49
|
rollbackCleanupWarning: string | null;
|
|
48
50
|
}
|
|
49
|
-
export declare function planExtensionBundle({ bundleId, bundleName, extensionIds, recoveryCapsule, sourceDirectory, buildMode, sharedDependencies, }: ExtensionBundleConfigurationInput): Promise<ExtensionBundlePlanResult>;
|
|
50
|
-
export declare function bundleExtensions({ bundleId, bundleName, extensionIds, recoveryCapsule, sourceDirectory, yes, buildMode, sharedDependencies, }: ExtensionBundleConfigurationInput): Promise<ExtensionBundleApplyResult>;
|
|
51
|
+
export declare function planExtensionBundle({ bundleId, bundleName, extensionIds, recoveryCapsule, sourceDirectory, buildMode, sharedDependencies, metadata, }: ExtensionBundleConfigurationInput): Promise<ExtensionBundlePlanResult>;
|
|
52
|
+
export declare function bundleExtensions({ bundleId, bundleName, extensionIds, recoveryCapsule, sourceDirectory, yes, buildMode, sharedDependencies, metadata, }: ExtensionBundleConfigurationInput): Promise<ExtensionBundleApplyResult>;
|
|
51
53
|
export declare function planExtensionUnbundle({ bundleId, sourceDirectory, }: {
|
|
52
54
|
bundleId: string;
|
|
53
55
|
sourceDirectory: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assert } from "./assert.js";
|
|
2
2
|
import { assertNoInterruptedRollback, compareDirectories, pathExists, replaceDirectoryTransactionally } from "./output-safety.js";
|
|
3
|
+
import { validateExtensionBundleMetadata } from "./extension-bundle-metadata.js";
|
|
3
4
|
import { validateBundleId, validateBundleName, validateExtensionBundleConfigurations } from "./extension-bundle.js";
|
|
4
5
|
import { buildExtensionBundlesWithModules } from "./extension-module-bundle.js";
|
|
5
6
|
import { createDeterministicSb3, inspectSb3SourceForExtensionSync } from "./source.js";
|
|
@@ -21,7 +22,7 @@ async function readExtensionManifest(source) {
|
|
|
21
22
|
const manifestPath = path.join(source.resolvedSourceDirectory, source.sourceManifest.embeddedExtensions);
|
|
22
23
|
return JSON.parse(await readFile(manifestPath, "utf8"));
|
|
23
24
|
}
|
|
24
|
-
async function configurationContext({ bundleId, bundleName, extensionIds, recoveryCapsule, buildMode, sharedDependencies, sourceDirectory, willReplace }) {
|
|
25
|
+
async function configurationContext({ bundleId, bundleName, extensionIds, recoveryCapsule, buildMode, sharedDependencies, metadata, sourceDirectory, willReplace }) {
|
|
25
26
|
validateBundleId(bundleId);
|
|
26
27
|
validateBundleName(bundleName);
|
|
27
28
|
assert(typeof recoveryCapsule === "boolean", "recoveryCapsule must be a boolean.");
|
|
@@ -36,6 +37,7 @@ async function configurationContext({ bundleId, bundleName, extensionIds, recove
|
|
|
36
37
|
id: bundleId,
|
|
37
38
|
members,
|
|
38
39
|
name: bundleName,
|
|
40
|
+
...metadata === void 0 ? {} : { metadata: validateExtensionBundleMetadata(metadata) },
|
|
39
41
|
...buildMode === void 0 ? {} : { buildMode },
|
|
40
42
|
...sharedDependencies === void 0 ? {} : { sharedDependencies },
|
|
41
43
|
...recoveryCapsule === true ? { recoveryCapsule: true } : {}
|
|
@@ -58,7 +60,7 @@ async function configurationContext({ bundleId, bundleName, extensionIds, recove
|
|
|
58
60
|
source
|
|
59
61
|
};
|
|
60
62
|
}
|
|
61
|
-
async function planExtensionBundle({ bundleId, bundleName, extensionIds, recoveryCapsule = false, sourceDirectory, buildMode, sharedDependencies }) {
|
|
63
|
+
async function planExtensionBundle({ bundleId, bundleName, extensionIds, recoveryCapsule = false, sourceDirectory, buildMode, sharedDependencies, metadata }) {
|
|
62
64
|
const context = await configurationContext({
|
|
63
65
|
bundleId,
|
|
64
66
|
bundleName,
|
|
@@ -67,12 +69,14 @@ async function planExtensionBundle({ bundleId, bundleName, extensionIds, recover
|
|
|
67
69
|
sourceDirectory,
|
|
68
70
|
buildMode,
|
|
69
71
|
sharedDependencies,
|
|
72
|
+
metadata,
|
|
70
73
|
willReplace: false
|
|
71
74
|
});
|
|
72
75
|
return {
|
|
73
76
|
applied: false,
|
|
74
77
|
bundleId,
|
|
75
78
|
bundleName,
|
|
79
|
+
...context.configuredBundle.bundle.metadata === void 0 ? {} : { metadata: structuredClone(context.configuredBundle.bundle.metadata) },
|
|
76
80
|
changed: true,
|
|
77
81
|
components: context.configuredBundle.components.map((component) => component.metadata),
|
|
78
82
|
counts: context.configuredBundle.counts,
|
|
@@ -114,7 +118,7 @@ async function installManifestConfiguration(context, operation) {
|
|
|
114
118
|
});
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
|
-
async function bundleExtensions({ bundleId, bundleName, extensionIds, recoveryCapsule = false, sourceDirectory, yes = false, buildMode, sharedDependencies }) {
|
|
121
|
+
async function bundleExtensions({ bundleId, bundleName, extensionIds, recoveryCapsule = false, sourceDirectory, yes = false, buildMode, sharedDependencies, metadata }) {
|
|
118
122
|
const context = await configurationContext({
|
|
119
123
|
bundleId,
|
|
120
124
|
bundleName,
|
|
@@ -123,11 +127,13 @@ async function bundleExtensions({ bundleId, bundleName, extensionIds, recoveryCa
|
|
|
123
127
|
sourceDirectory,
|
|
124
128
|
buildMode,
|
|
125
129
|
sharedDependencies,
|
|
130
|
+
metadata,
|
|
126
131
|
willReplace: yes
|
|
127
132
|
});
|
|
128
133
|
const plan = {
|
|
129
134
|
bundleId,
|
|
130
135
|
bundleName,
|
|
136
|
+
...context.configuredBundle.bundle.metadata === void 0 ? {} : { metadata: structuredClone(context.configuredBundle.bundle.metadata) },
|
|
131
137
|
components: context.configuredBundle.components.map((component) => component.metadata),
|
|
132
138
|
counts: context.configuredBundle.counts,
|
|
133
139
|
members: [...context.configuredBundle.bundle.members],
|