@teambit/cli 0.0.759 → 0.0.761
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.main.runtime.js
CHANGED
|
@@ -6,6 +6,7 @@ require("core-js/modules/es.array.flat.js");
|
|
|
6
6
|
require("core-js/modules/es.array.iterator.js");
|
|
7
7
|
require("core-js/modules/es.array.unscopables.flat.js");
|
|
8
8
|
require("core-js/modules/es.promise.js");
|
|
9
|
+
require("core-js/modules/es.string.trim.js");
|
|
9
10
|
Object.defineProperty(exports, "__esModule", {
|
|
10
11
|
value: true
|
|
11
12
|
});
|
|
@@ -210,6 +211,7 @@ class CLIMain {
|
|
|
210
211
|
command.options = command.options || [];
|
|
211
212
|
command.private = command.private || false;
|
|
212
213
|
command.commands = command.commands || [];
|
|
214
|
+
command.name = command.name.trim();
|
|
213
215
|
if (command.loader === undefined) {
|
|
214
216
|
if (command.internal) {
|
|
215
217
|
command.loader = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_harmony","data","require","_cli","_community","_pMapSeries","_interopRequireDefault","_commandGroups","_consumer","_logger","_lodash","_cli2","_getCommandId","_legacyCommandAdapter","_cliParser","_completion","_cli3","_help","CLIMain","constructor","commandsSlot","onStartSlot","community","logger","_defineProperty2","default","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","name","map","set","values","flat","getCommand","find","registerGroup","description","consoleWarning","registerOnStart","onStartFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","getBaseDomain","parse","onStartFns","currentCommand","process","argv","pMapSeries","onStart","alias","extendedDescription","group","options","private","loader","undefined","internal","helpUrl","isFullUrl","provider","loggerMain","config","createLogger","CLIAspect","id","cliMain","legacyRegistry","buildRegistry","ensureWorkspaceAndScope","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","CompletionCmd","cliCmd","CliCmd","getDocsDomain","helpCmd","HelpCmd","push","exports","CommunityAspect","LoggerAspect","MainRuntime","Slot","withType","addRuntime","loadConsumerIfExist","err","url","startsWith"],"sources":["cli.main.runtime.ts"],"sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport { buildRegistry } from '@teambit/legacy/dist/cli';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\nimport pMapSeries from 'p-map-series';\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { clone } from 'lodash';\nimport { CLIAspect, MainRuntime } from './cli.aspect';\nimport { getCommandId } from './get-command-id';\nimport { LegacyCommandAdapter } from './legacy-command-adapter';\nimport { CLIParser } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean, currentCommand: string) => Promise<void>;\n\nexport type OnStartSlot = SlotRegistry<OnStart>;\nexport type CommandsSlot = SlotRegistry<CommandList>;\n\nexport class CLIMain {\n public groups: GroupsType = clone(groups); // if it's not cloned, it is cached across loadBit() instances\n constructor(\n private commandsSlot: CommandsSlot,\n private onStartSlot: OnStartSlot,\n private community: CommunityMain,\n private logger: Logger\n ) {}\n\n /**\n * registers a new command in to the CLI.\n */\n register(...commands: CommandList) {\n commands.forEach((command) => {\n this.setDefaults(command);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n command.commands!.forEach((cmd) => this.setDefaults(cmd));\n });\n this.commandsSlot.register(commands);\n }\n\n /**\n * helpful for having the same command name in different environments (e.g. legacy and non-legacy).\n * for example `cli.unregister('tag');` removes the \"bit tag\" command.\n */\n unregister(commandName: string) {\n this.commandsSlot.toArray().forEach(([aspectId, commands]) => {\n const filteredCommands = commands.filter((command) => {\n return getCommandId(command.name) !== commandName;\n });\n this.commandsSlot.map.set(aspectId, filteredCommands);\n });\n }\n\n /**\n * list of all registered commands. (legacy and new).\n */\n get commands(): CommandList {\n return this.commandsSlot.values().flat();\n }\n\n /**\n * get an instance of a registered command. (useful for aspects to modify and extend existing commands)\n */\n getCommand(name: string): Command | undefined {\n return this.commands.find((command) => getCommandId(command.name) === name);\n }\n\n /**\n * when running `bit help`, commands are grouped by categories.\n * this method helps registering a new group by providing its name and a description.\n * the name is what needs to be assigned to the `group` property of the Command interface.\n * the description is what shown in the `bit help` output.\n */\n registerGroup(name: string, description: string) {\n if (this.groups[name]) {\n this.logger.consoleWarning(`CLI group \"${name}\" is already registered`);\n } else {\n this.groups[name] = description;\n }\n }\n\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\n return this;\n }\n\n /**\n * execute commands registered to this aspect.\n */\n async run(hasWorkspace: boolean) {\n await this.invokeOnStart(hasWorkspace);\n const CliParser = new CLIParser(this.commands, this.groups, this.community.getBaseDomain());\n await CliParser.parse();\n }\n\n private async invokeOnStart(hasWorkspace: boolean) {\n const onStartFns = this.onStartSlot.values();\n const currentCommand = process.argv[2];\n await pMapSeries(onStartFns, (onStart) => onStart(hasWorkspace, currentCommand));\n }\n\n private setDefaults(command: Command) {\n command.alias = command.alias || '';\n command.description = command.description || '';\n command.extendedDescription = command.extendedDescription || '';\n command.group = command.group || 'ungrouped';\n command.options = command.options || [];\n command.private = command.private || false;\n command.commands = command.commands || [];\n if (command.loader === undefined) {\n if (command.internal) {\n command.loader = false;\n } else {\n command.loader = true;\n }\n }\n if (command.helpUrl && !isFullUrl(command.helpUrl) && this.community) {\n command.helpUrl = `https://${this.community.getBaseDomain()}/${command.helpUrl}`;\n }\n }\n\n static dependencies = [CommunityAspect, LoggerAspect];\n static runtime = MainRuntime;\n static slots = [Slot.withType<CommandList>(), Slot.withType<OnStart>()];\n\n static async provider(\n [community, loggerMain]: [CommunityMain, LoggerMain],\n config,\n [commandsSlot, onStartSlot]: [CommandsSlot, OnStartSlot]\n ) {\n const logger = loggerMain.createLogger(CLIAspect.id);\n const cliMain = new CLIMain(commandsSlot, onStartSlot, community, logger);\n const legacyRegistry = buildRegistry();\n await ensureWorkspaceAndScope();\n const legacyCommands = legacyRegistry.commands;\n const legacyCommandsAdapters = legacyCommands.map((command) => new LegacyCommandAdapter(command, cliMain));\n const cliGenerateCmd = new CliGenerateCmd(cliMain);\n if (!community) {\n cliMain.register(...legacyCommandsAdapters, new CompletionCmd());\n return cliMain;\n }\n const cliCmd = new CliCmd(cliMain, community.getDocsDomain());\n const helpCmd = new HelpCmd(cliMain, community.getDocsDomain());\n cliCmd.commands.push(cliGenerateCmd);\n cliMain.register(...legacyCommandsAdapters, new CompletionCmd(), cliCmd, helpCmd);\n return cliMain;\n }\n}\n\nCLIAspect.addRuntime(CLIMain);\n\n/**\n * kind of a hack.\n * in the legacy, this is running at the beginning and it take care of issues when Bit files are missing,\n * such as \".bit\".\n * (to make this process better, you can easily remove it and run the e2e-tests. you'll see some failing)\n */\nasync function ensureWorkspaceAndScope() {\n try {\n await loadConsumerIfExist();\n } catch (err) {\n // do nothing. it could fail for example with ScopeNotFound error, which is taken care of in \"bit init\".\n }\n}\n\nfunction isFullUrl(url: string) {\n return url.startsWith('http://') || url.startsWith('https://');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAA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AA,GAAAA,OAAA;AAAA,IAAAM,gBAAA,GAAAC,OAAA,EAhIYP,OAAO,kBAsGI,CAACiF,4BAAe,EAAEC,sBAAY,CAAC;AAAA,IAAA5E,gBAAA,GAAAC,OAAA,EAtG1CP,OAAO,aAuGDmF,mBAAW;AAAA,IAAA7E,gBAAA,GAAAC,OAAA,EAvGjBP,OAAO,WAwGH,CAACoF,eAAI,CAACC,QAAQ,CAAc,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAU,CAAC,CAAC;AA0BzEvB,iBAAS,CAACwB,UAAU,CAACtF,OAAO,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA,eAAemE,uBAAuBA,CAAA,EAAG;EACvC,IAAI;IACF,MAAM,IAAAoB,+BAAmB,EAAC,CAAC;EAC7B,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ;EAAA;AAEJ;AAEA,SAAS/B,SAASA,CAACgC,GAAW,EAAE;EAC9B,OAAOA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAChE"}
|
|
1
|
+
{"version":3,"names":["_harmony","data","require","_cli","_community","_pMapSeries","_interopRequireDefault","_commandGroups","_consumer","_logger","_lodash","_cli2","_getCommandId","_legacyCommandAdapter","_cliParser","_completion","_cli3","_help","CLIMain","constructor","commandsSlot","onStartSlot","community","logger","_defineProperty2","default","clone","groups","register","commands","forEach","command","setDefaults","cmd","unregister","commandName","toArray","aspectId","filteredCommands","filter","getCommandId","name","map","set","values","flat","getCommand","find","registerGroup","description","consoleWarning","registerOnStart","onStartFn","run","hasWorkspace","invokeOnStart","CliParser","CLIParser","getBaseDomain","parse","onStartFns","currentCommand","process","argv","pMapSeries","onStart","alias","extendedDescription","group","options","private","trim","loader","undefined","internal","helpUrl","isFullUrl","provider","loggerMain","config","createLogger","CLIAspect","id","cliMain","legacyRegistry","buildRegistry","ensureWorkspaceAndScope","legacyCommands","legacyCommandsAdapters","LegacyCommandAdapter","cliGenerateCmd","CliGenerateCmd","CompletionCmd","cliCmd","CliCmd","getDocsDomain","helpCmd","HelpCmd","push","exports","CommunityAspect","LoggerAspect","MainRuntime","Slot","withType","addRuntime","loadConsumerIfExist","err","url","startsWith"],"sources":["cli.main.runtime.ts"],"sourcesContent":["import { Slot, SlotRegistry } from '@teambit/harmony';\nimport { buildRegistry } from '@teambit/legacy/dist/cli';\nimport { Command } from '@teambit/legacy/dist/cli/command';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\nimport pMapSeries from 'p-map-series';\nimport { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups';\nimport { loadConsumerIfExist } from '@teambit/legacy/dist/consumer';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { clone } from 'lodash';\nimport { CLIAspect, MainRuntime } from './cli.aspect';\nimport { getCommandId } from './get-command-id';\nimport { LegacyCommandAdapter } from './legacy-command-adapter';\nimport { CLIParser } from './cli-parser';\nimport { CompletionCmd } from './completion.cmd';\nimport { CliCmd, CliGenerateCmd } from './cli.cmd';\nimport { HelpCmd } from './help.cmd';\n\nexport type CommandList = Array<Command>;\nexport type OnStart = (hasWorkspace: boolean, currentCommand: string) => Promise<void>;\n\nexport type OnStartSlot = SlotRegistry<OnStart>;\nexport type CommandsSlot = SlotRegistry<CommandList>;\n\nexport class CLIMain {\n public groups: GroupsType = clone(groups); // if it's not cloned, it is cached across loadBit() instances\n constructor(\n private commandsSlot: CommandsSlot,\n private onStartSlot: OnStartSlot,\n private community: CommunityMain,\n private logger: Logger\n ) {}\n\n /**\n * registers a new command in to the CLI.\n */\n register(...commands: CommandList) {\n commands.forEach((command) => {\n this.setDefaults(command);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n command.commands!.forEach((cmd) => this.setDefaults(cmd));\n });\n this.commandsSlot.register(commands);\n }\n\n /**\n * helpful for having the same command name in different environments (e.g. legacy and non-legacy).\n * for example `cli.unregister('tag');` removes the \"bit tag\" command.\n */\n unregister(commandName: string) {\n this.commandsSlot.toArray().forEach(([aspectId, commands]) => {\n const filteredCommands = commands.filter((command) => {\n return getCommandId(command.name) !== commandName;\n });\n this.commandsSlot.map.set(aspectId, filteredCommands);\n });\n }\n\n /**\n * list of all registered commands. (legacy and new).\n */\n get commands(): CommandList {\n return this.commandsSlot.values().flat();\n }\n\n /**\n * get an instance of a registered command. (useful for aspects to modify and extend existing commands)\n */\n getCommand(name: string): Command | undefined {\n return this.commands.find((command) => getCommandId(command.name) === name);\n }\n\n /**\n * when running `bit help`, commands are grouped by categories.\n * this method helps registering a new group by providing its name and a description.\n * the name is what needs to be assigned to the `group` property of the Command interface.\n * the description is what shown in the `bit help` output.\n */\n registerGroup(name: string, description: string) {\n if (this.groups[name]) {\n this.logger.consoleWarning(`CLI group \"${name}\" is already registered`);\n } else {\n this.groups[name] = description;\n }\n }\n\n registerOnStart(onStartFn: OnStart) {\n this.onStartSlot.register(onStartFn);\n return this;\n }\n\n /**\n * execute commands registered to this aspect.\n */\n async run(hasWorkspace: boolean) {\n await this.invokeOnStart(hasWorkspace);\n const CliParser = new CLIParser(this.commands, this.groups, this.community.getBaseDomain());\n await CliParser.parse();\n }\n\n private async invokeOnStart(hasWorkspace: boolean) {\n const onStartFns = this.onStartSlot.values();\n const currentCommand = process.argv[2];\n await pMapSeries(onStartFns, (onStart) => onStart(hasWorkspace, currentCommand));\n }\n\n private setDefaults(command: Command) {\n command.alias = command.alias || '';\n command.description = command.description || '';\n command.extendedDescription = command.extendedDescription || '';\n command.group = command.group || 'ungrouped';\n command.options = command.options || [];\n command.private = command.private || false;\n command.commands = command.commands || [];\n command.name = command.name.trim();\n if (command.loader === undefined) {\n if (command.internal) {\n command.loader = false;\n } else {\n command.loader = true;\n }\n }\n if (command.helpUrl && !isFullUrl(command.helpUrl) && this.community) {\n command.helpUrl = `https://${this.community.getBaseDomain()}/${command.helpUrl}`;\n }\n }\n\n static dependencies = [CommunityAspect, LoggerAspect];\n static runtime = MainRuntime;\n static slots = [Slot.withType<CommandList>(), Slot.withType<OnStart>()];\n\n static async provider(\n [community, loggerMain]: [CommunityMain, LoggerMain],\n config,\n [commandsSlot, onStartSlot]: [CommandsSlot, OnStartSlot]\n ) {\n const logger = loggerMain.createLogger(CLIAspect.id);\n const cliMain = new CLIMain(commandsSlot, onStartSlot, community, logger);\n const legacyRegistry = buildRegistry();\n await ensureWorkspaceAndScope();\n const legacyCommands = legacyRegistry.commands;\n const legacyCommandsAdapters = legacyCommands.map((command) => new LegacyCommandAdapter(command, cliMain));\n const cliGenerateCmd = new CliGenerateCmd(cliMain);\n if (!community) {\n cliMain.register(...legacyCommandsAdapters, new CompletionCmd());\n return cliMain;\n }\n const cliCmd = new CliCmd(cliMain, community.getDocsDomain());\n const helpCmd = new HelpCmd(cliMain, community.getDocsDomain());\n cliCmd.commands.push(cliGenerateCmd);\n cliMain.register(...legacyCommandsAdapters, new CompletionCmd(), cliCmd, helpCmd);\n return cliMain;\n }\n}\n\nCLIAspect.addRuntime(CLIMain);\n\n/**\n * kind of a hack.\n * in the legacy, this is running at the beginning and it take care of issues when Bit files are missing,\n * such as \".bit\".\n * (to make this process better, you can easily remove it and run the e2e-tests. you'll see some failing)\n */\nasync function ensureWorkspaceAndScope() {\n try {\n await loadConsumerIfExist();\n } catch (err) {\n // do nothing. it could fail for example with ScopeNotFound error, which is taken care of in \"bit init\".\n }\n}\n\nfunction isFullUrl(url: string) {\n return url.startsWith('http://') || url.startsWith('https://');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,W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vD,QAAQ,CAAC,GAAG4D,sBAAsB,EAAE,KAAII,2BAAa,EAAC,CAAC,EAAEC,MAAM,EAAEG,OAAO,CAAC;IACjF,OAAOb,OAAO;EAChB;AACF;AAACgB,OAAA,CAAAjF,OAAA,GAAAA,OAAA;AAAA,IAAAM,gBAAA,GAAAC,OAAA,EAjIYP,OAAO,kBAuGI,CAACkF,4BAAe,EAAEC,sBAAY,CAAC;AAAA,IAAA7E,gBAAA,GAAAC,OAAA,EAvG1CP,OAAO,aAwGDoF,mBAAW;AAAA,IAAA9E,gBAAA,GAAAC,OAAA,EAxGjBP,OAAO,WAyGH,CAACqF,eAAI,CAACC,QAAQ,CAAc,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAU,CAAC,CAAC;AA0BzEvB,iBAAS,CAACwB,UAAU,CAACvF,OAAO,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA,eAAeoE,uBAAuBA,CAAA,EAAG;EACvC,IAAI;IACF,MAAM,IAAAoB,+BAAmB,EAAC,CAAC;EAC7B,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ;EAAA;AAEJ;AAEA,SAAS/B,SAASA,CAACgC,GAAW,EAAE;EAC9B,OAAOA,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,UAAU,CAAC;AAChE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.761/dist/cli.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_cli@0.0.761/dist/cli.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.761",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/harmony/cli",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "cli",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.761"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"core-js": "^3.0.0",
|
|
20
20
|
"@babel/runtime": "7.20.0",
|
|
21
21
|
"@teambit/harmony": "0.4.6",
|
|
22
|
-
"@teambit/community": "0.0.
|
|
23
|
-
"@teambit/logger": "0.0.
|
|
22
|
+
"@teambit/community": "0.0.309",
|
|
23
|
+
"@teambit/logger": "0.0.854",
|
|
24
24
|
"@teambit/bit-error": "0.0.402"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@teambit/legacy": "1.0.
|
|
38
|
+
"@teambit/legacy": "1.0.545",
|
|
39
39
|
"react": "^16.8.0 || ^17.0.0",
|
|
40
40
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
41
41
|
},
|
|
Binary file
|