Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
"flags": ["api-version", "flags-dir", "json", "loglevel", "package-id", "target-org"],
"plugin": "@salesforce/plugin-packaging"
},
{
"alias": ["force:bundle:create"],
"command": "package:bundles:create",
"flagAliases": ["apiversion", "target-hub-org", "targetdevhubusername"],
"flagChars": ["d", "n", "v"],
"flags": ["api-version", "description", "flags-dir", "json", "loglevel", "name", "target-dev-hub"],
"plugin": "@salesforce/plugin-packaging"
},
{
"alias": ["force:package:convert"],
"command": "package:convert",
Expand Down
24 changes: 24 additions & 0 deletions messages/bundle_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# summary

Create a bundle.

# description

First, use this command to create a bunle. Then create a bundle version.

Your --name value must be unique within your namespace.

Run '<%= config.bin %> bundle list to list all bundles in the Dev Hub org.

# examples

- Default Use Case
<%= config.bin %> <%= command.id %> --name <bundle_name> --description "<bundle_description>" --target-dev-hub <dev_hub_alias>`

# flags.name.summary

Name of the bundle to create.

# flags.description.summary

Description of the bundle
16 changes: 16 additions & 0 deletions schemas/package-bundles-create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/BundleCreate",
"definitions": {
"BundleCreate": {
"type": "object",
"properties": {
"Id": {
"type": "string"
}
},
"required": ["Id"],
"additionalProperties": false
}
}
}
57 changes: 57 additions & 0 deletions src/commands/package/bundles/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2018, salesforce.com, inc.
Comment thread
dawson-david-salesforce marked this conversation as resolved.
Outdated
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core';
import { BundleCreateOptions, PackageBundle } from '@salesforce/packaging';
import { Messages } from '@salesforce/core';
import { requiredHubFlag } from '../../../utils/hubFlag.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'bundle_create');
export type BundleCreate = { Id: string };

export class PackageBundlesCreate extends SfCommand<BundleCreate> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly aliases = ['force:bundle:create'];
public static readonly requiresProject = true;
public static readonly flags = {
loglevel,
name: Flags.string({
char: 'n',
summary: messages.getMessage('flags.name.summary'),
required: true,
}),
description: Flags.string({
char: 'd',
summary: messages.getMessage('flags.description.summary'),
}),
'target-dev-hub': requiredHubFlag,
'api-version': orgApiVersionFlagWithDeprecations,
};

public async run(): Promise<BundleCreate> {
Comment thread
btrn11 marked this conversation as resolved.
const { flags } = await this.parse(PackageBundlesCreate);

const options: BundleCreateOptions = {
Description: flags.description ?? '',
BundleName: flags.name,
};
this.spinner.start(`Creating Bundle with name ${options.BundleName}`);
const result = await PackageBundle.create(
flags['target-dev-hub'].getConnection(flags['api-version']),
this.project!,
options
);

this.spinner.stop();
this.table({ data: [{ name: 'Bundle Id', value: result.Id }], title: 'Ids' });

return result;
}
}
Loading