├── src
├── lib
│ ├── urls.json
│ ├── core
│ │ ├── defaultConnectedApp.json
│ │ ├── README.md
│ │ ├── time.ts
│ │ ├── command.ts
│ │ ├── hubOrgApi.ts
│ │ ├── varargsCommand.ts
│ │ └── errors.ts
│ ├── source
│ │ ├── mimeTypes.json
│ │ ├── metadataTypeImpl
│ │ │ ├── workflowMetadataType.ts
│ │ │ ├── samlSsoConfigMetadataType.ts
│ │ │ ├── duplicateRuleMetadataType.ts
│ │ │ ├── flowDefinitionMetadataType.ts
│ │ │ ├── flowMetadataType.ts
│ │ │ ├── apexClassMetadataType.ts
│ │ │ ├── customPageWeblinkMetadataType.ts
│ │ │ ├── customObjectTranslationMetadataType.ts
│ │ │ ├── territory2ModelMetadataType.ts
│ │ │ ├── customLabelsMetadataType.ts
│ │ │ ├── botMetadataType.ts
│ │ │ ├── customObjectMetadataType.ts
│ │ │ ├── customObjectSubtypeMetadataType.ts
│ │ │ ├── sharingRulesMetadataType.ts
│ │ │ ├── customObjectTranslationSubtypeMetadataType.ts
│ │ │ └── nondecomposedTypesWithChildrenMetadataType.ts
│ │ ├── types.ts
│ │ ├── workspaceFileState.ts
│ │ ├── decompositionStrategy
│ │ │ ├── decompositionCommitStrategy.ts
│ │ │ ├── staticResourceDecompositionConfig.ts
│ │ │ ├── inFolderDecompositionConfig.ts
│ │ │ ├── experienceBundleDecompositionStrategyConfig.ts
│ │ │ ├── nonDecomposedContentAndMetadataDecompositionConfig.ts
│ │ │ ├── customObjectTranslationDecompositionConfig.ts
│ │ │ ├── contentDecompositionStrategy.ts
│ │ │ ├── inFolderMetadataWorkspaceDecomposition.ts
│ │ │ ├── describeMetadataDecompositionConfig.ts
│ │ │ ├── nonDecomposedMetadataStrategy.ts
│ │ │ ├── staticResourceContentStrategy.ts
│ │ │ ├── decompositionConfig.ts
│ │ │ ├── nonDecomposedWorkspaceStrategy.ts
│ │ │ ├── virtualDecompositionCommitStrategy.ts
│ │ │ └── decompositionConfigFactory.ts
│ │ ├── typeDefObj.ts
│ │ ├── metadataDocument.ts
│ │ ├── parseManifestEntriesArray.ts
│ │ ├── srcStatusCommand.ts
│ │ └── manifestUtils.ts
│ ├── orgTypes.ts
│ ├── community
│ │ ├── defs
│ │ │ ├── CommunityTemplates.ts
│ │ │ ├── CommunityTemplatesListResponse.ts
│ │ │ ├── CommunityStatusEnum.ts
│ │ │ ├── CommunityInfo.ts
│ │ │ ├── CommunityCreateResponse.ts
│ │ │ ├── CommunityPublishResponse.ts
│ │ │ └── CommunityCreateParams.ts
│ │ ├── service
│ │ │ └── CommunitiesServices.ts
│ │ └── connect
│ │ │ └── CommunityTemplatesResource.ts
│ ├── org
│ │ ├── envTypes.ts
│ │ ├── sandbox
│ │ │ └── sandboxConstants.ts
│ │ ├── snapshot
│ │ │ ├── orgSnapshotListCommand.ts
│ │ │ ├── orgSnapshotDeleteCommand.ts
│ │ │ └── orgSnapshotGetCommand.ts
│ │ ├── orgHooks.ts
│ │ ├── activeScratchOrgDeleteCommand.ts
│ │ ├── orgHighlighter.ts
│ │ ├── orgConfigAttributes.ts
│ │ ├── orgShapeDeleteCommand.ts
│ │ └── shapeRepCreateCommand.ts
│ ├── force-cli
│ │ ├── force-cli-responseParser.ts
│ │ ├── force-cli-command.ts
│ │ ├── force-cli-error.ts
│ │ └── force-cli-config.ts
│ ├── apex
│ │ └── apexLogTailCommand.ts
│ ├── mdapi
│ │ ├── mdapiListmetadataCommand.ts
│ │ ├── mdapiRetrieveCommand.ts
│ │ ├── mdapiDescribemetadataCommand.ts
│ │ ├── mdapiDeployCommand.ts
│ │ ├── mdapiRetrieveReportCommand.ts
│ │ ├── mdapiDeployReportCommand.ts
│ │ ├── mdapiPollIntervalStrategy.ts
│ │ └── mdapiDeployCancelCommand.ts
│ ├── connect
│ │ └── services
│ │ │ ├── ConnectResource.ts
│ │ │ └── ConnectExecutor.ts
│ ├── package1
│ │ ├── package1VersionCreateCommand.ts
│ │ ├── package1VersionCreateGetCommand.ts
│ │ ├── package1VersionDisplayApi.ts
│ │ ├── package1VersionListApi.ts
│ │ ├── package1VersionListCommand.ts
│ │ └── package1VersionDisplayCommand.ts
│ └── package
│ │ ├── PackageInstallRequestGetCommand.ts
│ │ ├── PackageInstallRequestReportCommand.ts
│ │ ├── PackageUninstallRequestGetCommand.ts
│ │ ├── PackageUninstallRequestReportCommand.ts
│ │ └── packageUpdateCommand.ts
└── commands
│ ├── tslint.json
│ └── force
│ ├── package
│ ├── installed
│ │ └── list.ts
│ ├── list.ts
│ ├── install
│ │ └── report.ts
│ ├── uninstall
│ │ └── report.ts
│ ├── version
│ │ ├── create
│ │ │ ├── report.ts
│ │ │ └── list.ts
│ │ ├── report.ts
│ │ ├── promote.ts
│ │ └── delete.ts
│ ├── uninstall.ts
│ ├── delete.ts
│ └── update.ts
│ ├── org
│ ├── snapshot
│ │ ├── list.ts
│ │ ├── get.ts
│ │ ├── delete.ts
│ │ └── create.ts
│ └── shape
│ │ ├── list.ts
│ │ ├── create.ts
│ │ └── delete.ts
│ ├── community
│ ├── template
│ │ └── list.ts
│ └── publish.ts
│ ├── package1
│ └── version
│ │ ├── list.ts
│ │ ├── display.ts
│ │ └── create
│ │ └── get.ts
│ ├── source
│ ├── open.ts
│ ├── deploy
│ │ ├── cancel.ts
│ │ └── report.ts
│ ├── pull.ts
│ └── status.ts
│ ├── apex
│ └── log
│ │ └── tail.ts
│ └── mdapi
│ ├── deploy
│ ├── cancel.ts
│ └── report.ts
│ ├── describemetadata.ts
│ └── listmetadata.ts
├── CODEOWNERS
├── SECURITY.md
├── LICENSE.txt
└── README.md
/src/lib/urls.json:
--------------------------------------------------------------------------------
1 | {
2 | "sandbox": "https://test.salesforce.com",
3 | "production": "https://login.salesforce.com"
4 | }
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Comment line immediately above ownership line is reserved for related gus information. Please be careful while editing.
2 | #ECCN:Open Source
3 |
--------------------------------------------------------------------------------
/src/lib/core/defaultConnectedApp.json:
--------------------------------------------------------------------------------
1 | {
2 | "clientId": "PlatformCLI",
3 | "legacyClientId": "SalesforceDevelopmentExperience",
4 | "legacyClientSecret": "1384510088588713504"
5 | }
--------------------------------------------------------------------------------
/src/lib/source/mimeTypes.json:
--------------------------------------------------------------------------------
1 | {"text/javascript":["js"],"application/x-javascript":["js"],"application/x-zip-compressed":["zip"],"text/x-haml":["haml"],"image/x-png":["png"],"text/xml":["xml"]}
2 |
--------------------------------------------------------------------------------
/src/commands/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@salesforce/dev-config/tslint-strict",
3 | "rules": {
4 | "no-consecutive-blank-lines": true,
5 | "no-shadowed-variable": false,
6 | "no-unused-variable": true,
7 | "no-var-requires": false,
8 | "variable-name": false
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | ## Security
2 |
3 | Please report any security issue to [security@salesforce.com](mailto:security@salesforce.com)
4 | as soon as it is discovered. This library limits its runtime dependencies in
5 | order to reduce the total cost of ownership as much as can be, but all consumers
6 | should remain vigilant and have their security stakeholders review all third-party
7 | products (3PP) like this one and their dependencies.
8 |
--------------------------------------------------------------------------------
/src/lib/orgTypes.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | export enum OrgTypes {
9 | Scratch = 'scratch',
10 | Sandbox = 'sandbox',
11 | }
12 |
13 | export function creatableOrgTypes() {
14 | // The string '*' is appended to the default
15 | return [OrgTypes.Scratch, OrgTypes.Sandbox];
16 | }
17 |
--------------------------------------------------------------------------------
/src/lib/core/README.md:
--------------------------------------------------------------------------------
1 |
2 | **WARNING:** All files in this directory has been deprecated and should now be considered locked against further changes. Its contents
3 | have been partially or wholely superceded by functionality included in the @salesforce/core npm package, and exists
4 | now to service prior uses in this repository only until they can be ported to use the new @salesforce/core library.
5 |
6 |
7 | If you need or want help deciding where to add new functionality or how to migrate to the new library, please
8 | contact the CLI team at alm-cli@salesforce.com.
--------------------------------------------------------------------------------
/src/lib/community/defs/CommunityTemplates.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Definition of a community template
10 | */
11 | export type CommunityTemplates = {
12 | /**
13 | * name of template
14 | */
15 | templateName: string;
16 |
17 | /**
18 | * publisher for the template
19 | */
20 | publisher: string;
21 | };
22 |
--------------------------------------------------------------------------------
/src/lib/org/envTypes.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | const ENV_TYPES = {
9 | sandbox: 'sandbox',
10 | virtual: 'virtual',
11 | prototype: 'prototype',
12 |
13 | creatableTypes() {
14 | // The string '*' is appended to the default
15 | return [`${ENV_TYPES.sandbox}*`, ENV_TYPES.virtual, ENV_TYPES.prototype];
16 | },
17 | };
18 |
19 | export = ENV_TYPES;
20 |
--------------------------------------------------------------------------------
/src/lib/community/defs/CommunityTemplatesListResponse.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * SFDX command output when listing available community templates
10 | */
11 | import { CommunityTemplates } from '../defs/CommunityTemplates';
12 | export type CommunityTemplatesListResponse = {
13 | /**
14 | * list of templates
15 | */
16 | templates: CommunityTemplates[];
17 | total: number;
18 | };
19 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/workflowMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { NondecomposedTypesWithChildrenMetadataType } from './nondecomposedTypesWithChildrenMetadataType';
8 |
9 | export class WorkflowMetadataType extends NondecomposedTypesWithChildrenMetadataType {
10 | getAggregateFullNameFromSourceMemberName(sourceMemberName: string): string {
11 | return sourceMemberName.split('.')[0];
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/lib/force-cli/force-cli-responseParser.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | const SOAP_FAULTSTRING_KEY = 'faultstring';
9 |
10 | export const hasFaultString = function (errMsg: string): boolean {
11 | return errMsg ? errMsg.indexOf(SOAP_FAULTSTRING_KEY) > -1 : false;
12 | };
13 |
14 | export const getFaultString = function (errMsg: string): string {
15 | return errMsg.split('')[1].split('')[0];
16 | };
17 |
--------------------------------------------------------------------------------
/src/lib/source/types.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Type use for individual elements of a package.xml
10 | * ApexClass: Foo
11 | */
12 | export interface ManifestEntry {
13 | type: string;
14 | name: string;
15 | }
16 |
17 | /**
18 | * Capture common source scope options across retrieve and deploy.
19 | */
20 | export interface SourceOptions {
21 | manifest?: string;
22 | metadata?: string;
23 | sourcepath?: string;
24 | }
25 |
--------------------------------------------------------------------------------
/src/lib/community/defs/CommunityStatusEnum.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Community status
10 | */
11 | export type CommunityStatus = {
12 | /**
13 | * Community is still in development
14 | */
15 | UnderConstruction: 'UnderConstruction';
16 |
17 | /**
18 | * Community is live
19 | */
20 | Live: 'Live';
21 |
22 | /**
23 | * Community is inactive
24 | */
25 | DownForMaintenance: 'DownForMaintenance';
26 | };
27 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/samlSsoConfigMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DefaultMetadataType } from './defaultMetadataType';
9 |
10 | export class SamlSsoConfigMetadataType extends DefaultMetadataType {
11 | getAggregateFullNameFromFileProperty(fileProperty, namespace: string) {
12 | if (namespace) {
13 | return fileProperty.fullName.replace(`${namespace}__`, '');
14 | }
15 | return fileProperty.fullName;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/lib/community/defs/CommunityInfo.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { CommunityStatus } from './CommunityStatusEnum';
8 | /**
9 | * A definition of a community
10 | */
11 | export type CommunityInfo = {
12 | /**
13 | * Community name
14 | */
15 | name: string;
16 |
17 | /**
18 | * Community ID
19 | */
20 | id: string;
21 |
22 | /**
23 | * Community Status (Active/Inactive/DownForMaintainance)
24 | */
25 | status?: CommunityStatus;
26 | };
27 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/duplicateRuleMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DefaultMetadataType } from './defaultMetadataType';
9 |
10 | export class DuplicateRuleMetadataType extends DefaultMetadataType {
11 | getAggregateFullNameFromFileProperty(fileProperty, namespace: string): string {
12 | if (namespace) {
13 | return fileProperty.fullName.replace(`${namespace}__`, '');
14 | }
15 | return fileProperty.fullName;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/lib/apex/apexLogTailCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { ApexLogApi } from './apexLogApi';
9 |
10 | export class ApexLogTailCommand {
11 | async execute(context): Promise {
12 | const org = context.org;
13 | const apexLogApi = new ApexLogApi(org, context.flags);
14 | if (!context.flags.skiptraceflag) {
15 | await apexLogApi.prepareTraceFlag(context.flags.debuglevel);
16 | }
17 |
18 | return await apexLogApi.tail();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/lib/community/defs/CommunityCreateResponse.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * SFDX command output when creating a community
10 | */
11 | export type CommunityCreateResponse = {
12 | /**
13 | * output message
14 | */
15 | message: string;
16 |
17 | /**
18 | * name of the community
19 | */
20 | name: string;
21 |
22 | /**
23 | * the next actions that user can do to check, if community is created or not.
24 | */
25 | action: string;
26 | };
27 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/flowDefinitionMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DefaultMetadataType } from './defaultMetadataType';
9 | import { Messages } from '@salesforce/core';
10 |
11 | export class FlowDefinitionMetadataType extends DefaultMetadataType {
12 | getDeprecationMessage() {
13 | Messages.importMessagesDirectory(__dirname);
14 | const messages = Messages.loadMessages('salesforce-alm', 'source');
15 | return messages.getMessage('flowDefinitionDeprecation');
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/flowMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DefaultMetadataType } from './defaultMetadataType';
9 | import { Messages } from '@salesforce/core';
10 |
11 | export class FlowMetadataType extends DefaultMetadataType {
12 | getDeprecationMessage(fullName?: string) {
13 | if (/-[0-9]$/.test(fullName)) {
14 | Messages.importMessagesDirectory(__dirname);
15 | const messages = Messages.loadMessages('salesforce-alm', 'source');
16 | return messages.getMessage('flowDeprecation');
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/apexClassMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DefaultMetadataType } from './defaultMetadataType';
9 |
10 | export class ApexClassMetadataType extends DefaultMetadataType {
11 | getAggregateFullNameFromComponentFailure(componentFailure): string {
12 | // Sometimes, the fullNames of ApexClass failures look like:
13 | // 'classes/DreamHouseSampleDataController.cls-meta.xml'
14 | // so get the fullName from the fileName instead
15 | return this.getAggregateFullNameFromFilePath(componentFailure.fileName);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/customPageWeblinkMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as path from 'path';
9 |
10 | import { DefaultMetadataType } from './defaultMetadataType';
11 | import MetadataRegistry = require('../metadataRegistry');
12 |
13 | export class CustomPageWeblinkMetadataType extends DefaultMetadataType {
14 | protected getMdapiFormattedMetadataFileName(metadataFilePath: string): string {
15 | const fileName = path.basename(metadataFilePath);
16 | return fileName.replace(`.${this.typeDefObj.ext}${MetadataRegistry.getMetadataFileExt()}`, '.weblink');
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/lib/core/time.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Helper class to convert cli wait times between minutes and milliseconds.
10 | */
11 | export class Time {
12 | public static readonly MILLI_IN_SECONDS: number = 1000;
13 | public static readonly SECONDS_IN_MINUTE: number = 60;
14 |
15 | public readonly minutes: number;
16 |
17 | constructor(minutes: number) {
18 | this.minutes = minutes;
19 | }
20 |
21 | get seconds(): number {
22 | return this.minutes * Time.SECONDS_IN_MINUTE;
23 | }
24 |
25 | get milliseconds(): number {
26 | return this.seconds * Time.MILLI_IN_SECONDS;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/lib/mdapi/mdapiListmetadataCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { MdListmetadataApi } from './mdapiListmetadataApi';
9 |
10 | /**
11 | * Command implementation sfdx force:mdapi:listmetadata
12 | */
13 | class MetadataListmetadataCommand {
14 | private mdListmetadata;
15 |
16 | constructor(context) {
17 | this.mdListmetadata = new MdListmetadataApi(context.org);
18 | }
19 |
20 | validate(context) {
21 | return this.mdListmetadata.validate(context);
22 | }
23 |
24 | execute(context) {
25 | return this.mdListmetadata.retrieve(context);
26 | }
27 | }
28 |
29 | export = MetadataListmetadataCommand;
30 |
--------------------------------------------------------------------------------
/src/lib/mdapi/mdapiRetrieveCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { MdRetrieveApi } from './mdapiRetrieveApi';
9 |
10 | /**
11 | * Command implementation that uses mdapiDeployApi * API to retrieve source defined by given or generated package.xml.
12 | */
13 | class MetadataRetrieveCommand {
14 | private mdRetrieve;
15 |
16 | constructor(context) {
17 | this.mdRetrieve = new MdRetrieveApi(context.org);
18 | }
19 |
20 | validate(context) {
21 | return this.mdRetrieve.validate(context);
22 | }
23 |
24 | execute(context) {
25 | return this.mdRetrieve.retrieve(context);
26 | }
27 | }
28 |
29 | export = MetadataRetrieveCommand;
30 |
--------------------------------------------------------------------------------
/src/lib/mdapi/mdapiDescribemetadataCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { MdDescribemetadataApi } from './mdapiDescribemetadataApi';
9 |
10 | /**
11 | * Command implementation sfdx force:mdapi:describemetadata
12 | */
13 | class MetadataDescribemetadataCommand {
14 | private mdDescribemetadata;
15 |
16 | constructor(context) {
17 | this.mdDescribemetadata = new MdDescribemetadataApi(context.org);
18 | }
19 |
20 | validate(context) {
21 | return this.mdDescribemetadata.validate(context);
22 | }
23 |
24 | execute(context) {
25 | return this.mdDescribemetadata.retrieve(context);
26 | }
27 | }
28 |
29 | export = MetadataDescribemetadataCommand;
30 |
--------------------------------------------------------------------------------
/src/lib/community/defs/CommunityPublishResponse.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { CommunityStatus } from './CommunityStatusEnum';
8 | import { URL } from 'url';
9 | /**
10 | * SFDX command output when publishing a community
11 | */
12 | export type CommunityPublishResponse = {
13 | /**
14 | * community ID
15 | */
16 | id: string;
17 |
18 | /**
19 | * output message
20 | */
21 | message: string;
22 |
23 | /**
24 | * name of the community
25 | */
26 | name: string;
27 |
28 | /**
29 | * community status (Active/Inactive/DownForMaintainance)
30 | */
31 | status?: CommunityStatus;
32 |
33 | /**
34 | * url to access the community
35 | */
36 | url: URL;
37 | };
38 |
--------------------------------------------------------------------------------
/src/lib/mdapi/mdapiDeployCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import MdapiDeployApi = require('./mdapiDeployApi');
9 |
10 | /**
11 | * Command implementation that uses mdapiDeployApi to deploy source - directory or zip - to given org.
12 | */
13 | class MetadataDeployCommand {
14 | // TODO: proper property typing
15 | // eslint-disable-next-line no-undef
16 | [property: string]: any;
17 |
18 | constructor(context) {
19 | this.mdDeploy = new MdapiDeployApi(context.org);
20 | }
21 |
22 | validate(context) {
23 | return this.mdDeploy.validate(context);
24 | }
25 |
26 | execute(context) {
27 | return this.mdDeploy.deploy(context);
28 | }
29 | }
30 |
31 | export = MetadataDeployCommand;
32 |
--------------------------------------------------------------------------------
/src/lib/core/command.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { Logger } from '@salesforce/core';
9 |
10 | abstract class Command {
11 | private logger: Logger;
12 | protected readonly loggerName: string;
13 |
14 | constructor(readonly name: string) {
15 | this.loggerName = name;
16 | }
17 |
18 | protected async getLogger(): Promise {
19 | if (!this.logger) {
20 | this.logger = await Logger.child(this.loggerName);
21 | }
22 | return this.logger;
23 | }
24 |
25 | async validate(context: any): Promise {
26 | return Promise.resolve(context);
27 | }
28 |
29 | abstract async execute(context: any, stdinValues?: any): Promise;
30 | }
31 |
32 | export default Command;
33 |
--------------------------------------------------------------------------------
/src/lib/mdapi/mdapiRetrieveReportCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import MdapiRetrieveReportApi = require('./mdapiRetrieveReportApi');
9 |
10 | /**
11 | * Command implementation that uses mdapiDeployApi * API to retrieve source defined by given or generated package.xml.
12 | */
13 | class MetadataRetrieveReportCommand {
14 | private mdRetrieveReport;
15 |
16 | constructor(context) {
17 | this.mdRetrieveReport = new MdapiRetrieveReportApi(context.org);
18 | }
19 |
20 | validate(context) {
21 | return this.mdRetrieveReport.validate(context);
22 | }
23 |
24 | execute(options) {
25 | return this.mdRetrieveReport.report(options);
26 | }
27 | }
28 |
29 | export = MetadataRetrieveReportCommand;
30 |
--------------------------------------------------------------------------------
/src/lib/community/defs/CommunityCreateParams.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { JsonMap } from '@salesforce/ts-types';
9 |
10 | /**
11 | * SFDX command parameters when creating a community
12 | */
13 | export type CommunityCreateParams = {
14 | /**
15 | * name of the community to create
16 | */
17 | name: string;
18 |
19 | /**
20 | * template name to be used to create a community
21 | */
22 | templateName: string;
23 |
24 | /**
25 | * url path prefix of the community.
26 | */
27 | urlPathPrefix: string;
28 |
29 | /**
30 | * the description for the community
31 | */
32 | description;
33 |
34 | /**
35 | * template parameters for the template used to create the community
36 | */
37 | templateParams?: JsonMap;
38 | };
39 |
--------------------------------------------------------------------------------
/src/lib/source/workspaceFileState.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | export enum WorkspaceFileState {
9 | UNCHANGED = 'u',
10 | CHANGED = 'c',
11 | DELETED = 'd',
12 | NEW = 'n',
13 | DUP = 'p',
14 | }
15 |
16 | export type ReadableFileState = 'Unchanged' | 'Changed' | 'Deleted' | 'Add' | 'Duplicate' | 'Unknown';
17 |
18 | export function toReadableState(state: WorkspaceFileState): ReadableFileState {
19 | switch (state) {
20 | case WorkspaceFileState.UNCHANGED:
21 | return 'Unchanged';
22 | case WorkspaceFileState.CHANGED:
23 | return 'Changed';
24 | case WorkspaceFileState.DELETED:
25 | return 'Deleted';
26 | case WorkspaceFileState.NEW:
27 | return 'Add';
28 | case WorkspaceFileState.DUP:
29 | return 'Duplicate';
30 | default:
31 | return 'Unknown';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/lib/mdapi/mdapiDeployReportCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import Stash = require('../core/stash');
9 | import MdapiDeployReportApi = require('./mdapiDeployReportApi');
10 |
11 | /**
12 | * Command implementation that uses mdapiDeployApi to deploy source - directory or zip - to given org.
13 | */
14 | class MetadataDeployReportCommand {
15 | private mdDeployReport;
16 |
17 | constructor(context, private stashkey: string = Stash.Commands.MDAPI_DEPLOY) {
18 | this.mdDeployReport = new MdapiDeployReportApi(context.org, undefined, this.stashkey);
19 | }
20 |
21 | validate(context): Promise {
22 | return this.mdDeployReport.validate(context);
23 | }
24 |
25 | execute(context): Promise {
26 | return this.mdDeployReport.report(context);
27 | }
28 | }
29 |
30 | export = MetadataDeployReportCommand;
31 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/decompositionCommitStrategy.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { MetadataDocument } from '../metadataDocument';
9 |
10 | /**
11 | * Strategy for comiting decompositions to the file system.
12 | *
13 | * Of particular interest is deletion. If an aggregate object has fine grain tracking for its bits then these will be
14 | * deleted independently of a decomposition. If not, then deletion might be the responsibility of this strategy (by
15 | * looking at what's "missing" from the decompositions viz a viz the workspace).
16 | */
17 | export interface DecompositionCommitStrategy {
18 | commit(
19 | documents: Map,
20 | existingPaths: string[],
21 | createDuplicates: boolean,
22 | forceoverwrite: boolean
23 | ): Promise<[string[], string[], string[], string[]]>;
24 | }
25 |
--------------------------------------------------------------------------------
/src/lib/org/sandbox/sandboxConstants.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { Duration } from '@salesforce/kit';
9 |
10 | export const SANDBOXDEF_SRC_SANDBOXNAME = 'SourceSandboxName';
11 |
12 | export class SandboxConstants {
13 | static readonly DEFAULT_MAX_RETRIES: number = 0;
14 | static DEFAULT_POLL_INTERVAL: Duration = Duration.seconds(30);
15 | static readonly SANDBOX_INCOMPLETE_EXCEPTION_MESSAGE = 'INVALID_STATUS';
16 | }
17 |
18 | export class SandboxEventNames {
19 | static readonly EVENT_STATUS: string = 'status';
20 | static readonly EVENT_ASYNCRESULT: string = 'asyncResult';
21 | static readonly EVENT_RESULT: string = 'result';
22 | static readonly EVENT_CLIENTID_NOTSUPPORT: string = 'clientIdNotSupported';
23 | }
24 |
25 | export enum SandboxStatus {
26 | Pending = 'Pending',
27 | PendingRemote = 'Pending Remote Creation',
28 | Processing = 'Processing',
29 | Completed = 'Completed',
30 | Activating = 'Activating',
31 | }
32 |
--------------------------------------------------------------------------------
/src/lib/source/typeDefObj.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DecompositionConfig } from './decompositionStrategy/decompositionConfig';
9 |
10 | export class TypeDefObj {
11 | metadataName: string;
12 | ext: string;
13 | hasContent: boolean;
14 | defaultDirectory: string;
15 | nameForMsgs: string;
16 | nameForMsgsPlural: string;
17 | contentIsBinary: boolean;
18 | isAddressable: boolean;
19 | isSourceTracked: boolean;
20 | childXmlNames: string[];
21 | hasStandardMembers: boolean;
22 | deleteSupported: boolean;
23 | decompositionConfig: DecompositionConfig;
24 | hasVirtualSubtypes: boolean;
25 | inFolder: boolean;
26 | folderTypeDef: TypeDefObj;
27 | isGlobal: boolean;
28 | isEmptyContainer: boolean;
29 | parent: TypeDefObj;
30 |
31 | constructor(metadataName) {
32 | this.metadataName = metadataName;
33 |
34 | // defaults
35 | this.isAddressable = true;
36 | this.isSourceTracked = true;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/force-cli/force-cli-command.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // Based on https://devcenter.heroku.com/articles/developing-cli-plug-ins#all-command-options
9 | export interface Command {
10 | command: string;
11 | description: string;
12 | longDescription: string;
13 | help: string;
14 | requiresProject: boolean;
15 | default?: boolean;
16 | hidden?: boolean;
17 | needsApp?: boolean;
18 | needsOrg?: boolean;
19 | wantsOrg?: boolean;
20 | needsAuth?: boolean;
21 | flags?: Flag[];
22 | variableArgs?: boolean;
23 | args?: Arg[];
24 | supportsTargetUsername?: boolean;
25 | supportsPerfLogLevelFlag?: boolean;
26 | run: (context: any, doneCallback?: Function) => void;
27 | }
28 |
29 | interface Flag {
30 | name: string;
31 | char: string;
32 | hasValue?: boolean;
33 | hidden?: boolean;
34 | required?: boolean;
35 | description?: string;
36 | longDescription?: string;
37 | }
38 |
39 | interface Arg {
40 | name: string;
41 | optional?: boolean;
42 | hidden?: boolean;
43 | }
44 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/customObjectTranslationMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as path from 'path';
9 | import * as fs from 'fs-extra';
10 |
11 | import { DefaultMetadataType } from './defaultMetadataType';
12 | import * as PathUtil from '../sourcePathUtil';
13 |
14 | export class CustomObjectTranslationMetadataType extends DefaultMetadataType {
15 | getAggregateMetadataFilePathFromWorkspacePath(filePath): string {
16 | return PathUtil.removeParentDirFromPath(filePath);
17 | }
18 |
19 | entityExistsInWorkspace(metadataFilePath: string): boolean {
20 | const aggregateFullName = this.getAggregateFullNameFromFilePath(metadataFilePath);
21 | return fs.existsSync(path.join(path.dirname(metadataFilePath), aggregateFullName));
22 | }
23 |
24 | // CustomObjectTranslations are only coarsely tracked so we only want to report
25 | // that a COT has generally changed rather than reporting each associated filePath
26 | displayAggregateRemoteChangesOnly(): boolean {
27 | return true;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/lib/connect/services/ConnectResource.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { JsonCollection } from '@salesforce/ts-types';
8 |
9 | /**
10 | * Describe of a connect api resource
11 | * T - type of return type for success/failure
12 | */
13 | export interface ConnectResource {
14 | /**
15 | * Fetch the relative url of the connect end point
16 | */
17 | fetchRelativeConnectUrl(): Promise;
18 |
19 | /**
20 | * 'GET' or 'POST'
21 | */
22 | getRequestMethod(): string;
23 |
24 | /**
25 | * This will be called only when this#getRequestMethod() is 'POST'
26 | * Return the post params in stringified version
27 | */
28 | fetchPostParams(): Promise;
29 |
30 | /**
31 | * Called if the request is successful
32 | *
33 | * @param result - the result returned by the request
34 | */
35 | handleSuccess(result: JsonCollection): T;
36 |
37 | /**
38 | * Called if the request errored out
39 | *
40 | * @param error - the corresponding error
41 | */
42 | handleError(error: Error): T;
43 | }
44 |
--------------------------------------------------------------------------------
/src/lib/source/metadataDocument.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * An arbitrary memo of document interpretation.
10 | */
11 | export interface MetadataDocumentAnnotation {
12 | name: string;
13 | }
14 |
15 | /**
16 | * Core abstraction for a metadata entity or subtype used by
17 | * decomposition.
18 | *
19 | * Note that there is absolutely no assumption about the nature of either
20 | * the internal memory structure of the document (though often a DOM document)
21 | * or the external representation for storage on the file system (though
22 | * often XML). The external representation is assumed to be utf8 however.
23 | */
24 | export interface MetadataDocument {
25 | data: any;
26 | annotation: MetadataDocumentAnnotation;
27 |
28 | getRepresentation(): string;
29 | setRepresentation(representation: string): void;
30 |
31 | getAnnotation(): MetadataDocumentAnnotation;
32 | setAnnotation(annotation: MetadataDocumentAnnotation): void;
33 |
34 | isEquivalent(doc: MetadataDocument): boolean;
35 | isEquivalentTo(representation: string): boolean;
36 | }
37 |
--------------------------------------------------------------------------------
/src/lib/org/snapshot/orgSnapshotListCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { OrgSnapshotApiImpl, ORG_SNAPSHOT_COLUMNS } from './orgSnapshotApi';
9 | import logger = require('../../core/logApi');
10 |
11 | /**
12 | * List Org Snapshots linked DevHub.
13 | */
14 | class OrgSnapshotListCommand {
15 | private logger;
16 | private records;
17 |
18 | constructor() {
19 | this.logger = logger.child('org:snapshot:list');
20 | this.records = [];
21 | }
22 |
23 | execute(context) {
24 | return OrgSnapshotApiImpl.create(context.org)
25 | .then((orgSnapshotApi) => orgSnapshotApi.list())
26 | .then((records) => {
27 | this.records = records;
28 | return records;
29 | });
30 | }
31 |
32 | /**
33 | * returns a human readable message for a cli output
34 | *
35 | * @param result - the data representing the Org Snapshot
36 | * @returns {string}
37 | */
38 | getColumnData() {
39 | this.logger.styledHeader(this.logger.color.blue(`Org Snapshots [${this.records.length}]`));
40 | return ORG_SNAPSHOT_COLUMNS;
41 | }
42 | }
43 |
44 | export = OrgSnapshotListCommand;
45 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/staticResourceDecompositionConfig.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Decomposition configuration for static resources
10 | */
11 | import { DecompositionConfig, DecomposedSubtypeConfig } from './decompositionConfig';
12 |
13 | export class StaticResourceDecompositionConfig implements DecompositionConfig {
14 | metadataName: string;
15 | isGlobal: boolean;
16 | isEmptyContainer: boolean;
17 | useSparseComposition: boolean;
18 | decompositions: DecomposedSubtypeConfig[];
19 | strategy: string;
20 | workspaceStrategy: string;
21 | commitStrategy: string;
22 | contentStrategy: string;
23 |
24 | constructor(metadataName: string, isGlobal: boolean, isEmptyContainer: boolean) {
25 | this.strategy = 'describeMetadata';
26 | this.workspaceStrategy = 'nonDecomposed';
27 | this.commitStrategy = 'fineGrainTracking';
28 | this.metadataName = metadataName;
29 | this.isGlobal = isGlobal;
30 | this.isEmptyContainer = isEmptyContainer;
31 | this.useSparseComposition = false;
32 | this.decompositions = [];
33 | this.contentStrategy = 'staticResource';
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/territory2ModelMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as path from 'path';
9 |
10 | import MetadataRegistry = require('../metadataRegistry');
11 | import { DefaultMetadataType } from './defaultMetadataType';
12 |
13 | export class Territory2ModelMetadataType extends DefaultMetadataType {
14 | // eslint-disable-next-line @typescript-eslint/no-unused-vars
15 | getDefaultAggregateMetadataPath(fullName: string, defaultSourceDir: string, bundleFileProperties): string {
16 | const fileName = `${fullName}.${this.typeDefObj.ext}${MetadataRegistry.getMetadataFileExt()}`;
17 | return path.join(defaultSourceDir, this.typeDefObj.defaultDirectory, fullName, fileName);
18 | }
19 |
20 | protected getPathToMdapiSourceDir(aggregateFullName: string, mdDir: string): string {
21 | return path.join(mdDir, this.typeDefObj.defaultDirectory, aggregateFullName);
22 | }
23 |
24 | // eslint-disable-next-line @typescript-eslint/no-unused-vars
25 | getAggregateFullNameFromFileProperty(fileProperty, namespace: string): string {
26 | return path.basename(fileProperty.fileName, `.${this.typeDefObj.ext}`);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/inFolderDecompositionConfig.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DecompositionConfig, DecomposedSubtypeConfig } from './decompositionConfig';
9 |
10 | /**
11 | * Decomposition config for Documents, Reports, Email Templates, and Dashboards
12 | */
13 | export class InFolderDecompositionConfig implements DecompositionConfig {
14 | metadataName: string;
15 | isGlobal: boolean;
16 | isEmptyContainer: boolean;
17 | useSparseComposition: boolean;
18 | decompositions: DecomposedSubtypeConfig[];
19 | strategy: string;
20 | workspaceStrategy: string;
21 | commitStrategy: string;
22 | contentStrategy: string;
23 |
24 | constructor(metadataName: string, isGlobal: boolean, isEmptyContainer: boolean) {
25 | this.strategy = 'describeMetadata';
26 | this.workspaceStrategy = 'inFolderMetadataType';
27 | this.commitStrategy = 'fineGrainTracking';
28 | this.contentStrategy = 'nonDecomposedContent';
29 | this.metadataName = metadataName;
30 | this.isGlobal = isGlobal;
31 | this.isEmptyContainer = isEmptyContainer;
32 | this.useSparseComposition = false;
33 | this.decompositions = [];
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/customLabelsMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { NondecomposedTypesWithChildrenMetadataType } from './nondecomposedTypesWithChildrenMetadataType';
9 | import { SourceLocations } from '../sourceLocations';
10 |
11 | export class CustomLabelsMetadataType extends NondecomposedTypesWithChildrenMetadataType {
12 | parseSourceMemberForMetadataRetrieve(
13 | sourceMemberName: string,
14 | sourceMemberType: string,
15 | isNameObsolete: boolean
16 | ): any {
17 | return {
18 | fullName: sourceMemberName,
19 | type: sourceMemberType,
20 | isNameObsolete,
21 | };
22 | }
23 |
24 | // if name is singular 'CustomLabel' and there are no other entries in the nonDecomposedElementsIndex then we should delete the file
25 | // e.g. we're deleting the last CustomLabel entry in the CustomLabels file
26 | shouldDeleteWorkspaceAggregate(metadataType: string): boolean {
27 | if (metadataType === 'CustomLabel') {
28 | return SourceLocations.nonDecomposedElementsIndex.values().length === 1;
29 | } else {
30 | return metadataType === this.getAggregateMetadataName();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/lib/org/orgHooks.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as Config from '@oclif/config';
9 | import { Optional } from '@salesforce/ts-types';
10 |
11 | type HookOpts = {
12 | Command: Config.Command.Class;
13 | argv: string[];
14 | commandId: string;
15 | result: Optional;
16 | };
17 |
18 | export type OrgCreateResult = {
19 | accessToken: string;
20 | clientId: string;
21 | created: string;
22 | createdOrgInstance: string;
23 | devHubUsername: string;
24 | expirationDate: string;
25 | instanceUrl: string;
26 | loginUrl: string;
27 | orgId: string;
28 | username: string;
29 | };
30 |
31 | type PostOrgCreateOpts = HookOpts;
32 |
33 | /**
34 | * Extends OCLIF's Hooks interface to add types for hooks that run on sfdx org commands
35 | */
36 | export interface OrgHooks extends Config.Hooks {
37 | postorgcreate: PostOrgCreateOpts;
38 | }
39 |
40 | export type OrgHook = (this: Config.Hook.Context, options: T extends keyof Config.Hooks ? OrgHooks[T] : T) => any;
41 |
42 | // eslint-disable-next-line no-redeclare
43 | export declare namespace OrgHook {
44 | export type PostOrgCreate = Config.Hook;
45 | }
46 |
--------------------------------------------------------------------------------
/src/lib/core/hubOrgApi.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /* --------------------------------------------------------------------------------------------------------------------
9 | * WARNING: This file has been deprecated and should now be considered locked against further changes. Its contents
10 | * have been partially or wholely superceded by functionality included in the @salesforce/core npm package, and exists
11 | * now to service prior uses in this repository only until they can be ported to use the new @salesforce/core library.
12 | *
13 | * If you need or want help deciding where to add new functionality or how to migrate to the new library, please
14 | * contact the CLI team at alm-cli@salesforce.com.
15 | * ----------------------------------------------------------------------------------------------------------------- */
16 |
17 | import ScratchOrg = require('./scratchOrgApi');
18 |
19 | /**
20 | * TODO Just extend scratch org for now until everything points over to the
21 | * new Org class in sfdx-core.
22 | */
23 | class HubOrgApi extends ScratchOrg {
24 | constructor(force?) {
25 | super(force, ScratchOrg.Defaults.DEVHUB);
26 | }
27 | }
28 |
29 | export = HubOrgApi;
30 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/experienceBundleDecompositionStrategyConfig.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { DecompositionConfig, DecomposedSubtypeConfig } from './decompositionConfig';
8 |
9 | /**
10 | * Config for ExperienceBundle. Uses nonDecomposed strategy except for content strategy
11 | */
12 | export class ExperienceBundleDecompositionStrategyConfig implements DecompositionConfig {
13 | metadataName: string;
14 | isGlobal: boolean;
15 | isEmptyContainer: boolean;
16 | useSparseComposition: boolean;
17 | decompositions: DecomposedSubtypeConfig[];
18 | strategy: string;
19 | workspaceStrategy: string;
20 | commitStrategy: string;
21 | contentStrategy: string;
22 |
23 | constructor(metadataName: string, isGlobal: boolean, isEmptyContainer: boolean) {
24 | this.strategy = 'nonDecomposed';
25 | this.workspaceStrategy = 'nonDecomposed';
26 | this.commitStrategy = 'fineGrainTracking';
27 | this.metadataName = metadataName;
28 | this.isGlobal = isGlobal;
29 | this.isEmptyContainer = isEmptyContainer;
30 | this.useSparseComposition = false;
31 | this.decompositions = [];
32 | this.contentStrategy = 'experienceBundleStrategy';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/nonDecomposedContentAndMetadataDecompositionConfig.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { DecompositionConfig, DecomposedSubtypeConfig } from './decompositionConfig';
8 |
9 | /**
10 | * Decomposition configuration for metadata types that do not require any content or metadata decompositions
11 | */
12 | export class NonDecomposedContentAndMetadataDecompositionConfig implements DecompositionConfig {
13 | metadataName: string;
14 | isGlobal: boolean;
15 | isEmptyContainer: boolean;
16 | useSparseComposition: boolean;
17 | decompositions: DecomposedSubtypeConfig[];
18 | strategy: string;
19 | workspaceStrategy: string;
20 | commitStrategy: string;
21 | contentStrategy: string;
22 |
23 | constructor(metadataName: string, isGlobal: boolean, isEmptyContainer: boolean) {
24 | this.strategy = 'nonDecomposed';
25 | this.workspaceStrategy = 'nonDecomposed';
26 | this.commitStrategy = 'fineGrainTracking';
27 | this.metadataName = metadataName;
28 | this.isGlobal = isGlobal;
29 | this.isEmptyContainer = isEmptyContainer;
30 | this.useSparseComposition = false;
31 | this.decompositions = [];
32 | this.contentStrategy = 'nonDecomposedContent';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/customObjectTranslationDecompositionConfig.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DecompositionConfig, DecomposedSubtypeConfig } from './decompositionConfig';
9 |
10 | /**
11 | * Decomposition configuration for the describeMetadata decomposition and the folder per subtype
12 | * workspace manifestation.
13 | */
14 | export class CustomObjectTranslationDecompositionConfig implements DecompositionConfig {
15 | metadataName: string;
16 | isGlobal: boolean;
17 | isEmptyContainer: boolean;
18 | useSparseComposition: boolean;
19 | decompositions: DecomposedSubtypeConfig[];
20 | strategy: string;
21 | workspaceStrategy: string;
22 | commitStrategy: string;
23 | contentStrategy: string;
24 |
25 | constructor(metadataName: string, isGlobal: boolean, isEmptyContainer: boolean) {
26 | this.strategy = 'describeMetadata';
27 | this.workspaceStrategy = 'folderPerSubtype';
28 | this.commitStrategy = 'virtualDecomposition';
29 | this.contentStrategy = 'N/A';
30 | this.metadataName = metadataName;
31 | this.isGlobal = isGlobal;
32 | this.isEmptyContainer = isEmptyContainer;
33 | this.useSparseComposition = false;
34 | this.decompositions = [];
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/lib/mdapi/mdapiPollIntervalStrategy.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | const _small = [0.5];
9 | const _medium = [0.5];
10 | const _large = [0.5];
11 |
12 | class MdapiPollIntervalStrategy {
13 | // TODO: proper property typing
14 | // eslint-disable-next-line no-undef
15 | [property: string]: any;
16 |
17 | constructor(sourceElementsToUpsert, sourceElementsToDelete) {
18 | const totalElementsToPush = sourceElementsToUpsert.length + sourceElementsToDelete.length;
19 | if (totalElementsToPush <= 10) {
20 | this.intervals = _small;
21 | } else if (totalElementsToPush <= 50) {
22 | this.intervals = _medium;
23 | } else {
24 | this.intervals = _large;
25 | }
26 | }
27 |
28 | /**
29 | * Returns an appropriate polling interval (in milliseconds) for the given iteration.
30 | */
31 | getInterval(iteration) {
32 | let index = iteration - 1;
33 | if (index < 0) {
34 | index = 0;
35 | }
36 | let intervalInSeconds;
37 | if (index < this.intervals.length) {
38 | intervalInSeconds = this.intervals[index];
39 | } else {
40 | intervalInSeconds = this.intervals[this.intervals.length - 1];
41 | }
42 | return intervalInSeconds * 1000;
43 | }
44 | }
45 |
46 | export = MdapiPollIntervalStrategy;
47 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2020, Salesforce.com, Inc.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 |
6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 |
8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 |
10 | * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11 |
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13 |
--------------------------------------------------------------------------------
/src/lib/community/service/CommunitiesServices.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { Org } from '@salesforce/core/lib/org';
8 | import { QueryResult } from 'jsforce';
9 | import { CommunityInfo } from '../defs/CommunityInfo';
10 |
11 | /**
12 | * Helper services for Communities
13 | */
14 | export class CommunitiesServices {
15 | /**
16 | * Get community name from the given id
17 | *
18 | * @param org - the org to query
19 | * @param name - the given community name
20 | *
21 | * @returns - the community id for the given name
22 | */
23 | public static async fetchCommunityInfoFromName(org: Org, name: string): Promise {
24 | if (!name) {
25 | return Promise.resolve(undefined);
26 | }
27 | const result: QueryResult = await CommunitiesServices.runQuery(
28 | org,
29 | `SELECT Id, Status FROM NETWORK WHERE NAME = '${name}'`
30 | );
31 | if (result.totalSize > 0) {
32 | const record = result.records[0];
33 | return {
34 | name,
35 | id: record['Id'],
36 | status: record['Status'],
37 | };
38 | }
39 | }
40 |
41 | public static async runQuery(org: Org, query: string): Promise> {
42 | if (!query) {
43 | return;
44 | }
45 | return org.getConnection().query(query);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/lib/package1/package1VersionCreateCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // Local
9 | import logger = require('../core/logApi');
10 | import messages = require('../messages');
11 | import * as Package1VersionCreateApi from './package1VersionCreateApi';
12 |
13 | const Package1VersionCreateCommand = function () {
14 | this.messages = messages();
15 | this.logger = logger.child('Package1VersionCreateCommand');
16 | this.createApi = new Package1VersionCreateApi();
17 | };
18 |
19 | Package1VersionCreateCommand.prototype.execute = function (context) {
20 | this.org = context.org;
21 | return this.createApi.execute(context);
22 | };
23 |
24 | Package1VersionCreateCommand.prototype.poll = function (context, id, retries) {
25 | this.org = context.org;
26 | return this.createApi.poll(context, id, retries);
27 | };
28 |
29 | /**
30 | * returns a human readable message for a cli output
31 | *
32 | * @param result - the data representing the Package Version
33 | * @returns {string}
34 | */
35 | Package1VersionCreateCommand.prototype.getHumanSuccessMessage = function (result) {
36 | const arg = result.Status === 'SUCCESS' ? [result.MetadataPackageVersionId] : [result.Id, this.org.name];
37 | return this.messages.getMessage(result.Status, arg, 'package1_version_create_get');
38 | };
39 |
40 | export = Package1VersionCreateCommand;
41 |
--------------------------------------------------------------------------------
/src/lib/org/snapshot/orgSnapshotDeleteCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { OrgSnapshotApiImpl } from './orgSnapshotApi';
9 | import Messages = require('../../messages');
10 | const messages = Messages();
11 | import logger = require('../../core/logApi');
12 |
13 | /**
14 | * Delete a Org Snapshot record.
15 | */
16 | class OrgSnapshotDeleteCommand {
17 | private logger;
18 | private orgSnapshotIdOrName: string;
19 |
20 | constructor() {
21 | this.logger = logger.child('org:snapshot:delete');
22 | }
23 |
24 | execute(context) {
25 | // double-check
26 | if (!context.flags.snapshot) {
27 | throw new Error(messages.getMessage('snapshotInvalid', [], 'orgSnapshot'));
28 | }
29 |
30 | this.orgSnapshotIdOrName = context.flags.snapshot;
31 | return OrgSnapshotApiImpl.create(context.org).then((orgSnapshotApi) =>
32 | orgSnapshotApi.delete(this.orgSnapshotIdOrName)
33 | );
34 | }
35 |
36 | /**
37 | * returns a human readable message for a cli output
38 | *
39 | * @param result - the data representing the Org Snapshot
40 | * @returns {string}
41 | */
42 | // eslint-disable-next-line @typescript-eslint/no-unused-vars
43 | getHumanSuccessMessage(result) {
44 | this.logger.log(`Successfully deleted snapshot ${this.orgSnapshotIdOrName}.`);
45 | return '';
46 | }
47 | }
48 |
49 | export = OrgSnapshotDeleteCommand;
50 |
--------------------------------------------------------------------------------
/src/lib/package/PackageInstallRequestGetCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Contains config details and operations meant for package subscriber orgs.
10 | * This could potentially include test orgs used by CI process for testing packages,
11 | * and target subscriber orgs.
12 | **/
13 | import logger = require('../core/logApi');
14 | import PackageInstallCommand = require('./packageInstallCommand');
15 |
16 | const DEFAULT_MAX_POLL = 0;
17 |
18 | class PackageInstallRequestGetCommand {
19 | // TODO: proper property typing
20 | // eslint-disable-next-line no-undef
21 | [property: string]: any;
22 |
23 | constructor() {
24 | this.maxRetries = DEFAULT_MAX_POLL;
25 | this.packageInstallRequestId = null;
26 | this.logger = logger.child('PackageInstallRequestGetCommand');
27 | }
28 |
29 | execute(context) {
30 | this.packageInstallRequestId = context.flags.requestid;
31 | this.packageInstallCommand = new PackageInstallCommand(context);
32 |
33 | return this.packageInstallCommand.poll(context, this.packageInstallRequestId, this.maxRetries);
34 | }
35 |
36 | /**
37 | * returns a human readable message for a cli output
38 | *
39 | * @returns {string}
40 | */
41 | getHumanSuccessMessage(result) {
42 | return this.packageInstallCommand.getHumanSuccessMessage(result);
43 | }
44 | }
45 |
46 | export = PackageInstallRequestGetCommand;
47 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/contentDecompositionStrategy.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Contract for where and how content files will be decomposed and saved to the workspace
10 | */
11 |
12 | export interface ContentDecompositionStrategy {
13 | /**
14 | * Gets the list of paths to content files in the workspace for the given metadata entity
15 | *
16 | * @param metadataFilePath
17 | */
18 | getContentPaths(metadataFilePath: string): string[];
19 |
20 | /**
21 | *
22 | * @param metadataFilePath - the nondecomposed metadata path for the given metadata entity
23 | * @param retrievedContentFilePaths - the paths to the files from which the content will be copied/extracted
24 | * @param retrievedMetadataFilePath - the path to the retrieved metadata file
25 | * @param createDuplicates - whether to create .dup files in case there are identical existing content files
26 | * @param unsupportedMimeTypes - list of static resource mime types that are not allowlisted for support
27 | * @param forceoverwrite - force an overwrite
28 | */
29 | saveContent(
30 | metadataFilePath: string,
31 | retrievedContentFilePaths: string[],
32 | retrievedMetadataFilePath: string,
33 | createDuplicates: boolean,
34 | unsupportedMimeTypes: string[],
35 | forceoverwrite: boolean
36 | ): Promise<[string[], string[], string[], string[]]>;
37 | }
38 |
--------------------------------------------------------------------------------
/src/commands/force/package/installed/list.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import Messages = require('../../../../lib/messages');
13 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
14 |
15 | const messages = Messages();
16 | import consts = require('../../../../lib/core/constants');
17 |
18 | export class PackageInstalledListCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_installed_list');
20 | public static readonly longDescription = messages.getMessage('cliLongDescription', [], 'package_installed_list');
21 | public static readonly help = messages.getMessage('help', [], 'package_installed_list');
22 | public static readonly orgType = consts.DEFAULT_USERNAME;
23 | public static readonly requiresUsername = true;
24 | public static readonly requiresProject = true;
25 | public async run(): Promise {
26 | const context = await this.resolveLegacyContext();
27 | const packageInstalledListCommand = require('../../../../lib/package/packageInstalledListCommand');
28 |
29 | return this.execLegacyCommand(new packageInstalledListCommand.packageInstalledListCommand(), context);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/lib/package/PackageInstallRequestReportCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Contains config details and operations meant for package subscriber orgs.
10 | * This could potentially include test orgs used by CI process for testing packages,
11 | * and target subscriber orgs.
12 | **/
13 | import logger = require('../core/logApi');
14 | import PackageInstallCommand = require('./packageInstallCommand');
15 |
16 | const DEFAULT_MAX_POLL = 0;
17 |
18 | class PackageInstallRequestReportCommand {
19 | // TODO: proper property typing
20 | // eslint-disable-next-line no-undef
21 | [property: string]: any;
22 |
23 | constructor() {
24 | this.maxRetries = DEFAULT_MAX_POLL;
25 | this.packageInstallRequestId = null;
26 | this.logger = logger.child('PackageInstallRequestReportCommand');
27 | }
28 |
29 | execute(context) {
30 | this.packageInstallRequestId = context.flags.requestid;
31 | this.packageInstallCommand = new PackageInstallCommand(context);
32 |
33 | return this.packageInstallCommand.poll(context, this.packageInstallRequestId, this.maxRetries);
34 | }
35 |
36 | /**
37 | * returns a human readable message for a cli output
38 | *
39 | * @returns {string}
40 | */
41 | getHumanSuccessMessage(result) {
42 | return this.packageInstallCommand.getHumanSuccessMessage(result);
43 | }
44 | }
45 |
46 | export = PackageInstallRequestReportCommand;
47 |
--------------------------------------------------------------------------------
/src/lib/package/PackageUninstallRequestGetCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Contains config details and operations meant for package subscriber orgs.
10 | * This could potentially include test orgs used by CI process for testing packages,
11 | * and target subscriber orgs.
12 | **/
13 | import logger = require('../core/logApi');
14 | import PackageUninstallCommand = require('./packageUninstallCommand');
15 |
16 | const DEFAULT_MAX_POLL = 0;
17 |
18 | class PackageUninstallRequestGetCommand {
19 | // TODO: proper property typing
20 | // eslint-disable-next-line no-undef
21 | [property: string]: any;
22 |
23 | constructor() {
24 | this.maxRetries = DEFAULT_MAX_POLL;
25 | this.packageUninstallRequestId = null;
26 | this.logger = logger.child('PackageUninstallRequestGetCommand');
27 | }
28 |
29 | execute(context) {
30 | this.packageUninstallRequestId = context.flags.requestid;
31 | this.packageUninstallCommand = new PackageUninstallCommand(context);
32 |
33 | return this.packageUninstallCommand.poll(context, this.packageUninstallRequestId, this.maxRetries);
34 | }
35 |
36 | /**
37 | * returns a human readable message for a cli output
38 | *
39 | * @returns {string}
40 | */
41 | getHumanSuccessMessage(result) {
42 | return this.packageUninstallCommand.getHumanSuccessMessage(result);
43 | }
44 | }
45 |
46 | export = PackageUninstallRequestGetCommand;
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # salesforce-alm
2 |
3 | **This code is read-only and not meant to be executed, edited, or contributed to.**
4 |
5 | This repository represents a snapshot of the [salesforce-alm](https://www.npmjs.com/package/salesforce-alm) (commonly referred to as the toolbelt) plug-in source code for the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). The toolbelt is the largest plug-in for the CLI and it contains most of the force commands including the [source format](https://trailhead.salesforce.com/en/content/learn/modules/sfdx_dev_model/sfdx_dev_model_sdd) and conversion for commands.
6 |
7 | Our goal is to completely open-source all Salesforce CLI source: the toolbelt plus all Salesforce CLI repositories and plug-ins. This toolbelt snapshot is the first step towards full open-source Salesforce CLI code.
8 |
9 | Why aren’t we open-sourcing everything right now? We’ve had an overwhelming number of requests to look at the toolbelt code. This snapshot is a stopgap. The CLI team is working on open source plans. We’ve determined it will take a significant amount of engineering hours to migrate our current development and build process to an open source repository. Therefore, we will move code in chunks as we break up the toolbelt into plug-ins and open source as we go.
10 |
11 | Updates: We plan to release an update of this code every Salesforce Release (three times per year). This way the community will be able to investigate any changes to the toolbelt as they come out.
12 |
13 | Please continue to provide feedback at the [Salesforce CLI issues only repo](https://github.com/forcedotcom/cli). We will not be accepting PRs to this repository.
14 |
--------------------------------------------------------------------------------
/src/lib/package1/package1VersionCreateGetCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Contains config details and operations meant for package subscriber orgs.
10 | * This could potentially include test orgs used by CI process for testing packages,
11 | * and target subscriber orgs.
12 | **/
13 | import logger = require('../core/logApi');
14 | import * as Package1VersionCreateCommand from './package1VersionCreateCommand';
15 |
16 | const DEFAULT_MAX_POLL = 0;
17 |
18 | class Package1VersionCreateGetCommand {
19 | // TODO: proper property typing
20 | // eslint-disable-next-line no-undef
21 | [property: string]: any;
22 |
23 | constructor() {
24 | this.maxRetries = DEFAULT_MAX_POLL;
25 | this.packageUploadRequestId = null;
26 | this.logger = logger.child('Package1VersionCreateGetCommand');
27 | }
28 |
29 | execute(context) {
30 | this.packageUploadRequestId = context.flags.requestid;
31 | this.package1VersionCreateCommand = new Package1VersionCreateCommand();
32 |
33 | return this.package1VersionCreateCommand.poll(context, this.packageUploadRequestId, this.maxRetries);
34 | }
35 |
36 | /**
37 | * returns a human readable message for a cli output
38 | *
39 | * @returns {string}
40 | */
41 | getHumanSuccessMessage(result) {
42 | return this.package1VersionCreateCommand.getHumanSuccessMessage(result);
43 | }
44 | }
45 |
46 | export = Package1VersionCreateGetCommand;
47 |
--------------------------------------------------------------------------------
/src/lib/package/PackageUninstallRequestReportCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * Contains config details and operations meant for package subscriber orgs.
10 | * This could potentially include test orgs used by CI process for testing packages,
11 | * and target subscriber orgs.
12 | **/
13 | import logger = require('../core/logApi');
14 | import PackageUninstallCommand = require('./packageUninstallCommand');
15 |
16 | const DEFAULT_MAX_POLL = 0;
17 |
18 | class PackageUninstallRequestReportCommand {
19 | // TODO: proper property typing
20 | // eslint-disable-next-line no-undef
21 | [property: string]: any;
22 |
23 | constructor() {
24 | this.maxRetries = DEFAULT_MAX_POLL;
25 | this.packageUninstallRequestId = null;
26 | this.logger = logger.child('PackageUninstallRequestReportCommand');
27 | }
28 |
29 | execute(context) {
30 | this.packageUninstallRequestId = context.flags.requestid;
31 | this.packageUninstallCommand = new PackageUninstallCommand(context);
32 |
33 | return this.packageUninstallCommand.poll(context, this.packageUninstallRequestId, this.maxRetries);
34 | }
35 |
36 | /**
37 | * returns a human readable message for a cli output
38 | *
39 | * @returns {string}
40 | */
41 | getHumanSuccessMessage(result) {
42 | return this.packageUninstallCommand.getHumanSuccessMessage(result);
43 | }
44 | }
45 |
46 | export = PackageUninstallRequestReportCommand;
47 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/botMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as path from 'path';
9 | import { removeParentDirFromPath, canRead } from '../sourcePathUtil';
10 | import { DefaultMetadataType } from './defaultMetadataType';
11 |
12 | export class BotMetadataType extends DefaultMetadataType {
13 | hasIndividuallyAddressableChildWorkspaceElements(): boolean {
14 | return true;
15 | }
16 |
17 | getAggregateMetadataFilePathFromWorkspacePath(filePath: string): string {
18 | super.debug(() => `getAggregateMetadataFilePathFromWorkspacePath filePath: ${filePath}`);
19 | return removeParentDirFromPath(filePath);
20 | }
21 |
22 | entityExistsInWorkspace(metadataFilePath: string): boolean {
23 | const aggregateFullName = this.getAggregateFullNameFromFilePath(metadataFilePath);
24 | super.debug(() => `entityExistsInWorkspace metadataFilePath: ${metadataFilePath}`);
25 | return canRead(path.join(path.dirname(metadataFilePath), aggregateFullName));
26 | }
27 |
28 | isContainerValid(container): boolean {
29 | const containerDataNodes = container.data.childNodes;
30 | const isValid = !(
31 | containerDataNodes &&
32 | containerDataNodes[0].tagName === 'xml' &&
33 | containerDataNodes[1].tagName == this.getMetadataName() &&
34 | containerDataNodes[1].childNodes.length === 0
35 | );
36 | super.debug(() => `isContainerValid isValid: ${isValid}`);
37 | return isValid;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/commands/force/org/snapshot/list.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import Messages = require('../../../../lib/messages');
13 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
14 |
15 | const messages = Messages();
16 | import consts = require('../../../../lib/core/constants');
17 |
18 | export class OrgSnapshotListCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('listSnapshotCmdDescription', [], 'orgSnapshot');
20 | public static readonly longDescription = messages.getMessage('listSnapshotCmdDescriptionLong', [], 'orgSnapshot');
21 | public static readonly help = messages.getMessage('listSnapshotCmdHelp', [], 'orgSnapshot');
22 | public static readonly showProgress = true;
23 | public static readonly requiresProject = false;
24 | public static readonly requiresDevhubUsername = true;
25 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
26 | public async run(): Promise {
27 | const context = await this.resolveLegacyContext();
28 | const OrgSnapshotListCommandImpl = require('../../../../lib/org/snapshot/orgSnapshotListCommand'); // eslint-disable-line global-require
29 | return this.execLegacyCommand(new OrgSnapshotListCommandImpl(), context);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/commands/force/community/template/list.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { SfdxCommand } from '@salesforce/command';
9 | import { Messages } from '@salesforce/core';
10 | import { CommunityTemplatesResource } from '../../../../lib/community/connect/CommunityTemplatesResource';
11 | import { ConnectExecutor } from '../../../../lib/connect/services/ConnectExecutor';
12 | import { CommunityTemplatesListResponse } from '../../../../lib/community/defs/CommunityTemplatesListResponse';
13 |
14 | Messages.importMessagesDirectory(__dirname);
15 | const community = Messages.loadMessages('salesforce-alm', 'community_commands');
16 |
17 | /**
18 | * A command to fetch available community templates a community. This is just an sfdx wrapper around
19 | * the get available community templates connect endpoint
20 | */
21 | export class CommunityListTemplatesCommand extends SfdxCommand {
22 | public static readonly requiresUsername = true;
23 | public static readonly help = community.getMessage('list.help');
24 | public static readonly description =
25 | community.getMessage('list.description') + '\n\n' + CommunityListTemplatesCommand.help;
26 | public static readonly longDescription = community.getMessage('list.longDescription');
27 |
28 | public async run(): Promise {
29 | const listTemplateCommand = new CommunityTemplatesResource(this.ux);
30 | return new ConnectExecutor(listTemplateCommand, this.org).callConnectApi();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/inFolderMetadataWorkspaceDecomposition.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | /* eslint-disable @typescript-eslint/no-unused-vars */
8 |
9 | import { Nullable } from '@salesforce/ts-types';
10 | import { MetadataDocumentAnnotation } from '../metadataDocument';
11 | import { DecompositionWorkspaceStrategy } from './decompositionWorkspaceStrategy';
12 | import { DecomposedSubtypeConfig } from './decompositionConfig';
13 |
14 | export class InFolderMetadataWorkspaceDecomposition implements DecompositionWorkspaceStrategy {
15 | getDecomposedFileName(
16 | annotation: MetadataDocumentAnnotation,
17 | decomposedSubtypeConfig: DecomposedSubtypeConfig
18 | ): string {
19 | return null;
20 | }
21 |
22 | getContainerPath(metadataFilePath: string, ext: string): string {
23 | return metadataFilePath;
24 | }
25 |
26 | findDecomposedPaths(metadataFilePath: string, ext: string): Map {
27 | return new Map();
28 | }
29 |
30 | getDecomposedSubtypeDirFromMetadataFile(
31 | metadataFilePath: string,
32 | ext: string,
33 | decomposedSubtypeConfig: DecomposedSubtypeConfig
34 | ): Nullable {
35 | return null;
36 | }
37 |
38 | getDecomposedSubtypeDirFromAnnotation(
39 | annotation: MetadataDocumentAnnotation,
40 | metadataType: string,
41 | aggregateFullName: string,
42 | decomposedSubtypeConfig: DecomposedSubtypeConfig
43 | ): Nullable {
44 | return null;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/customObjectMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as path from 'path';
9 | import * as fs from 'fs-extra';
10 |
11 | import { DefaultMetadataType } from './defaultMetadataType';
12 | import * as PathUtil from '../sourcePathUtil';
13 |
14 | export class CustomObjectMetadataType extends DefaultMetadataType {
15 | hasIndividuallyAddressableChildWorkspaceElements(): boolean {
16 | return true;
17 | }
18 |
19 | getAggregateMetadataFilePathFromWorkspacePath(filePath): string {
20 | return PathUtil.removeParentDirFromPath(filePath);
21 | }
22 |
23 | entityExistsInWorkspace(metadataFilePath: string): boolean {
24 | const aggregateFullName = this.getAggregateFullNameFromFilePath(metadataFilePath);
25 | return fs.existsSync(path.join(path.dirname(metadataFilePath), aggregateFullName));
26 | }
27 |
28 | /**
29 | * W-4594933: Converting mdapi source that only contains "decomposed" metadata elements will
30 | * result in an empty CustomObject container file created. This container file,
31 | * which meets the below criteria, is invalid
32 | *
33 | * @param container
34 | * @returns {boolean}
35 | */
36 | isContainerValid(container): boolean {
37 | const containerDataNodes = container.data.childNodes;
38 | return !(
39 | containerDataNodes &&
40 | containerDataNodes[0].tagName == 'xml' &&
41 | containerDataNodes[1].tagName == this.getMetadataName() &&
42 | containerDataNodes[1].childNodes.length == 0
43 | );
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/lib/mdapi/mdapiDeployCancelCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { SfdxError, Messages } from '@salesforce/core';
9 |
10 | import { MdapiDeployCancel } from '../mdapi/mdapiDeployCancel';
11 | import { parseWaitParam } from '../source/sourceUtil';
12 |
13 | import Stash = require('../core/stash');
14 |
15 | Messages.importMessagesDirectory(__dirname);
16 |
17 | export class MdapiCancelCommand {
18 | private org: any;
19 |
20 | constructor(private stashKey: string = Stash.Commands.MDAPI_DEPLOY) {}
21 | /**
22 | * Executes the mdapi deploy cancel command
23 | *
24 | * @param context - the cli context
25 | * @returns {Promise}
26 | */
27 | public async execute(context: any) {
28 | return await new MdapiDeployCancel(this.org).cancel(this.org, context);
29 | }
30 |
31 | /**
32 | * Validates the mdapi deploy cancel command parameters
33 | *
34 | * @param context - the cli context
35 | * @returns {Promise}
36 | */
37 | public async validate(context: any): Promise {
38 | const options = context.flags;
39 | this.org = context.org;
40 |
41 | if (!options.jobid) {
42 | const stashedValues = await Stash.list(this.stashKey);
43 | options.jobid = stashedValues.jobid;
44 | }
45 |
46 | if (!options.jobid) {
47 | throw SfdxError.create('salesforce-alm', 'mdapi_cancel', 'MissingRequiredParameter');
48 | }
49 |
50 | // Validate the wait param if set and convert to an integer.
51 | parseWaitParam(options);
52 |
53 | return Promise.resolve(options);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/commands/force/org/shape/list.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import * as fs from 'fs';
13 | import { flags, FlagsConfig } from '@salesforce/command';
14 | import * as BBPromise from 'bluebird';
15 | import Messages = require('../../../../lib/messages');
16 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
17 |
18 | const messages = Messages();
19 |
20 | export class OrgShapeListCommand extends ToolbeltCommand {
21 | public static readonly theDescription = messages.getMessage('description', [], 'org_shape_list');
22 | public static readonly longDescription = messages.getMessage('longDescription', [], 'org_shape_list');
23 | public static readonly help = messages.getMessage('help', [], 'org_shape_list');
24 | public static readonly requiresProject = false;
25 | public static readonly flagsConfig: FlagsConfig = {
26 | verbose: flags.builtin({
27 | description: messages.getMessage('verbose', [], 'org_shape_list'),
28 | longDescription: messages.getMessage('verboseLong', [], 'org_shape_list'),
29 | }),
30 | };
31 |
32 | public async run(): Promise {
33 | const context = await this.resolveLegacyContext();
34 |
35 | BBPromise.promisifyAll(fs);
36 |
37 | const OrgShapeListCommandImpl = require('../../../../lib/org/orgShapeListCommand'); // eslint-disable-line global-require
38 | return this.execLegacyCommand(new OrgShapeListCommandImpl(), context);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/commands/force/package1/version/list.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 |
18 | export class Package1VersionListCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('package1VersionListCommandCliDescription');
20 | public static readonly longDescription = messages.getMessage('package1VersionListCommandLongDescription');
21 | public static readonly help = messages.getMessage('package1VersionListCommandCliHelp');
22 | public static readonly supportsUsername = true;
23 | public static readonly requiresProject = true;
24 | public static readonly flagsConfig: FlagsConfig = {
25 | packageid: flags.id({
26 | char: 'i',
27 | description: messages.getMessage('package1VersionListCommandPackageId'),
28 | longDescription: messages.getMessage('package1VersionListCommandPackageIdLong'),
29 | required: false,
30 | }),
31 | };
32 |
33 | public async run(): Promise {
34 | const context = await this.resolveLegacyContext();
35 | const Package1VersionListCommandImpl = require('../../../../lib/package1/package1VersionListCommand');
36 | return this.execLegacyCommand(new Package1VersionListCommandImpl(context.org), context);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/commands/force/package/list.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../lib/core/constants');
18 |
19 | export class PackageListCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_list');
21 | public static readonly longDescription = messages.getMessage('cliLongDescription', [], 'package_list');
22 | public static readonly help = messages.getMessage('help', [], 'package_list');
23 | public static readonly requiresProject = false;
24 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
25 | public static readonly requiresDevhubUsername = true;
26 | public static readonly flagsConfig: FlagsConfig = {
27 | verbose: flags.builtin({
28 | description: messages.getMessage('verboseDescription', [], 'package_list'),
29 | longDescription: messages.getMessage('verboseLongDescription', [], 'package_list'),
30 | }),
31 | };
32 |
33 | public async run(): Promise {
34 | const context = await this.resolveLegacyContext();
35 | const PackageListCommandImpl = require('../../../lib/package/packageListCommand');
36 | return this.execLegacyCommand(new PackageListCommandImpl(), context);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/commands/force/package/install/report.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 |
18 | export class PackageInstallReportCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_install_report');
20 | public static readonly longDescription = messages.getMessage('cliDescriptionLong', [], 'package_install_report');
21 | public static readonly help = messages.getMessage('help', [], 'package_install_report');
22 | public static readonly requiresProject = false;
23 | public static readonly requiresUsername = true;
24 | public static readonly flagsConfig: FlagsConfig = {
25 | requestid: flags.id({
26 | char: 'i',
27 | description: messages.getMessage('requestId', [], 'package_install_report'),
28 | longDescription: messages.getMessage('requestIdLong', [], 'package_install_report'),
29 | required: true,
30 | }),
31 | };
32 |
33 | public async run(): Promise {
34 | const context = await this.resolveLegacyContext();
35 | const PackageInstallRequestReportCommand = require('../../../../lib/package/PackageInstallRequestReportCommand');
36 | return this.execLegacyCommand(new PackageInstallRequestReportCommand(), context);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/describeMetadataDecompositionConfig.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DecompositionConfig, DecomposedSubtypeConfig } from './decompositionConfig';
9 |
10 | /**
11 | * Subtype configuration for the describeMetadata decomposition.
12 | */
13 | export class DescribeMetadataDecomposedSubtypeConfig implements DecomposedSubtypeConfig {
14 | metadataName: string;
15 | ext: string;
16 | hasStandardMembers: boolean;
17 | isAddressable: boolean;
18 |
19 | defaultDirectory: string;
20 | metadataEntityNameElement: string;
21 | xmlFragmentName: string;
22 | }
23 |
24 | /**
25 | * Decomposition configuration for the describeMetadata decomposition and the folder per subtype
26 | * workspace manifestation.
27 | */
28 | export class DescribeMetadataDecompositionConfig implements DecompositionConfig {
29 | metadataName: string;
30 | isGlobal: boolean;
31 | isEmptyContainer: boolean;
32 | useSparseComposition: boolean;
33 | decompositions: DecomposedSubtypeConfig[];
34 | strategy: string;
35 | workspaceStrategy: string;
36 | commitStrategy: string;
37 | contentStrategy: string;
38 |
39 | constructor(metadataName: string, isGlobal: boolean, isEmptyContainer: boolean, useSparseComposition?: boolean) {
40 | this.strategy = 'describeMetadata';
41 | this.workspaceStrategy = 'folderPerSubtype';
42 | this.commitStrategy = 'fineGrainTracking';
43 | this.contentStrategy = 'N/A';
44 | this.metadataName = metadataName;
45 | this.isGlobal = isGlobal;
46 | this.isEmptyContainer = isEmptyContainer;
47 | this.useSparseComposition = useSparseComposition;
48 | this.decompositions = [];
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/commands/force/package1/version/display.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 |
18 | export class Package1VersionDisplayCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('package1VersionDisplayCommandCliDescription');
20 | public static readonly longDescription = messages.getMessage('package1VersionDisplayCommandLongDescription');
21 | public static readonly help = messages.getMessage('package1VersionDisplayCommandCliHelp');
22 | public static readonly requiresUsername = true;
23 | public static readonly requiresProject = true;
24 | public static readonly flagsConfig: FlagsConfig = {
25 | packageversionid: flags.id({
26 | char: 'i',
27 | description: messages.getMessage('package1VersionDisplayCommandPackageId'),
28 | longDescription: messages.getMessage('package1VersionDisplayCommandPackageIdLong'),
29 | required: true,
30 | }),
31 | };
32 |
33 | public async run(): Promise {
34 | const context = await this.resolveLegacyContext();
35 | const Package1VersionDisplayCommandImpl = require('../../../../lib/package1/package1VersionDisplayCommand');
36 | return this.execLegacyCommand(new Package1VersionDisplayCommandImpl(context.org), context);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/commands/force/package/uninstall/report.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 |
18 | export class PackageUninstallReportCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_uninstall_report');
20 | public static readonly longDescription = messages.getMessage('cliDescriptionLong', [], 'package_uninstall_report');
21 | public static readonly help = messages.getMessage('help', [], 'package_uninstall_report');
22 | public static readonly requiresProject = false;
23 | public static readonly requiresUsername = true;
24 | public static readonly flagsConfig: FlagsConfig = {
25 | requestid: flags.id({
26 | char: 'i',
27 | description: messages.getMessage('requestId', [], 'package_uninstall_report'),
28 | longDescription: messages.getMessage('requestIdLong', [], 'package_uninstall_report'),
29 | required: true,
30 | }),
31 | };
32 |
33 | public async run(): Promise {
34 | const context = await this.resolveLegacyContext();
35 | const PackageUninstallRequestReportCommand = require('../../../../lib/package/PackageUninstallRequestReportCommand');
36 | return this.execLegacyCommand(new PackageUninstallRequestReportCommand(), context);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/nonDecomposedMetadataStrategy.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | /* eslint-disable @typescript-eslint/no-unused-vars */
8 |
9 | import { MetadataDocument } from '../metadataDocument';
10 | import { XmlMetadataDocument } from '../xmlMetadataDocument';
11 | import { DecompositionConfig, DecomposedSubtypeConfig } from './decompositionConfig';
12 | import { DecompositionStrategy } from './decompositionStrategy';
13 |
14 | /**
15 | * Null decomposition strategy.
16 | */
17 | export class NonDecomposedMetadataStrategy implements DecompositionStrategy {
18 | decompositionConfig: DecompositionConfig;
19 |
20 | constructor(decompositionConfig: DecompositionConfig) {
21 | this.decompositionConfig = decompositionConfig;
22 | }
23 |
24 | newContainerDocument(metadataName: string): MetadataDocument {
25 | return new XmlMetadataDocument(metadataName);
26 | }
27 |
28 | newDecompositionDocument(metadataName: string): MetadataDocument {
29 | return new XmlMetadataDocument(metadataName);
30 | }
31 |
32 | newComposedDocument(metadataName: string): MetadataDocument {
33 | return new XmlMetadataDocument(metadataName);
34 | }
35 |
36 | compose(
37 | container: MetadataDocument,
38 | decompositions: Map
39 | ): MetadataDocument {
40 | return container;
41 | }
42 |
43 | decompose(
44 | composed: MetadataDocument,
45 | name: string,
46 | manifest?
47 | ): [MetadataDocument, Map] {
48 | return [composed, new Map()];
49 | }
50 |
51 | isComposable(): boolean {
52 | return false;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/lib/connect/services/ConnectExecutor.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { ConnectResource } from './ConnectResource';
8 | import { Org } from '@salesforce/core/lib/org';
9 | import { RequestInfo } from 'jsforce';
10 | import { SfdxError } from '@salesforce/core';
11 |
12 | /**
13 | * An executor which calls a connect api for the given org
14 | */
15 | export class ConnectExecutor {
16 | private connectService: ConnectResource;
17 | private org: Org;
18 |
19 | constructor(connectService: ConnectResource, org: Org) {
20 | this.connectService = connectService;
21 | this.org = org;
22 | }
23 |
24 | /**
25 | * Call the connect resource as defined by the given ConnectResource for the given org
26 | */
27 | public async callConnectApi(): Promise {
28 | return this.org
29 | .getConnection()
30 | .request(await this.fetchRequestInfo())
31 | .then((result) => this.connectService.handleSuccess(result))
32 | .catch((err) => this.connectService.handleError(err));
33 | }
34 |
35 | public async fetchRequestInfo(): Promise {
36 | const connectUrl: string = encodeURI(await this.connectService.fetchRelativeConnectUrl());
37 | let method = this.connectService.getRequestMethod();
38 | if (method === 'GET') {
39 | return {
40 | url: connectUrl,
41 | method,
42 | body: null,
43 | };
44 | } else if (method === 'POST') {
45 | return {
46 | url: connectUrl,
47 | method,
48 | body: await this.connectService.fetchPostParams(),
49 | };
50 | } else {
51 | throw new SfdxError(`Unsupported method is given: ${method}`, 'UNSUPPORTED_OPERATION');
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/lib/community/connect/CommunityTemplatesResource.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { UX } from '@salesforce/command';
8 | import { Messages } from '@salesforce/core';
9 | import { ConnectResource } from '../../connect/services/ConnectResource';
10 | import { CommunityTemplatesListResponse } from '../defs/CommunityTemplatesListResponse';
11 |
12 | Messages.importMessagesDirectory(__dirname);
13 | const community = Messages.loadMessages('salesforce-alm', 'community_commands');
14 |
15 | /**
16 | * A connect api resource for fetching community templates available to context user
17 | */
18 | export class CommunityTemplatesResource implements ConnectResource {
19 | private ux: UX;
20 |
21 | constructor(ux: UX) {
22 | this.ux = ux;
23 | }
24 |
25 | // eslint-disable-next-line @typescript-eslint/require-await
26 | async fetchRelativeConnectUrl(): Promise {
27 | return '/connect/communities/templates';
28 | }
29 | // eslint-disable-next-line @typescript-eslint/require-await
30 | async fetchPostParams(): Promise {
31 | return JSON.stringify({});
32 | }
33 |
34 | getRequestMethod(): string {
35 | return 'GET';
36 | }
37 |
38 | handleSuccess(result: CommunityTemplatesListResponse): CommunityTemplatesListResponse {
39 | const columns = ['templateName', 'publisher'];
40 | this.ux.styledHeader(community.getMessage('list.response.styledHeader'));
41 | this.ux.table(result.templates, columns);
42 | this.ux.log();
43 | this.ux.log(community.getMessage('list.response.TotalField'), result.total.toString());
44 | return result;
45 | }
46 | handleError(error: Error): CommunityTemplatesListResponse {
47 | throw error;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/commands/force/org/shape/create.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import Messages = require('../../../../lib/messages');
13 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
14 |
15 | const messages = Messages();
16 | const commandTimeOutInMS = 30e3;
17 |
18 | export class OrgShapeCreateCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('create_shape_command_description', null, 'org_shape');
20 | public static readonly longDescription = messages.getMessage(
21 | 'create_shape_command_description_long',
22 | null,
23 | 'org_shape'
24 | );
25 | public static readonly help = messages.getMessage('create_shape_command_help', null, 'org_shape');
26 | public static readonly requiresProject = false;
27 | public static readonly requiresUsername = true;
28 |
29 | public async run(): Promise {
30 | const context = await this.resolveLegacyContext();
31 | const ShapeRepCreateCommandImpl = require('../../../../lib/org/shapeRepCreateCommand');
32 | const createCommand = new ShapeRepCreateCommandImpl();
33 |
34 | let timeoutID;
35 |
36 | const timeout = new Promise((_, reject) => {
37 | timeoutID = setTimeout(() => {
38 | reject(messages.getMessage('shapeCreateFailedMessage'));
39 | }, commandTimeOutInMS);
40 | });
41 |
42 | return Promise.race([this.execLegacyCommand(createCommand, context), timeout]).then((result) => {
43 | clearTimeout(timeoutID);
44 | return result;
45 | });
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/commands/force/community/publish.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command';
9 | import { Messages } from '@salesforce/core';
10 | import { CommunityPublishResource } from '../../../lib/community/connect/CommunityPublishResource';
11 | import { ConnectExecutor } from '../../../lib/connect/services/ConnectExecutor';
12 | import { CommunityPublishResponse } from '../../../lib/community/defs/CommunityPublishResponse';
13 |
14 | Messages.importMessagesDirectory(__dirname);
15 | const community = Messages.loadMessages('salesforce-alm', 'community_commands');
16 |
17 | /**
18 | * A command to publish a community. This is just an sfdx wrapper around
19 | * the community publish connect endpoint
20 | */
21 | export class CommunityPublishCommand extends SfdxCommand {
22 | public static readonly requiresUsername = true;
23 | public static readonly help = community.getMessage('publish.help');
24 | public static readonly longDescription = community.getMessage('publish.longDescription');
25 | public static readonly description =
26 | community.getMessage('publish.description') + '\n\n' + CommunityPublishCommand.help;
27 | public static readonly flagsConfig: FlagsConfig = {
28 | name: flags.string({
29 | char: 'n',
30 | description: community.getMessage('publish.flags.name.description'),
31 | longDescription: community.getMessage('publish.flags.name.longDescription'),
32 | required: true,
33 | }),
34 | };
35 |
36 | public async run(): Promise {
37 | const publishCommand = new CommunityPublishResource(this.flags, this.org, this.ux);
38 | return new ConnectExecutor(publishCommand, this.org).callConnectApi();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/commands/force/source/open.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import * as Messages from '../../../lib/force-cli/force-cli-messages';
14 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
15 |
16 | export class SourceOpenCommand extends ToolbeltCommand {
17 | public static readonly theDescription = Messages.get('SourceOpenDescription');
18 | public static readonly longDescription = Messages.get('SourceOpenLongDescription');
19 | public static readonly help = Messages.get('SourceOpenHelp');
20 | public static readonly requiresProject = true;
21 | public static readonly flagsConfig: FlagsConfig = {
22 | sourcefile: flags.filepath({
23 | char: 'f',
24 | required: true,
25 | hidden: false,
26 | description: Messages.get('SourceOpenFileDescription'),
27 | longDescription: Messages.get('SourceOpenFileLongDescription'),
28 | }),
29 | urlonly: flags.boolean({
30 | char: 'r',
31 | required: false,
32 | hidden: false,
33 | description: Messages.get('SourceOpenPathDescription'),
34 | longDescription: Messages.get('SourceOpenPathLongDescription'),
35 | }),
36 | };
37 |
38 | public static readonly requiresUsername = true;
39 | public async run(): Promise {
40 | const context = await this.resolveLegacyContext();
41 | const { SourceOpenCommandImpl } = require('../../../lib/source/sourceOpenCommand');
42 | return await this.execLegacyCommand(new SourceOpenCommandImpl(), context);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/staticResourceContentStrategy.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { MetadataType } from '../metadataType';
9 |
10 | import { ContentDecompositionStrategy } from './contentDecompositionStrategy';
11 | import { StaticResource } from './staticResource';
12 |
13 | export class StaticResourceContentStrategy implements ContentDecompositionStrategy {
14 | metadataType: MetadataType;
15 | metadataRegistry;
16 | workspaceVersion;
17 |
18 | constructor(metadataType: MetadataType, metadataRegistry, workspaceVersion) {
19 | this.metadataType = metadataType;
20 | this.metadataRegistry = metadataRegistry;
21 | this.workspaceVersion = workspaceVersion;
22 | }
23 |
24 | getContentPaths(metadataFilePath: string): string[] {
25 | const staticResource = new StaticResource(metadataFilePath, this.metadataType, this.workspaceVersion);
26 | return staticResource.getContentPaths();
27 | }
28 |
29 | async saveContent(
30 | metadataFilePath,
31 | retrievedContentFilePaths,
32 | retrievedMetadataFilePath,
33 | createDuplicates,
34 | unsupportedMimeTypes: string[],
35 | forceoverwrite = false
36 | ): Promise<[string[], string[], string[], string[]]> {
37 | const newPaths = [];
38 | const staticResource = new StaticResource(
39 | metadataFilePath,
40 | this.metadataType,
41 | this.workspaceVersion,
42 | retrievedMetadataFilePath,
43 | unsupportedMimeTypes
44 | );
45 | const [updatedPaths, duplicatePaths, deletedPaths] = await staticResource.saveResource(
46 | retrievedContentFilePaths[0],
47 | createDuplicates,
48 | forceoverwrite
49 | );
50 | return [newPaths, updatedPaths, deletedPaths, duplicatePaths];
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/lib/force-cli/force-cli-error.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /* --------------------------------------------------------------------------------------------------------------------
9 | * WARNING: This file has been deprecated and should now be considered locked against further changes. Its contents
10 | * have been partially or wholly superseded by functionality included in the @salesforce/core npm package, and exists
11 | * now to service prior uses in this repository only until they can be ported to use the new @salesforce/core library.
12 | *
13 | * If you need or want help deciding where to add new functionality or how to migrate to the new library, please
14 | * contact the CLI team at alm-cli@salesforce.com.
15 | * ----------------------------------------------------------------------------------------------------------------- */
16 |
17 | import cli = require('heroku-cli-util');
18 | import * as ResponseParser from './force-cli-responseParser';
19 | import { Command } from './force-cli-command';
20 |
21 | // TODO Deprecate this file
22 | export const exitWithMessage = function (msg: string): never {
23 | msg = checkIfFaultStringFromXml(msg);
24 | throw new Error(msg);
25 | };
26 |
27 | export const exitDisplayHelp = function (command: Command): never {
28 | cli.log('\n' + command.help);
29 | // @ts-ignore exit throws instead of returning any
30 | return cli.exit(1);
31 | };
32 |
33 | /**
34 | * parses the xml faultstring if needed
35 | * exposed for unit testing
36 | *
37 | * @param msg
38 | * @returns {string}
39 | */
40 | export const checkIfFaultStringFromXml = function (msg: string): string {
41 | if (ResponseParser.hasFaultString(msg)) {
42 | return ResponseParser.getFaultString(msg);
43 | }
44 | return msg;
45 | };
46 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/decompositionConfig.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /**
9 | * The minimum configuration for a metadata entity subtype (eg. CustomField).
10 | */
11 | export interface DecomposedSubtypeConfig {
12 | metadataName: string; // Name of the metadata subtype (eg. CustomField)
13 | ext: string; // The normal file extension (eg. field)
14 | defaultDirectory: string; // The default directory (eg. fields)
15 | hasStandardMembers: boolean; // Does this subtype have standard members (eg. CustomField)?
16 | isAddressable: boolean; // Can this subtype be addressed individually by mdapi?
17 | }
18 |
19 | /**
20 | * The minimum configuration for a decomposition. Each decomposed type has a single configuration associated
21 | * with it in the metadata repository. This configuration (and any extension) drives the runtime behavior of
22 | * decomposition.
23 | */
24 | export interface DecompositionConfig {
25 | metadataName: string; // Name of the aggregate metadata entity (eg. CustomObject)
26 | isGlobal: boolean; // Is this a global (singleton) metadata entity (eg. CustomLabels)?
27 | isEmptyContainer: boolean; // Is there anything left to represent once the subtypes are extracted?
28 | decompositions: DecomposedSubtypeConfig[]; // List of subtype decomposition configurations. DO NOT leave undefined!
29 | strategy: string; // Name of the strategy for decomposition of the raw metadata.
30 | workspaceStrategy: string; // Name of the strategy for manifesting the decomposition in the workspace.
31 | commitStrategy: string; // Name of the strategy for handling additions, deletions and updates.
32 | contentStrategy: string;
33 | useSparseComposition: boolean; // Like CustomObject, where (eg) fields can be combined into a CustomObject w/o any root data
34 | }
35 |
--------------------------------------------------------------------------------
/src/lib/org/activeScratchOrgDeleteCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import srcDevUtil = require('../core/srcDevUtil');
9 | import Messages = require('../messages');
10 | import ActiveScratchOrgDeleteApi = require('./activeScratchOrgDeleteApi');
11 |
12 | const messages = Messages();
13 |
14 | class OrgDeleteCommand {
15 | // TODO: proper property typing
16 | // eslint-disable-next-line no-undef
17 | [property: string]: any;
18 |
19 | async execute(context) {
20 | const activeScratchOrgDeleteApi = new ActiveScratchOrgDeleteApi();
21 | const orgData = await this.org.getConfig();
22 |
23 | try {
24 | await activeScratchOrgDeleteApi.doDelete(this.org, context.targetdevhubusername);
25 | } catch (err) {
26 | if (err.name === 'attemptingToDeleteExpiredOrDeleted') {
27 | this.alreadyDeleted = true;
28 | } else {
29 | // Includes the "insufficientAccessToDelete" error.
30 | throw err;
31 | }
32 | }
33 | await this.org.deleteConfig();
34 | return {
35 | orgId: orgData.orgId,
36 | username: orgData.userName,
37 | };
38 | }
39 |
40 | // eslint-disable-next-line @typescript-eslint/require-await
41 | async validate(context) {
42 | this.org = context.org;
43 | const fixedContext = srcDevUtil.fixCliContext(context);
44 | this.username = fixedContext.targetusername;
45 | if (!this.username) {
46 | this.username = context.org.name;
47 | }
48 | return fixedContext;
49 | }
50 |
51 | getHumanSuccessMessage() {
52 | if (this.alreadyDeleted) {
53 | return messages.getMessage('deleteOrgConfigOnlyCommandSuccess', this.username);
54 | } else {
55 | return messages.getMessage('deleteOrgCommandSuccess', this.username);
56 | }
57 | }
58 | }
59 |
60 | export = OrgDeleteCommand;
61 |
--------------------------------------------------------------------------------
/src/lib/org/snapshot/orgSnapshotGetCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { OrgSnapshotApi, OrgSnapshotApiImpl, ColumnData } from './orgSnapshotApi';
9 | import Messages = require('../../messages');
10 | const messages = Messages();
11 | import logger = require('../../core/logApi');
12 |
13 | /**
14 | * Get a Org Snapshot record.
15 | */
16 | class OrgSnapshotGetCommand {
17 | private logger;
18 | private orgSnapshotApi: OrgSnapshotApi;
19 | private orgSnapshotIdOrName: string;
20 |
21 | constructor() {
22 | this.logger = logger.child('org:snapshot:get');
23 | }
24 |
25 | execute(context) {
26 | // double-check
27 | if (!context.flags.snapshot) {
28 | throw new Error(messages.getMessage('snapshotInvalid', [], 'orgSnapshot'));
29 | }
30 |
31 | this.orgSnapshotIdOrName = context.flags.snapshot;
32 | return OrgSnapshotApiImpl.create(context.org).then((orgSnapshotApi) => {
33 | this.orgSnapshotApi = orgSnapshotApi;
34 | return this.orgSnapshotApi.get(this.orgSnapshotIdOrName);
35 | });
36 | }
37 |
38 | /**
39 | * returns a human readable message for a cli output
40 | *
41 | * @param result - the data representing the Org Snapshot
42 | * @returns {string}
43 | */
44 | getHumanSuccessMessage(result) {
45 | const data: ColumnData[] = this.orgSnapshotApi.mapDataToLabel(result);
46 |
47 | if (result.Status === 'Error') {
48 | data.push({ name: 'Error', value: result.Error || 'Unknown' });
49 | }
50 |
51 | this.logger.styledHeader(this.logger.color.blue('Org Snapshot'));
52 | this.logger.table(data, {
53 | columns: [
54 | { key: 'name', label: 'Name' },
55 | { key: 'value', label: 'Value' },
56 | ],
57 | });
58 |
59 | return '';
60 | }
61 | }
62 |
63 | export = OrgSnapshotGetCommand;
64 |
--------------------------------------------------------------------------------
/src/commands/force/package1/version/create/get.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 |
18 | export class Package1VersionCreateGetCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package1_version_create_get');
20 | public static readonly longDescription = messages.getMessage('cliDescriptionLong', [], 'package1_version_create_get');
21 | public static readonly help = messages.getMessage('help', [], 'package1_version_create_get');
22 | public static readonly requiresProject = false;
23 | public static readonly requiresUsername = true;
24 | public static readonly flagsConfig: FlagsConfig = {
25 | requestid: flags.id({
26 | char: 'i',
27 | description: messages.getMessage('requestId', [], 'package1_version_create_get'),
28 | longDescription: messages.getMessage('requestIdLong', [], 'package1_version_create_get'),
29 | required: true,
30 | }),
31 | };
32 |
33 | /**
34 | * context hook
35 | *
36 | * @param context - the cli context
37 | * @returns {Promise}
38 | */
39 | public async run(): Promise {
40 | const context = await this.resolveLegacyContext();
41 | const Package1VersionCreateGetCommandImpl = require('../../../../../lib/package1/package1VersionCreateGetCommand');
42 | return this.execLegacyCommand(new Package1VersionCreateGetCommandImpl(), context);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/commands/force/org/snapshot/get.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../../lib/core/constants');
18 |
19 | export class OrgSnapshotGetCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('getSnapshotCmdDescription', [], 'orgSnapshot');
21 | public static readonly longDescription = messages.getMessage('getSnapshotCmdDescriptionLong', [], 'orgSnapshot');
22 | public static readonly help = messages.getMessage('getSnapshotCmdHelp', [], 'orgSnapshot');
23 | public static readonly showProgress = true;
24 | public static readonly requiresProject = false;
25 | public static readonly requiresDevhubUsername = true;
26 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
27 | public static readonly flagsConfig: FlagsConfig = {
28 | snapshot: flags.string({
29 | char: 's',
30 | description: messages.getMessage('getSnapshotCmdSnapshotDescription', [], 'orgSnapshot'),
31 | longDescription: messages.getMessage('getSnapshotCmdSnapshotDescriptionLong', [], 'orgSnapshot'),
32 | required: true,
33 | }),
34 | };
35 | public async run(): Promise {
36 | const context = await this.resolveLegacyContext();
37 | const OrgSnapshotGetCommandImpl = require('../../../../lib/org/snapshot/orgSnapshotGetCommand'); // eslint-disable-line global-require
38 | return this.execLegacyCommand(new OrgSnapshotGetCommandImpl(), context);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/lib/source/parseManifestEntriesArray.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | import { SfdxError, SfdxErrorConfig } from '@salesforce/core';
8 | import { MdRetrieveApi } from '../mdapi/mdapiRetrieveApi';
9 | import * as PathUtil from '../source/sourcePathUtil';
10 | import { ManifestEntry } from './types';
11 |
12 | /**
13 | * Parse the manifest file and create a list ManifestEntry objects.
14 | *
15 | * @param manifestPath {string} The filepath for the manifest
16 | * @returns {ManifestEntry[]} An array for ManifestEntry objects from the manifest.
17 | */
18 | export const parseToManifestEntriesArray = async function (manifestPath: string): Promise {
19 | const entries: ManifestEntry[] = [];
20 | const options = {
21 | unpackaged: manifestPath,
22 | };
23 |
24 | return MdRetrieveApi._getPackageJson(undefined, options).then((manifestJson) => {
25 | toArray(manifestJson.types).forEach((type) => {
26 | if (!type.name) {
27 | const errConfig = new SfdxErrorConfig('salesforce-alm', 'source', 'IllFormattedManifest');
28 | errConfig.setErrorTokens(['; is missing']);
29 | throw SfdxError.create(errConfig);
30 | }
31 | toArray(type.members).forEach((member) => {
32 | const _member = PathUtil.replaceForwardSlashes(member);
33 | entries.push({
34 | type: type.name,
35 | name: _member,
36 | });
37 | });
38 | });
39 | return entries;
40 | });
41 | };
42 |
43 | /**
44 | * Convert the argument into an array datatype
45 | *
46 | * @param arrayOrObjectOrUndefined
47 | * @returns Array
48 | */
49 | export const toArray = function (arrayOrObjectOrUndefined: any) {
50 | if (!arrayOrObjectOrUndefined) {
51 | return [];
52 | } else if (Array.isArray(arrayOrObjectOrUndefined)) {
53 | return arrayOrObjectOrUndefined;
54 | } else {
55 | return [arrayOrObjectOrUndefined];
56 | }
57 | };
58 |
--------------------------------------------------------------------------------
/src/commands/force/org/snapshot/delete.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../../lib/core/constants');
18 |
19 | export class OrgSnapshotDeleteCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('deleteSnapshotCmdDescription', [], 'orgSnapshot');
21 | public static readonly longDescription = messages.getMessage('deleteSnapshotCmdDescriptionLong', [], 'orgSnapshot');
22 | public static readonly help = messages.getMessage('deleteSnapshotCmdHelp', [], 'orgSnapshot');
23 | public static readonly showProgress = true;
24 | public static readonly requiresProject = false;
25 | public static readonly requiresDevhubUsername = true;
26 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
27 | public static readonly flagsConfig: FlagsConfig = {
28 | snapshot: flags.string({
29 | char: 's',
30 | description: messages.getMessage('deleteSnapshotCmdSnapshotDescription', [], 'orgSnapshot'),
31 | longDescription: messages.getMessage('deleteSnapshotCmdSnapshotDescriptionLong', [], 'orgSnapshot'),
32 | required: true,
33 | }),
34 | };
35 |
36 | public async run(): Promise {
37 | const context = await this.resolveLegacyContext();
38 | const OrgSnapshotDeleteCommandImpl = require('../../../../lib/org/snapshot/orgSnapshotDeleteCommand'); // eslint-disable-line global-require
39 | return this.execLegacyCommand(new OrgSnapshotDeleteCommandImpl(), context);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/lib/org/orgHighlighter.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as _ from 'lodash';
9 | import chalk, { Chalk } from 'chalk';
10 |
11 | /**
12 | * Class for decorating org status and connected status in the org:list and display commands.
13 | */
14 | class OrgDecorator {
15 | private chalk: Chalk;
16 |
17 | constructor(private colorEnabled: boolean = true, chalkOverride?) {
18 | this.chalk = chalkOverride || chalk;
19 | }
20 |
21 | /**
22 | * helper to decorate the org status
23 | *
24 | * @param {object} val - org metadata
25 | */
26 | decorateStatus(val: object) {
27 | if (this.colorEnabled) {
28 | this.decorateAttribute(val, 'status', 'Active');
29 | }
30 | }
31 |
32 | /**
33 | * helper to decorate the org connectedStatus
34 | *
35 | * @param {object} val - org metadata
36 | */
37 | decorateConnectedStatus(val) {
38 | if (val.connectedStatus === 'Unknown') {
39 | return val;
40 | }
41 | if (this.colorEnabled) {
42 | return this.decorateAttribute(val, 'connectedStatus', 'Connected');
43 | }
44 | }
45 |
46 | /**
47 | * Helper to decorate attributes
48 | *
49 | * @param {object} val - object containing the value to decorate
50 | * @param {string} attribute - the name of the attribute to decorate
51 | * @param {string} greenStatus - the name of state that should report green.
52 | * @private
53 | */
54 | private decorateAttribute(val: object, attribute: string, greenStatus: string) {
55 | if (val && !_.isNil(_.get(val, attribute))) {
56 | switch (_.get(val, attribute)) {
57 | case greenStatus:
58 | _.set(val, attribute, this.chalk.green(_.get(val, attribute)));
59 | break;
60 | default:
61 | _.set(val, attribute, this.chalk.red(_.get(val, attribute)));
62 | break;
63 | }
64 | }
65 | return val;
66 | }
67 | }
68 |
69 | export = OrgDecorator;
70 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/customObjectSubtypeMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as path from 'path';
9 |
10 | import { DefaultMetadataType } from './defaultMetadataType';
11 | import * as PathUtil from '../sourcePathUtil';
12 | import MetadataRegistry = require('../metadataRegistry');
13 |
14 | export class CustomObjectSubtypeMetadataType extends DefaultMetadataType {
15 | getAggregateMetadataName(): string {
16 | return this.typeDefObj.parent.metadataName;
17 | }
18 |
19 | getFullNameFromFilePath(filePath: string): string {
20 | const parentName = PathUtil.getGrandparentDirectoryName(filePath);
21 | const fileName = PathUtil.getFileName(filePath);
22 | return `${parentName}.${fileName}`;
23 | }
24 |
25 | getAggregateFullNameFromFilePath(filePath: string): string {
26 | return PathUtil.getGrandparentDirectoryName(filePath);
27 | }
28 |
29 | getAggregateMetadataFilePathFromWorkspacePath(filePath): string {
30 | const aggregateFullName = this.getAggregateFullNameFromFilePath(filePath);
31 | const pathToDefaultDir = PathUtil.getPathToDir(filePath, this.typeDefObj.parent.defaultDirectory);
32 | const fileName = `${aggregateFullName}.${this.typeDefObj.parent.ext}${MetadataRegistry.getMetadataFileExt()}`;
33 | return path.join(pathToDefaultDir, fileName);
34 | }
35 |
36 | getAggregateFullNameFromSourceMemberName(sourceMemberName: string): string {
37 | return sourceMemberName.split('.')[0];
38 | }
39 |
40 | getAggregateFullNameFromWorkspaceFullName(workspaceFullName: string): string {
41 | return workspaceFullName.split('.')[0];
42 | }
43 |
44 | getAggregateFullNameFromComponentFailure(componentFailure): string {
45 | return this.getAggregateFullNameFromWorkspaceFullName(componentFailure.fullName);
46 | }
47 |
48 | getWorkspaceFullNameFromComponentFailure(componentFailure): string {
49 | return componentFailure.fullName;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/commands/force/package/version/create/report.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../../../lib/core/constants');
18 |
19 | export class PackageVersionCreateReportCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_version_create_report');
21 | public static readonly longDescription = messages.getMessage(
22 | 'cliLongDescription',
23 | [],
24 | 'package_version_create_report'
25 | );
26 | public static readonly help = messages.getMessage('help', [], 'package_version_create_report');
27 | public static readonly requiresProject = false;
28 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
29 | public static readonly requiresDevhubUsername = true;
30 | public static readonly flagsConfig: FlagsConfig = {
31 | packagecreaterequestid: flags.id({
32 | char: 'i',
33 | description: messages.getMessage('requestId', [], 'package_version_create_report'),
34 | longDescription: messages.getMessage('requestIdLong', [], 'package_version_create_report'),
35 | required: true,
36 | }),
37 | };
38 |
39 | public async run(): Promise {
40 | const context = await this.resolveLegacyContext();
41 | const PackageVersionCreateRequestReportCommand = require('../../../../../lib/package/packageVersionCreateRequestReportCommand');
42 | return this.execLegacyCommand(new PackageVersionCreateRequestReportCommand(), context);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/core/varargsCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as _ from 'lodash';
9 | import Command from './command';
10 | import almError = require('./almError');
11 |
12 | abstract class VarargsCommand extends Command {
13 | keyValuePairs;
14 |
15 | constructor(name: string, readonly validators?: Function[]) {
16 | super(name);
17 | }
18 |
19 | async validate(context): Promise {
20 | // If the ToolbeltCommand sets it, use it.
21 | if (context.varargs) {
22 | // All validation is handled in SfdxCommand
23 | this.keyValuePairs = context.varargs;
24 | return super.validate(context);
25 | }
26 |
27 | // Keep this around for unit test. Test can be removed when
28 | // classes are refactored or removed.
29 |
30 | // If this command requires variables, throw if none are provided.
31 | if (_.get(context, 'command.variableArgsRequired') && !_.get(context, 'args.length')) {
32 | throw almError({ keyName: 'ArgsRequired', bundle: 'varargs_command' }, []);
33 | }
34 |
35 | // validate the format of the varargs
36 | if (_.get(context, 'args.length')) {
37 | this.keyValuePairs = {};
38 | context.args.forEach((arg) => {
39 | const split = arg.split('=');
40 |
41 | if (split.length !== 2) {
42 | throw almError({ keyName: 'InvalidArgsFormat', bundle: 'varargs_command' }, [arg]);
43 | }
44 | const [name, value] = split;
45 |
46 | if (this.keyValuePairs[name]) {
47 | throw almError({ keyName: 'DuplicateArgs', bundle: 'varargs_command' }, [name]);
48 | }
49 |
50 | if (_.get(this, 'validators.length')) {
51 | this.validators.forEach((validator) => validator(name, value));
52 | }
53 |
54 | this.keyValuePairs[name] = value || undefined;
55 | });
56 | }
57 |
58 | return super.validate(context);
59 | }
60 | }
61 |
62 | export default VarargsCommand;
63 |
--------------------------------------------------------------------------------
/src/lib/package/packageUpdateCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // Local
9 | import logger = require('../core/logApi');
10 | import Messages = require('../messages');
11 | const messages = Messages();
12 | import pkgUtils = require('./packageUtils');
13 |
14 | class PackageUpdateCommand {
15 | // TODO: proper property typing
16 | // eslint-disable-next-line no-undef
17 | [property: string]: any;
18 |
19 | constructor() {
20 | this.logger = logger.child('package:update');
21 | }
22 |
23 | execute(context) {
24 | return this._execute(context).catch((err) => {
25 | // TODO:
26 | // until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
27 | err = pkgUtils.massageErrorMessage(err);
28 | throw pkgUtils.applyErrorAction(err);
29 | });
30 | }
31 |
32 | _execute(context) {
33 | this.org = context.org;
34 | this.force = context.org.force;
35 |
36 | const packageId = pkgUtils.getPackageIdFromAlias(context.flags.package, this.force);
37 | pkgUtils.validateId(pkgUtils.BY_LABEL.PACKAGE_ID, packageId);
38 |
39 | const request: any = {};
40 | request.Id = packageId;
41 | if (context.flags.name) {
42 | request.Name = context.flags.name;
43 | }
44 | if (context.flags.description) {
45 | request.Description = context.flags.description;
46 | }
47 | if (context.flags.errornotificationusername) {
48 | request.PackageErrorUsername = context.flags.errornotificationusername;
49 | }
50 |
51 | return this.force.toolingUpdate(this.org, 'Package2', request).then((updateResult) => {
52 | if (!updateResult.success) {
53 | throw new Error(updateResult.errors);
54 | }
55 | return updateResult;
56 | });
57 | }
58 |
59 | getHumanSuccessMessage(result) {
60 | return messages.getMessage('humanSuccess', [result.id], 'package_update');
61 | }
62 | }
63 |
64 | export = PackageUpdateCommand;
65 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/sharingRulesMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { NondecomposedTypesWithChildrenMetadataType } from './nondecomposedTypesWithChildrenMetadataType';
9 |
10 | export class SharingRulesMetadataType extends NondecomposedTypesWithChildrenMetadataType {
11 | /**
12 | * Sharing rules are tracked at the fine-grained level on the server, but they are nondecomposed in the workspace
13 | * If a child of a sharing rule type has been changed on the server, this corresponds to the aggregate file in the workspace
14 | *
15 | * @param {string} sourceMemberFullName
16 | * @param {string} workspaceFullName
17 | * @returns {boolean}
18 | */
19 | sourceMemberFullNameCorrespondsWithWorkspaceFullName(
20 | sourceMemberFullName: string,
21 | workspaceFullName: string
22 | ): boolean {
23 | return sourceMemberFullName.split('.')[0] === workspaceFullName;
24 | }
25 |
26 | // eslint-disable-next-line @typescript-eslint/no-unused-vars
27 | getDisplayNameForRemoteChange(sourceMemberType: string): string {
28 | return this.typeDefObj.metadataName;
29 | }
30 |
31 | parseSourceMemberForMetadataRetrieve(
32 | sourceMemberName: string,
33 | sourceMemberType: string,
34 | isNameObsolete: boolean
35 | ): any {
36 | if (
37 | sourceMemberType === 'SharingOwnerRule' ||
38 | sourceMemberType === 'SharingCriteriaRule' ||
39 | sourceMemberType === 'SharingGuestRule' ||
40 | sourceMemberType === 'SharingTerritoryRule'
41 | ) {
42 | const fullName = this.getAggregateFullNameFromSourceMemberName(sourceMemberName);
43 | // these types are not decomposed, so deletions of child types are part of changes to the larger parent container
44 | return { fullName: `${fullName}.*`, type: sourceMemberType };
45 | }
46 | return {
47 | fullName: sourceMemberName,
48 | type: sourceMemberType,
49 | isNameObsolete,
50 | };
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/commands/force/package/uninstall.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../lib/core/constants');
18 |
19 | export class PackageUninstallCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_uninstall');
21 | public static readonly longDescription = messages.getMessage('cliDescriptionLong', [], 'package_uninstall');
22 | public static readonly help = messages.getMessage('help', [], 'package_uninstall');
23 | public static readonly requiresProject = false;
24 | public static readonly orgType = consts.DEFAULT_USERNAME;
25 | public static readonly requiresUsername = true;
26 | public static readonly flagsConfig: FlagsConfig = {
27 | wait: flags.minutes({
28 | char: 'w',
29 | description: messages.getMessage('wait', [], 'package_uninstall'),
30 | longDescription: messages.getMessage('waitLong', [], 'package_uninstall'),
31 | required: false,
32 | }),
33 | package: flags.string({
34 | char: 'p',
35 | description: messages.getMessage('package', [], 'package_uninstall'),
36 | longDescription: messages.getMessage('packageLong', [], 'package_uninstall'),
37 | required: false,
38 | }),
39 | };
40 |
41 | public async run(): Promise {
42 | const context = await this.resolveLegacyContext();
43 | const PackageUninstallCommandImpl = require('../../../lib/package/packageUninstallCommand');
44 | return this.execLegacyCommand(new PackageUninstallCommandImpl(), context);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/lib/force-cli/force-cli-config.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /* --------------------------------------------------------------------------------------------------------------------
9 | * WARNING: This file has been deprecated and should now be considered locked against further changes. Its contents
10 | * have been partially or wholly superseded by functionality included in the @salesforce/core npm package, and exists
11 | * now to service prior uses in this repository only until they can be ported to use the new @salesforce/core library.
12 | *
13 | * If you need or want help deciding where to add new functionality or how to migrate to the new library, please
14 | * contact the CLI team at alm-cli@salesforce.com.
15 | * ----------------------------------------------------------------------------------------------------------------- */
16 |
17 | import { Connection } from 'jsforce';
18 |
19 | export const importScratchOrgCred = async function (context: any): Promise {
20 | // Here be 🐉
21 | /* _getConnection only sets up the listener for a token refresh but does
22 | * not actually check if the token is old. Need to do a subsequent call
23 | * with the connection object for it to check and do a refresh.
24 | */
25 | const conn = await context.org.force._getConnection(context.org, context.org.config);
26 | await conn.requestGet(conn._baseUrl());
27 | return conn;
28 | };
29 |
30 | export const getActiveConnection = async function (context?: any): Promise {
31 | // if (TestUtil.isIntegrationTesting()) {
32 | // let loginUrl = TestUtil.getTestInstance();
33 | // let username = TestUtil.getTestUsername();
34 | // let password = TestUtil.getTestPassword();
35 | // let connection = new Connection();
36 | // connection.loginUrl = loginUrl;
37 | // await connection.loginBySoap(username, password);
38 | // return connection;
39 | // } else {
40 | return await importScratchOrgCred(context);
41 | // }
42 | };
43 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/customObjectTranslationSubtypeMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as path from 'path';
9 |
10 | import { DefaultMetadataType } from './defaultMetadataType';
11 | import * as PathUtil from '../sourcePathUtil';
12 | import MetadataRegistry = require('../metadataRegistry');
13 |
14 | export class CustomObjectTranslationSubtypeMetadataType extends DefaultMetadataType {
15 | getAggregateMetadataName(): string {
16 | return this.typeDefObj.parent.metadataName;
17 | }
18 |
19 | getFullNameFromFilePath(filePath: string): string {
20 | const parentName = PathUtil.getParentDirectoryName(filePath);
21 | const fileName = PathUtil.getFileName(filePath);
22 | return `${parentName}.${fileName}`;
23 | }
24 |
25 | getAggregateFullNameFromFilePath(filePath: string): string {
26 | return PathUtil.getParentDirectoryName(filePath);
27 | }
28 |
29 | getAggregateMetadataFilePathFromWorkspacePath(filePath: string): string {
30 | const aggregateFullName = this.getAggregateFullNameFromFilePath(filePath);
31 | const pathToDefaultDir = PathUtil.getPathToDir(filePath, this.typeDefObj.parent.defaultDirectory);
32 | const fileName = `${aggregateFullName}.${this.typeDefObj.parent.ext}${MetadataRegistry.getMetadataFileExt()}`;
33 | return path.join(pathToDefaultDir, fileName);
34 | }
35 |
36 | getAggregateFullNameFromWorkspaceFullName(workspaceFullName: string): string {
37 | return workspaceFullName.split('.')[0];
38 | }
39 |
40 | sourceMemberFullNameCorrespondsWithWorkspaceFullName(
41 | sourceMemberFullName: string,
42 | workspaceFullName: string
43 | ): boolean {
44 | const aggregateFullName = this.getAggregateFullNameFromWorkspaceFullName(workspaceFullName);
45 | return sourceMemberFullName === aggregateFullName;
46 | }
47 |
48 | getAggregateFullNameFromComponentFailure(componentFailure): string {
49 | return this.getAggregateFullNameFromWorkspaceFullName(componentFailure.fullName);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/lib/package1/package1VersionDisplayApi.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // Node
9 | import * as util from 'util';
10 |
11 | // Local
12 | import logger = require('../core/logApi');
13 | import messages = require('../messages');
14 |
15 | const Package1VersionDisplayApi = function (org) {
16 | this.releaseOrg = org;
17 | this.force = this.releaseOrg.force;
18 | this.messages = messages();
19 | this.logger = logger.child('Package1VersionListApi');
20 | };
21 |
22 | /**
23 | * Displays information on specified package version available in dev org.
24 | *
25 | * @param metadataPackageVersionId: Package version ID to display information for (starts with 04t)
26 | * @returns Array of package version results (should be length 1)
27 | */
28 | Package1VersionDisplayApi.prototype.display = function (metadataPackageVersionId) {
29 | const selectClause =
30 | 'SELECT Id,MetadataPackageId,Name,ReleaseState,MajorVersion,MinorVersion,PatchVersion,BuildNumber FROM MetadataPackageVersion';
31 |
32 | const whereClause = ` WHERE id = '${metadataPackageVersionId}'`;
33 |
34 | const query = `${selectClause}${whereClause}`;
35 |
36 | return this.force.toolingQuery(this.releaseOrg, query).then((queryResult) => {
37 | const results = [];
38 | const records = queryResult.records;
39 | if (!util.isNullOrUndefined(records)) {
40 | for (let i = 0; i < records.length; i++) {
41 | const record = queryResult.records[i];
42 | // TODO: In 208, will add package description, amongst other things.
43 | results.push({
44 | MetadataPackageVersionId: record.Id,
45 | MetadataPackageId: record.MetadataPackageId,
46 | Name: record.Name,
47 | ReleaseState: record.ReleaseState,
48 | Version: `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}`,
49 | BuildNumber: record.BuildNumber,
50 | });
51 | }
52 | }
53 | return results;
54 | });
55 | };
56 |
57 | export = Package1VersionDisplayApi;
58 |
--------------------------------------------------------------------------------
/src/lib/source/metadataTypeImpl/nondecomposedTypesWithChildrenMetadataType.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { DefaultMetadataType } from './defaultMetadataType';
9 |
10 | /**
11 | * Class to represent types that have childXmlNames, but are not decomposed
12 | * Since the child types are not decomposed into individual files in the workspace,
13 | * we do not have MetadataType representations for the child types themselves,
14 | * and any metadataType specific logic for those child types is handled in this class
15 | */
16 | export class NondecomposedTypesWithChildrenMetadataType extends DefaultMetadataType {
17 | requiresIndividuallyAddressableMembersInPackage(): boolean {
18 | return true;
19 | }
20 |
21 | getAggregateFullNameFromSourceMemberName(sourceMemberName): string {
22 | return sourceMemberName.split('.').length == 1 ? this.getMetadataName() : sourceMemberName.split('.')[0]; // if only passed the name, return the type
23 | }
24 |
25 | /**
26 | * @param {string} sourceMemberType - could be the name of the Nondecomposed type itself (i.e. EscalationRules) or
27 | * the name of a child type (i.e. Escalation Rule (singular))
28 | * @returns {string}
29 | */
30 | getDisplayNameForRemoteChange(sourceMemberType: string): string {
31 | if (sourceMemberType !== this.typeDefObj.metadataName) {
32 | return sourceMemberType;
33 | }
34 | return this.typeDefObj.metadataName;
35 | }
36 |
37 | parseSourceMemberForMetadataRetrieve(
38 | sourceMemberName: string,
39 | // eslint-disable-next-line @typescript-eslint/no-unused-vars
40 | sourceMemberType: string,
41 | // eslint-disable-next-line @typescript-eslint/no-unused-vars
42 | isNameObsolete: boolean
43 | ): any {
44 | const fullName = this.getAggregateFullNameFromSourceMemberName(sourceMemberName);
45 | // these types are not decomposed, so deletions of child types are part of changes to the larger parent container
46 | return { fullName, type: this.getMetadataName() };
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/commands/force/package/version/report.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../../lib/core/constants');
18 |
19 | export class PackageVersionReportCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_version_report');
21 | public static readonly longDescription = messages.getMessage('cliLongDescription', [], 'package_version_report');
22 | public static readonly help = messages.getMessage('help', [], 'package_version_report');
23 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
24 | public static readonly requiresDevhubUsername = true;
25 | public static readonly requiresProject = true;
26 | public static readonly flagsConfig: FlagsConfig = {
27 | package: flags.string({
28 | char: 'p',
29 | description: messages.getMessage('package', [], 'package_version_report'),
30 | longDescription: messages.getMessage('packageLong', [], 'package_version_report'),
31 | required: true,
32 | }),
33 | verbose: flags.builtin({
34 | description: messages.getMessage('verboseDescription', [], 'package_version_report'),
35 | longDescription: messages.getMessage('verboseLongDescription', [], 'package_version_report'),
36 | }),
37 | };
38 |
39 | public async run(): Promise {
40 | const context = await this.resolveLegacyContext();
41 | const PackageVersionReportCommandImpl = require('../../../../lib/package/packageVersionReportCommand');
42 | return this.execLegacyCommand(new PackageVersionReportCommandImpl(), context);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/lib/source/srcStatusCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import messages = require('../messages');
9 |
10 | import logger = require('../core/logApi');
11 | import * as syncCommandHelper from './syncCommandHelper';
12 | import { SrcStatusApi } from './srcStatusApi';
13 | const { Messages } = require('@salesforce/core');
14 |
15 | Messages.importMessagesDirectory(__dirname);
16 |
17 | function SrcStatusCommand(context) {
18 | this.scratchOrg = context.org;
19 | this.force = this.scratchOrg.force;
20 | this.projectPath = this.force.config.getProjectPath();
21 | this.messages = messages(this.force.config.getLocale());
22 | this.logger = logger.child('source:status');
23 | }
24 |
25 | SrcStatusCommand.prototype.reject = function reject(...args) {
26 | const msg = this.messages.getMessage(...args);
27 | return Promise.reject(new Error(msg));
28 | };
29 |
30 | SrcStatusCommand.prototype.execute = function execute(options) {
31 | const rows = [];
32 | let api;
33 | return SrcStatusApi.create({ org: this.scratchOrg })
34 | .then((srcStatusApi: SrcStatusApi) => {
35 | api = srcStatusApi;
36 | })
37 | .then(() => api.doStatus(options))
38 | .then(() => {
39 | api
40 | .getLocalChanges()
41 | .forEach((workspaceElement) =>
42 | syncCommandHelper.createStatusLocalRows(rows, workspaceElement, this.projectPath)
43 | );
44 | api
45 | .getRemoteChanges()
46 | .forEach((workspaceElement) =>
47 | syncCommandHelper.createStatusRemoteRows(rows, workspaceElement, this.projectPath)
48 | );
49 | this.logger.styledHeader(this.logger.color.blue(this.messages.getMessage('statusCommandHumanSuccess')));
50 | return rows;
51 | });
52 | };
53 |
54 | /**
55 | * this indicated to index.js this command should produce tabular output.
56 | *
57 | * @returns {*[]}
58 | */
59 | SrcStatusCommand.prototype.getColumnData = function () {
60 | const commonMsgs = Messages.loadMessages('salesforce-alm', 'source');
61 | return syncCommandHelper.getColumnMetaInfo(commonMsgs);
62 | };
63 |
64 | export = SrcStatusCommand;
65 |
--------------------------------------------------------------------------------
/src/commands/force/source/deploy/cancel.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { Messages } from '@salesforce/core';
9 | import { flags, FlagsConfig } from '@salesforce/command';
10 | import { Duration } from '@salesforce/kit';
11 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
12 |
13 | import consts = require('../../../../lib/core/constants');
14 | import Stash = require('../../../../lib/core/stash');
15 | const { DEFAULT_SRC_WAIT_MINUTES, MIN_SRC_WAIT_MINUTES } = consts;
16 |
17 | Messages.importMessagesDirectory(__dirname);
18 |
19 | const messages = Messages.loadMessages('salesforce-alm', 'source_deploy_cancel');
20 | const commonMsgs = Messages.loadMessages('salesforce-alm', 'source');
21 |
22 | export class SourceDeployCancelCommand extends ToolbeltCommand {
23 | public static readonly theDescription = messages.getMessage('description');
24 | public static readonly longDescription = messages.getMessage('longDescription');
25 | public static readonly help = messages.getMessage('help');
26 | public static readonly requiresProject = false;
27 | public static readonly requiresUsername = true;
28 | public static readonly flagsConfig: FlagsConfig = {
29 | wait: flags.minutes({
30 | char: 'w',
31 | required: false,
32 | hidden: false,
33 | default: Duration.minutes(DEFAULT_SRC_WAIT_MINUTES),
34 | min: Duration.minutes(MIN_SRC_WAIT_MINUTES),
35 | description: commonMsgs.getMessage('waitParamDescription', [DEFAULT_SRC_WAIT_MINUTES]),
36 | longDescription: commonMsgs.getMessage('waitParamDescriptionLong'),
37 | }),
38 | jobid: flags.id({
39 | char: 'i',
40 | description: messages.getMessage('jobId'),
41 | longDescription: messages.getMessage('jobIdLong'),
42 | required: false,
43 | }),
44 | };
45 |
46 | public async run(): Promise {
47 | const { MdapiCancelCommand } = require('../../../../lib/mdapi/mdapiDeployCancelCommand');
48 | const context = await this.resolveLegacyContext();
49 | return await this.execLegacyCommand(new MdapiCancelCommand(Stash.Commands.SOURCE_DEPLOY), context);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/commands/force/apex/log/tail.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import * as Messages from '../../../../lib/force-cli/force-cli-messages';
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | export class ApexLogTailCommand extends ToolbeltCommand {
17 | public static readonly theDescription = Messages.get('ApexLogTailDescription');
18 | public static readonly longDescription = Messages.get('ApexLogTailLongDescription');
19 | public static readonly help = Messages.get('ApexLogTailHelp');
20 | public static readonly requiresProject = false;
21 | public static readonly flagsConfig: FlagsConfig = {
22 | color: flags.boolean({
23 | char: 'c',
24 | required: false,
25 | hidden: false,
26 | description: Messages.get('ApexLogTailColorizeDescription'),
27 | longDescription: Messages.get('ApexLogTailColorizeLongDescription'),
28 | }),
29 | debuglevel: flags.string({
30 | char: 'd',
31 | required: false,
32 | hidden: false,
33 | description: Messages.get('ApexLogTailDebugLevelDescription'),
34 | longDescription: Messages.get('ApexLogTailDebugLevelLongDescription'),
35 | }),
36 | skiptraceflag: flags.boolean({
37 | char: 's',
38 | required: false,
39 | hidden: false,
40 | description: Messages.get('ApexLogTailSkipTraceFlagDescription'),
41 | longDescription: Messages.get('ApexLogTailSkipTraceFlagLongDescription'),
42 | }),
43 | };
44 |
45 | public static readonly requiresUsername = true;
46 | public async run(): Promise {
47 | const context = await this.resolveLegacyContext();
48 | // eslint-disable-next-line @typescript-eslint/no-shadow
49 | const { ApexLogTailCommand } = require('../../../../lib/apex/apexLogTailCommand');
50 | return await this.execLegacyCommand(new ApexLogTailCommand(), context);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/commands/force/source/deploy/report.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { Messages } from '@salesforce/core';
9 | import { flags, FlagsConfig } from '@salesforce/command';
10 | import { Duration } from '@salesforce/kit';
11 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
12 |
13 | import consts = require('../../../../lib/core/constants');
14 | import Stash = require('../../../../lib/core/stash');
15 | const { DEFAULT_SRC_WAIT_MINUTES, MIN_SRC_WAIT_MINUTES } = consts;
16 |
17 | Messages.importMessagesDirectory(__dirname);
18 |
19 | const messages = Messages.loadMessages('salesforce-alm', 'source_deploy_report');
20 | const commonMsgs = Messages.loadMessages('salesforce-alm', 'source');
21 |
22 | export class SourceDeployReportCommand extends ToolbeltCommand {
23 | public static readonly theDescription = messages.getMessage('description');
24 | public static readonly longDescription = messages.getMessage('longDescription');
25 | public static readonly help = messages.getMessage('help');
26 | public static readonly requiresProject = false;
27 | public static readonly requiresUsername = true;
28 | public static readonly flagsConfig: FlagsConfig = {
29 | wait: flags.minutes({
30 | char: 'w',
31 | required: false,
32 | hidden: false,
33 | default: Duration.minutes(DEFAULT_SRC_WAIT_MINUTES),
34 | min: Duration.minutes(MIN_SRC_WAIT_MINUTES),
35 | description: commonMsgs.getMessage('waitParamDescription', [DEFAULT_SRC_WAIT_MINUTES]),
36 | longDescription: commonMsgs.getMessage('waitParamDescriptionLong'),
37 | }),
38 | jobid: flags.id({
39 | char: 'i',
40 | description: messages.getMessage('jobId'),
41 | longDescription: messages.getMessage('jobIdLong'),
42 | required: false,
43 | }),
44 | };
45 |
46 | public async run(): Promise {
47 | const context = await this.resolveLegacyContext();
48 | const MdapiDeployReportCommand = require('../../../../lib/mdapi/mdapiDeployReportCommand');
49 | return this.execLegacyCommand(new MdapiDeployReportCommand(context, Stash.Commands.SOURCE_DEPLOY), context);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/commands/force/package/version/promote.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../../lib/core/constants');
18 |
19 | export class PackageVersionPromoteCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_version_promote');
21 | public static readonly longDescription = messages.getMessage('cliDescriptionLong', [], 'package_version_promote');
22 | public static readonly help = messages.getMessage('help', [], 'package_version_promote');
23 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
24 | public static readonly requiresDevhubUsername = true;
25 | public static readonly requiresProject = true;
26 | public static readonly flagsConfig: FlagsConfig = {
27 | package: flags.string({
28 | char: 'p',
29 | description: messages.getMessage('package', [], 'package_version_promote'),
30 | longDescription: messages.getMessage('packageLong', [], 'package_version_promote'),
31 | required: true,
32 | }),
33 | noprompt: flags.boolean({
34 | char: 'n',
35 | description: messages.getMessage('setasreleasedForce', [], 'package_version_promote'),
36 | longDescription: messages.getMessage('setasreleasedForceLong', [], 'package_version_promote'),
37 | required: false,
38 | }),
39 | };
40 |
41 | public async run(): Promise {
42 | const context = await this.resolveLegacyContext();
43 |
44 | const PackageVersionPromoteCommandImpl = require('../../../../lib/package/packageVersionPromoteCommand');
45 | const packageVersionPromoteCommand = new PackageVersionPromoteCommandImpl();
46 |
47 | return this.execLegacyCommand(packageVersionPromoteCommand, context);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/nonDecomposedWorkspaceStrategy.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 | /* eslint-disable @typescript-eslint/no-unused-vars */
8 |
9 | import { Nullable } from '@salesforce/ts-types';
10 | import { MetadataDocumentAnnotation } from '../metadataDocument';
11 | import { DecompositionWorkspaceStrategy } from './decompositionWorkspaceStrategy';
12 | import { DecomposedSubtypeConfig } from './decompositionConfig';
13 |
14 | /**
15 | * Workspace decomposition strategy where metadata files do not require decomposition
16 | */
17 |
18 | export class NonDecomposedWorkspaceStrategy implements DecompositionWorkspaceStrategy {
19 | /**
20 | * Returns null because this strategy has no decompositions
21 | *
22 | * @param annotation
23 | * @param decomposedSubtypeConfig
24 | * @returns {null}
25 | */
26 | getDecomposedFileName(annotation, decomposedSubtypeConfig) {
27 | return null;
28 | }
29 |
30 | /**
31 | * For non-decomposed source, the metadata file path is also the container path
32 | *
33 | * @param metadataFilePath
34 | * @param ext
35 | * @returns {any}
36 | */
37 | getContainerPath(metadataFilePath, ext) {
38 | return metadataFilePath;
39 | }
40 |
41 | /**
42 | * Returns an empty map because this strategy has no decompositions
43 | *
44 | * @param metadataFilePath
45 | * @param ext
46 | * @returns {Map}
47 | */
48 | findDecomposedPaths(metadataFilePath, ext) {
49 | return new Map();
50 | }
51 |
52 | /**
53 | * Returns null because this strategy has no decompositions
54 | *
55 | * @param metadataFilePath
56 | * @param ext
57 | * @param decomposedSubtypeConfig
58 | * @returns {null}
59 | */
60 | getDecomposedSubtypeDirFromMetadataFile(metadataFilePath, ext, decomposedSubtypeConfig) {
61 | return null;
62 | }
63 |
64 | getDecomposedSubtypeDirFromAnnotation(
65 | annotation: MetadataDocumentAnnotation,
66 | metadataType: string,
67 | aggregateFullName: string,
68 | decomposedSubtypeConfig: DecomposedSubtypeConfig
69 | ): Nullable {
70 | return null;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/virtualDecompositionCommitStrategy.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // Node
9 | import { fs } from '@salesforce/core';
10 | import * as util from 'util';
11 |
12 | import { DecompositionConfig } from './decompositionConfig';
13 | import { DecompositionCommitStrategy } from './decompositionCommitStrategy';
14 | import { FineGrainTrackingCommitStrategy } from './fineGrainTrackingCommitStrategy';
15 | import { MetadataDocument } from '../metadataDocument';
16 |
17 | /**
18 | * When we don't have fine grain tracking we most likely aren't decomposing into "real" (mdapi addressable) metadata entities.
19 | * In these virtual decomposition cases deletions become the responsibility of the decomposition.
20 | */
21 | export class VirtualDecompositionCommitStrategy
22 | extends FineGrainTrackingCommitStrategy
23 | implements DecompositionCommitStrategy
24 | {
25 | constructor(decompositionConfig: DecompositionConfig) {
26 | super(decompositionConfig);
27 | }
28 |
29 | async commit(
30 | documents: Map,
31 | existingPaths: string[],
32 | createDuplicates: boolean,
33 | forceoverwrite = false
34 | ): Promise<[string[], string[], string[], string[]]> {
35 | let newPaths: string[];
36 | let deletedPaths: string[];
37 | let updatedPaths: string[];
38 | let dupPaths: string[] = [];
39 | [newPaths, updatedPaths, deletedPaths, dupPaths] = await super.commit(
40 | documents,
41 | existingPaths,
42 | createDuplicates /** generateDuplicates */,
43 | forceoverwrite
44 | );
45 |
46 | deletedPaths = this.getDeletedPaths(documents, existingPaths); // No fine grain tracking to help us here.
47 | deletedPaths.map((deletedPath) => fs.unlinkSync(deletedPath));
48 |
49 | return [newPaths, updatedPaths, deletedPaths, dupPaths];
50 | }
51 |
52 | getDeletedPaths(documents: Map, existingPaths: string[]): string[] {
53 | return existingPaths.reduce((deletedPaths, existingPath) => {
54 | if (util.isNullOrUndefined(documents.get(existingPath))) {
55 | deletedPaths.push(existingPath);
56 | }
57 | return deletedPaths;
58 | }, []);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/lib/org/orgConfigAttributes.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /* --------------------------------------------------------------------------------------------------------------------
9 | * WARNING: This file has been deprecated and should now be considered locked against further changes. Its contents
10 | * have been partially or wholely superceded by functionality included in the @salesforce/core npm package, and exists
11 | * now to service prior uses in this repository only until they can be ported to use the new @salesforce/core library.
12 | *
13 | * If you need or want help deciding where to add new functionality or how to migrate to the new library, please
14 | * contact the CLI team at alm-cli@salesforce.com.
15 | * ----------------------------------------------------------------------------------------------------------------- */
16 |
17 | // Fields the scratch org config object is expected to have
18 | export = {
19 | ORG_ID: { name: 'orgId' },
20 | ACCESS_TOKEN: { name: 'accessToken', secret: true },
21 | REFRESH_TOKEN: { name: 'refreshToken', secret: true, required: false },
22 | INSTANCE_URL: { name: 'instanceUrl' },
23 | LOGIN_URL: { name: 'loginUrl', required: false },
24 | USERNAME: { name: 'username' },
25 | PASSWORD: { name: 'password', secret: true, required: false },
26 | CLIENT_ID: { name: 'clientId', required: false },
27 | PRIVATE_KEY: { name: 'privateKey', required: false },
28 | CLIENT_SECRET: { name: 'clientSecret', secret: true, required: false },
29 | CREATED_ORG_INSTANCE: { name: 'createdOrgInstance', required: false },
30 | CREATED: { name: 'created', required: false },
31 | DEV_HUB_USERNAME: { name: 'devHubUsername', required: false },
32 | IS_DEV_HUB: { name: 'isDevHub', required: false },
33 | IS_SCRATCH_ORG: { name: 'isScratchOrg', required: false },
34 | SCRATCH_ADMIN_USERNAME: { name: 'scratchAdminUsername', required: false },
35 | USER_PROFILE_NAME: { name: 'userProfileName', required: false },
36 | USER_ID: { name: 'userId', required: false },
37 | TRIAL_EXPIRATION_DATE: { name: 'trialExpirationDate', required: false },
38 | SNAPSHOT: { name: 'snapshot', required: false },
39 | EXPIRATION_DATE: { name: 'expirationDate', required: false },
40 | };
41 |
--------------------------------------------------------------------------------
/src/lib/org/orgShapeDeleteCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import * as _ from 'lodash';
9 | import Command from '../core/command';
10 |
11 | // Thirdparty
12 |
13 | import Messages = require('../messages');
14 | const messages = Messages();
15 | import srcDevUtil = require('../core/srcDevUtil');
16 | import * as almError from '../core/almError';
17 | import ShapeRepApi = require('./shapeRepApi');
18 |
19 | /**
20 | * Command impl for force:org:shape:delete
21 | */
22 | class OrgShapeDeleteCommand extends Command {
23 | private org;
24 | private shapeApi;
25 |
26 | constructor() {
27 | super('org:shape:delete');
28 | }
29 |
30 | /**
31 | * executes the delete command
32 | *
33 | * @param context - the cli context
34 | * @returns {Promise}
35 | */
36 | async execute(): Promise {
37 | const orgData = await this.org.getConfig();
38 | const deletedShapeIds = await this.shapeApi.deleteAll();
39 | const results = { orgId: orgData.orgId, shapeIds: deletedShapeIds };
40 | return Promise.resolve(results);
41 | }
42 |
43 | /**
44 | * secondary validation for the cli.
45 | *
46 | * @param context - the cli context.
47 | * @returns {Promise}
48 | */
49 | async validate(context): Promise {
50 | // validate varargs
51 | await super.validate(context);
52 |
53 | this.org = context.org;
54 | const fixedContext = srcDevUtil.fixCliContext(context);
55 | const username = fixedContext.targetusername;
56 |
57 | // raise an error if the org does not have the feature enabled
58 | this.shapeApi = new ShapeRepApi(this.org.force, this.org);
59 | const enabled = await this.shapeApi.isFeatureEnabled();
60 | if (!enabled) {
61 | return Promise.reject(almError({ keyName: 'noAccess', bundle: 'org_shape_delete' }, [username]));
62 | }
63 |
64 | return Promise.resolve(fixedContext);
65 | }
66 |
67 | getHumanSuccessMessage(results) {
68 | if (_.isEmpty(results.shapeIds)) {
69 | return messages.getMessage('noShapesHumanSuccess', results.orgId, 'org_shape_delete');
70 | }
71 | return messages.getMessage('humanSuccess', results.orgId, 'org_shape_delete');
72 | }
73 | }
74 | export = OrgShapeDeleteCommand;
75 |
--------------------------------------------------------------------------------
/src/commands/force/mdapi/deploy/cancel.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import { Messages } from '@salesforce/core';
14 | import { Duration } from '@salesforce/kit';
15 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
16 |
17 | import consts = require('../../../../lib/core/constants');
18 | const { DEFAULT_SRC_WAIT_MINUTES, MIN_SRC_WAIT_MINUTES } = consts;
19 |
20 | Messages.importMessagesDirectory(__dirname);
21 |
22 | const messages = Messages.loadMessages('salesforce-alm', 'mdapi_cancel');
23 | const commonMsgs = Messages.loadMessages('salesforce-alm', 'source');
24 |
25 | export class MdapiDeployCancelCommand extends ToolbeltCommand {
26 | public static readonly theDescription = messages.getMessage('description');
27 | public static readonly longDescription = messages.getMessage('longDescription');
28 | public static readonly help = messages.getMessage('help');
29 | public static readonly requiresProject = false;
30 | public static readonly requiresUsername = true;
31 | public static readonly flagsConfig: FlagsConfig = {
32 | wait: flags.minutes({
33 | char: 'w',
34 | required: false,
35 | hidden: false,
36 | default: Duration.minutes(DEFAULT_SRC_WAIT_MINUTES),
37 | min: Duration.minutes(MIN_SRC_WAIT_MINUTES),
38 | description: commonMsgs.getMessage('waitParamDescription', [DEFAULT_SRC_WAIT_MINUTES]),
39 | longDescription: commonMsgs.getMessage('waitParamDescriptionLong'),
40 | }),
41 | jobid: flags.id({
42 | char: 'i',
43 | description: messages.getMessage('jobId'),
44 | longDescription: messages.getMessage('jobIdLong'),
45 | required: false,
46 | }),
47 | };
48 | public async run(): Promise {
49 | const { MdapiCancelCommandImpl } = require('../../../../lib/mdapi/mdapiDeployCancelCommand');
50 | const context = await this.resolveLegacyContext();
51 | return await this.execLegacyCommand(new MdapiCancelCommandImpl(), context);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/commands/force/package/version/create/list.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../../../lib/core/constants');
18 |
19 | export class PackageVersionCreateListCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_version_create_list');
21 | public static readonly longDescription = messages.getMessage('cliLongDescription', [], 'package_version_create_list');
22 | public static readonly help = messages.getMessage('help', [], 'package_version_create_list');
23 | public static readonly requiresProject = false;
24 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
25 | public static readonly requiresDevhubUsername = true;
26 | public static readonly flagsConfig: FlagsConfig = {
27 | createdlastdays: flags.number({
28 | char: 'c',
29 | description: messages.getMessage('createdLastDaysDescription', [], 'packaging'),
30 | longDescription: messages.getMessage('createdLastDaysLongDescription', [], 'packaging'),
31 | required: false,
32 | }),
33 | status: flags.enum({
34 | char: 's',
35 | description: messages.getMessage('statusDescription', [], 'package_version_create_list'),
36 | longDescription: messages.getMessage('statusLongDescription', [], 'package_version_create_list'),
37 | required: false,
38 | options: ['Queued', 'InProgress', 'Success', 'Error'],
39 | }),
40 | };
41 |
42 | public async run(): Promise {
43 | const context = await this.resolveLegacyContext();
44 | const PackageVersionCreateRequestListCommand = require('../../../../../lib/package/packageVersionCreateRequestListCommand');
45 | return this.execLegacyCommand(new PackageVersionCreateRequestListCommand(), context);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/commands/force/org/shape/delete.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 |
18 | export class OrgShapeDeleteCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('description', [], 'org_shape_delete');
20 | public static readonly longDescription = messages.getMessage('longDescription', [], 'org_shape_delete');
21 | public static readonly help = messages.getMessage('help', [], 'org_shape_delete');
22 | public static readonly requiresProject = false;
23 | public static readonly requiresUsername = true;
24 | public static readonly flagsConfig: FlagsConfig = {
25 | noprompt: flags.boolean({
26 | char: 'p',
27 | description: messages.getMessage('noPrompt', [], 'org_shape_delete'),
28 | longDescription: messages.getMessage('noPromptLong', [], 'org_shape_delete'),
29 | required: false,
30 | }),
31 | };
32 |
33 | public async run(): Promise {
34 | const context = await this.resolveLegacyContext();
35 | const heroku = require('heroku-cli-util');
36 |
37 | const OrgShapeDeleteCommandImpl = require('../../../../lib/org/orgShapeDeleteCommand');
38 | const orgShapeDeleteCommand = new OrgShapeDeleteCommandImpl();
39 |
40 | // don't prompt yes/no if we're forcing the delete request, just execute
41 | if (context.flags.noprompt) {
42 | return this.execLegacyCommand(orgShapeDeleteCommand, context);
43 | } else {
44 | return heroku
45 | .prompt(messages.getMessage('deleteCommandYesNo', this.org.getUsername(), 'org_shape_delete'))
46 | .then((answer) => {
47 | if (answer.toUpperCase() === 'YES' || answer.toUpperCase() === 'Y') {
48 | return this.execLegacyCommand(orgShapeDeleteCommand, context);
49 | }
50 | return undefined;
51 | });
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/lib/package1/package1VersionListApi.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // Node
9 | import * as util from 'util';
10 |
11 | // Local
12 | import logger = require('../core/logApi');
13 | import messages = require('../messages');
14 |
15 | const Package1VersionListApi = function (org) {
16 | this.releaseOrg = org;
17 | this.force = this.releaseOrg.force;
18 | this.messages = messages(this.force.config.getLocale());
19 | this.logger = logger.child('Package1VersionListApi');
20 | };
21 |
22 | /**
23 | * Lists package versions available in dev org. If package ID is supplied, only list versions of that package,
24 | * otherwise, list all package versions
25 | *
26 | * @param metadataPackageId: optional, if present ID of package to list versions for (starts with 033)
27 | * @returns Array of package version results
28 | */
29 | Package1VersionListApi.prototype.list = function (metadataPackageId) {
30 | const selectClause =
31 | 'SELECT Id,MetadataPackageId,Name,ReleaseState,MajorVersion,MinorVersion,PatchVersion,BuildNumber FROM MetadataPackageVersion';
32 |
33 | const whereClause = util.isNullOrUndefined(metadataPackageId)
34 | ? ''
35 | : ` WHERE MetadataPackageId = '${metadataPackageId}'`;
36 |
37 | const orderByClause = ' ORDER BY MetadataPackageId, MajorVersion, MinorVersion, PatchVersion, BuildNumber';
38 |
39 | const query = `${selectClause}${whereClause}${orderByClause}`;
40 |
41 | return this.force.toolingQuery(this.releaseOrg, query).then((queryResult) => {
42 | const results = [];
43 | const records = queryResult.records;
44 | if (!util.isNullOrUndefined(records)) {
45 | for (let i = 0; i < records.length; i++) {
46 | const record = queryResult.records[i];
47 | // TODO: In 208, will add package description
48 | results.push({
49 | MetadataPackageVersionId: record.Id,
50 | MetadataPackageId: record.MetadataPackageId,
51 | Name: record.Name,
52 | ReleaseState: record.ReleaseState,
53 | Version: `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}`,
54 | BuildNumber: record.BuildNumber,
55 | });
56 | }
57 | }
58 | return results;
59 | });
60 | };
61 |
62 | export = Package1VersionListApi;
63 |
--------------------------------------------------------------------------------
/src/lib/package1/package1VersionListCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // Local
9 | import logger = require('../core/logApi');
10 | import messages = require('../messages');
11 | import * as Package1VersionListApi from './package1VersionListApi';
12 |
13 | const Package1VersionListCommand = function (org) {
14 | this.releaseOrg = org;
15 | this.messages = messages();
16 | this.logger = logger.child('Package1VersionListCommand');
17 | this.listApi = new Package1VersionListApi(this.releaseOrg);
18 | };
19 |
20 | const requestFromContext = function (context) {
21 | return {
22 | MetadataPackageId: context.flags.packageid,
23 | };
24 | };
25 |
26 | /**
27 | * Lists a new version of the Managed Package in the target org.
28 | *
29 | * @param context: heroku context
30 | * @returns {*|promise}
31 | */
32 | Package1VersionListCommand.prototype.execute = function (context) {
33 | const request = requestFromContext(context);
34 |
35 | return this.listApi.list(request.MetadataPackageId);
36 | };
37 |
38 | /**
39 | * returns a human readable message for a cli output
40 | *
41 | * @param result - the data representing the Package Version
42 | * @returns {string}
43 | */
44 | Package1VersionListCommand.prototype.getHumanSuccessMessage = function () {
45 | return this.messages.getMessage('package1VersionListHumanSuccess');
46 | };
47 |
48 | /**
49 | * indicates that the human readable message should be tabular
50 | *
51 | * @returns {[{}...]}
52 | */
53 | Package1VersionListCommand.prototype.getColumnData = function () {
54 | return [
55 | { key: 'MetadataPackageVersionId', label: 'MetadataPackageVersionId' },
56 | { key: 'MetadataPackageId', label: 'MetadataPackageId' },
57 | { key: 'Name', label: 'Name' },
58 | { key: 'Version', label: 'Version' },
59 | { key: 'ReleaseState', label: 'ReleaseState' },
60 | { key: 'BuildNumber', label: 'BuildNumber' },
61 | ];
62 | };
63 |
64 | /**
65 | * returns a human readable message for cli error output
66 | *
67 | * @returns {string}
68 | */
69 | Package1VersionListCommand.prototype.getHumanErrorMessage = function (err) {
70 | if (!err.action) {
71 | err['action'] = this.messages.getMessage('package1VersionListAction');
72 | }
73 | };
74 |
75 | export = Package1VersionListCommand;
76 |
--------------------------------------------------------------------------------
/src/commands/force/package/delete.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../lib/core/constants');
18 |
19 | export class PackageDeleteCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_delete');
21 | public static readonly longDescription = messages.getMessage('cliLongDescription', [], 'package_delete');
22 | public static readonly help = messages.getMessage('help', [], 'package_delete');
23 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
24 | public static readonly requiresDevhubUsername = true;
25 | public static readonly requiresProject = true;
26 | public static readonly flagsConfig: FlagsConfig = {
27 | noprompt: flags.boolean({
28 | char: 'n',
29 | description: messages.getMessage('noPrompt', [], 'package_delete'),
30 | longDescription: messages.getMessage('noPrompt', [], 'package_delete'),
31 | required: false,
32 | }),
33 | package: flags.string({
34 | char: 'p',
35 | description: messages.getMessage('package', [], 'package_delete'),
36 | longDescription: messages.getMessage('packageLong', [], 'package_delete'),
37 | required: true,
38 | }),
39 | undelete: flags.boolean({
40 | description: messages.getMessage('undelete', [], 'package_delete'),
41 | longDescription: messages.getMessage('undeleteLong', [], 'package_delete'),
42 | required: false,
43 | hidden: true,
44 | }),
45 | };
46 |
47 | public async run(): Promise {
48 | const context = await this.resolveLegacyContext();
49 | const PackageDeleteCommandImpl = require('../../../lib/package/packageDeleteCommand');
50 | const heroku = require('heroku-cli-util');
51 | return this.execLegacyCommand(new PackageDeleteCommandImpl(heroku.prompt), context);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/commands/force/mdapi/describemetadata.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
14 |
15 | import Messages = require('../../../lib/messages');
16 | const messages = Messages();
17 | export class MdapiDescribemetadataCommand extends ToolbeltCommand {
18 | public static readonly theDescription = messages.getMessage('mdDescribeMetadataCommandCliDescription');
19 | public static readonly longDescription = messages.getMessage('mdDescribeMetadataCommandCliLong');
20 | public static readonly help = messages.getMessage('mdDescribeMetadataCommandCliHelp');
21 | public static readonly requiresProject = false;
22 | public static readonly requiresUsername = true;
23 | public static readonly flagsConfig: FlagsConfig = {
24 | apiversion: flags.builtin({
25 | // @ts-ignore force char override for backward compat -- don't try this at home!
26 | char: 'a',
27 | description: messages.getMessage('mdDescribeMetadataCommandCliApiVersion'),
28 | longDescription: messages.getMessage('mdDescribeMetadataCommandCliApiVersionLong'),
29 | }),
30 | resultfile: flags.filepath({
31 | char: 'f',
32 | description: messages.getMessage('mdDescribeMetadataCommandCliFilterKnown'),
33 | longDescription: messages.getMessage('mdDescribeMetadataCommandCliFilterKnownLong'),
34 | required: false,
35 | }),
36 | filterknown: flags.boolean({
37 | char: 'k',
38 | description: messages.getMessage('mdDescribeMetadataCommandCliResultFile'),
39 | longDescription: messages.getMessage('mdDescribeMetadataCommandCliResultFileLong'),
40 | hidden: true,
41 | }),
42 | };
43 |
44 | public async run(): Promise {
45 | const context = await this.resolveLegacyContext();
46 | // eslint-disable-next-line @typescript-eslint/no-shadow
47 | const MdapiDescribemetadataCommandImpl = require('../../../lib/mdapi/mdapiDescribemetadataCommand');
48 | return this.execLegacyCommand(new MdapiDescribemetadataCommandImpl(context), context);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/lib/package1/package1VersionDisplayCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // Local
9 | import logger = require('../core/logApi');
10 | import messages = require('../messages');
11 | import * as Package1VersionDisplayApi from './package1VersionDisplayApi';
12 |
13 | const Package1VersionDisplayCommand = function (org) {
14 | this.releaseOrg = org;
15 | this.logger = logger.child('Package1VersionListCommand');
16 | this.messages = messages();
17 | this.displayApi = new Package1VersionDisplayApi(this.releaseOrg);
18 | };
19 |
20 | const requestFromContext = function (context) {
21 | return {
22 | MetadataPackageVersionId: context.flags.packageversionid,
23 | };
24 | };
25 |
26 | /**
27 | * Displays information about the specified package version
28 | *
29 | * @param context: heroku context
30 | * @returns {*|promise}
31 | */
32 | Package1VersionDisplayCommand.prototype.execute = function (context) {
33 | const request = requestFromContext(context);
34 |
35 | return this.displayApi.display(request.MetadataPackageVersionId);
36 | };
37 |
38 | /**
39 | * returns a human readable message for a cli output
40 | *
41 | * @param result - the data representing the Package Version
42 | * @returns {string}
43 | */
44 | Package1VersionDisplayCommand.prototype.getHumanSuccessMessage = function () {
45 | return this.messages.getMessage('package1VersionDisplayHumanSuccess');
46 | };
47 |
48 | /**
49 | * indicates that the human readable message should be tabular
50 | *
51 | * @returns {[{}...]}
52 | */
53 | Package1VersionDisplayCommand.prototype.getColumnData = function () {
54 | return [
55 | { key: 'MetadataPackageVersionId', label: 'MetadataPackageVersionId' },
56 | { key: 'MetadataPackageId', label: 'MetadataPackageId' },
57 | { key: 'Name', label: 'Name' },
58 | { key: 'Version', label: 'Version' },
59 | { key: 'ReleaseState', label: 'ReleaseState' },
60 | { key: 'BuildNumber', label: 'BuildNumber' },
61 | ];
62 | };
63 |
64 | /**
65 | * returns a human readable message for cli error output
66 | *
67 | * @returns {string}
68 | */
69 | Package1VersionDisplayCommand.prototype.getHumanErrorMessage = function (err) {
70 | if (!err.action) {
71 | err['action'] = this.messages.getMessage('package1VersionDisplayAction');
72 | }
73 | };
74 |
75 | export = Package1VersionDisplayCommand;
76 |
--------------------------------------------------------------------------------
/src/commands/force/source/pull.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import { Messages } from '@salesforce/core';
14 | import { Duration } from '@salesforce/kit';
15 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
16 |
17 | Messages.importMessagesDirectory(__dirname);
18 | const mdapiMessages: Messages = Messages.loadMessages('salesforce-alm', 'mdapi_deploy');
19 | const messages: Messages = Messages.loadMessages('salesforce-alm', 'source_pull');
20 | import consts = require('../../../lib/core/constants');
21 |
22 | export class SourcePullCommand extends ToolbeltCommand {
23 | public static readonly theDescription = messages.getMessage('commandDescription');
24 | public static readonly longDescription = messages.getMessage('commandDescriptionLong');
25 | public static readonly help = messages.getMessage('commandHelp');
26 | public static readonly showProgress = true;
27 | public static readonly requiresProject = true;
28 | public static readonly requiresUsername = true;
29 | public static readonly flagsConfig: FlagsConfig = {
30 | wait: flags.minutes({
31 | char: 'w',
32 | description: mdapiMessages.getMessage('mdapiCliWait', [consts.DEFAULT_SRC_WAIT_MINUTES]),
33 | longDescription: messages.getMessage('waitFlagDescriptionLong'),
34 | required: false,
35 | default: Duration.minutes(consts.DEFAULT_SRC_WAIT_MINUTES),
36 | min: Duration.minutes(consts.MIN_SRC_WAIT_MINUTES),
37 | }),
38 | forceoverwrite: flags.boolean({
39 | char: 'f',
40 | description: messages.getMessage('forceoverwriteFlagDescription'),
41 | longDescription: messages.getMessage('forceoverwriteFlagDescriptionLong'),
42 | required: false,
43 | }),
44 | };
45 | protected readonly lifecycleEventNames = ['preretrieve', 'postretrieve', 'postsourceupdate'];
46 |
47 | public async run(): Promise {
48 | const context = await this.resolveLegacyContext();
49 | const MdapiPullCommand = require('../../../lib/source/sourcePullCommand');
50 | return this.execLegacyCommand(new MdapiPullCommand(), context);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/lib/source/decompositionStrategy/decompositionConfigFactory.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { InFolderDecompositionConfig } from './inFolderDecompositionConfig';
9 | import { CustomObjectTranslationDecompositionConfig } from './customObjectTranslationDecompositionConfig';
10 | import { DescribeMetadataDecompositionConfig } from './describeMetadataDecompositionConfig';
11 | import { NonDecomposedContentAndMetadataDecompositionConfig } from './nonDecomposedContentAndMetadataDecompositionConfig';
12 | import { StaticResourceDecompositionConfig } from './staticResourceDecompositionConfig';
13 | import { DecompositionConfig } from './decompositionConfig';
14 | import { TypeDefObj } from '../typeDefObj';
15 | import { ExperienceBundleDecompositionStrategyConfig } from './experienceBundleDecompositionStrategyConfig';
16 |
17 | export class DecompositionConfigFactory {
18 | static getDecompositionConfig(typeDefObj: TypeDefObj): DecompositionConfig {
19 | if (typeDefObj.inFolder) {
20 | return new InFolderDecompositionConfig(typeDefObj.metadataName, typeDefObj.isGlobal, typeDefObj.isEmptyContainer);
21 | }
22 |
23 | switch (typeDefObj.metadataName) {
24 | case 'CustomObjectTranslation':
25 | return new CustomObjectTranslationDecompositionConfig(
26 | typeDefObj.metadataName,
27 | typeDefObj.isGlobal,
28 | typeDefObj.isEmptyContainer
29 | );
30 | case 'Bot':
31 | case 'CustomObject':
32 | return new DescribeMetadataDecompositionConfig(
33 | typeDefObj.metadataName,
34 | typeDefObj.isGlobal,
35 | typeDefObj.isEmptyContainer,
36 | true
37 | );
38 | case 'StaticResource':
39 | return new StaticResourceDecompositionConfig(
40 | typeDefObj.metadataName,
41 | typeDefObj.isGlobal,
42 | typeDefObj.isEmptyContainer
43 | );
44 | case 'ExperienceBundle':
45 | return new ExperienceBundleDecompositionStrategyConfig(
46 | typeDefObj.metadataName,
47 | typeDefObj.isGlobal,
48 | typeDefObj.isEmptyContainer
49 | );
50 | default:
51 | return new NonDecomposedContentAndMetadataDecompositionConfig(
52 | typeDefObj.metadataName,
53 | typeDefObj.isGlobal,
54 | typeDefObj.isEmptyContainer
55 | );
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/lib/source/manifestUtils.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { AnyJson } from '@salesforce/ts-types';
9 | import * as PathUtil from '../source/sourcePathUtil';
10 | import { ManifestEntry, SourceOptions } from './types';
11 | import * as ManifestCreateApi from './manifestCreateApi';
12 |
13 | // eslint-disable-next-line @typescript-eslint/require-await
14 | export const toManifest = async function (
15 | org: any,
16 | options: SourceOptions,
17 | tmpOutputDir?: string
18 | ): Promise {
19 | if (options && options.metadata) {
20 | const entries: ManifestEntry[] = parseManifestEntries(options.metadata);
21 | if (entries != null) {
22 | // Create a manifest and update the options with the manifest file.
23 | options.manifest = (await createManifest(org, options, entries, tmpOutputDir)).file;
24 | return options.manifest;
25 | } else {
26 | return null;
27 | }
28 | }
29 | return null;
30 | };
31 |
32 | /**
33 | * Function to create a manifest for a given org
34 | *
35 | * @param org {AnyJson} An org
36 | * @param options {SourceOptions} Source options
37 | * @param mdPairs {ManifestEntry[]} Array of metadata items
38 | * @returns A package.xml manifest
39 | */
40 | export const createManifest = function (
41 | org: AnyJson,
42 | options: SourceOptions,
43 | mdPairs: ManifestEntry[] = [],
44 | tmpOutputDir?: string
45 | ): Promise<{ file: string }> {
46 | if (!org || !options) {
47 | return null;
48 | }
49 |
50 | const manifestApi = new ManifestCreateApi(org);
51 |
52 | // Create the package.xml in the temp dir
53 | const manifestOptions = Object.assign({}, options, {
54 | outputdir: tmpOutputDir,
55 | });
56 | return manifestApi.createManifest(manifestOptions, null, mdPairs);
57 | };
58 |
59 | /**
60 | * Parse manifest entry strings into an array of ManifestEntry objects
61 | *
62 | * @param arg {string} The entry string; e.g., "ApexClass, CustomObject:MyObjectName"
63 | */
64 | export const parseManifestEntries = function (entries: string): ManifestEntry[] | null {
65 | if (entries) {
66 | const mdParamArray = entries.split(',');
67 | return mdParamArray.map((md) => {
68 | const [mdType, ...rest] = md.split(':');
69 | const mdName = rest.length ? rest.join(':') : '*';
70 | return { type: mdType.trim(), name: PathUtil.replaceForwardSlashes(mdName.trim()) };
71 | });
72 | }
73 | return null;
74 | };
75 |
--------------------------------------------------------------------------------
/src/commands/force/mdapi/listmetadata.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 |
18 | export class MdapiListmetadataCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('mdListmetadataCommandCliDescription');
20 | public static readonly longDescription = messages.getMessage('mdListmetadataCommandCliLong');
21 | public static readonly help = messages.getMessage('mdListmetadataCommandCliHelp');
22 | public static readonly requiresProject = false;
23 | public static readonly requiresUsername = true;
24 | public static readonly flagsConfig: FlagsConfig = {
25 | apiversion: flags.builtin({
26 | // @ts-ignore force char override for backward compat -- don't try this at home!
27 | char: 'a',
28 | description: messages.getMessage('mdListmetadataCommandCliApiVersion'),
29 | longDescription: messages.getMessage('mdListmetadataCommandCliApiVersionLong'),
30 | }),
31 | resultfile: flags.filepath({
32 | char: 'f',
33 | description: messages.getMessage('mdListmetadataCommandCliResultFile'),
34 | longDescription: messages.getMessage('mdListmetadataCommandCliResultFileLong'),
35 | required: false,
36 | }),
37 | metadatatype: flags.string({
38 | char: 'm',
39 | description: messages.getMessage('mdListmetadataCommandCliMetadatatype'),
40 | longDescription: messages.getMessage('mdListmetadataCommandCliMetadatatypeLong'),
41 | required: true,
42 | }),
43 | folder: flags.string({
44 | description: messages.getMessage('mdListmetadataCommandCliFolder'),
45 | longDescription: messages.getMessage('mdListmetadataCommandCliFolderLong'),
46 | required: false,
47 | }),
48 | };
49 |
50 | public async run(): Promise {
51 | const context = await this.resolveLegacyContext();
52 | const MdapiListmetadataCommandImpl = require('../../../lib/mdapi/mdapiListmetadataCommand');
53 | return this.execLegacyCommand(new MdapiListmetadataCommandImpl(context), context);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/commands/force/mdapi/deploy/report.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import { Messages } from '@salesforce/core';
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | Messages.importMessagesDirectory(__dirname);
17 | const messages: Messages = Messages.loadMessages('salesforce-alm', 'mdapi_deploy');
18 |
19 | import consts = require('../../../../lib/core/constants');
20 | import Stash = require('../../../../lib/core/stash');
21 |
22 | export class MdapiDeployReportCommand extends ToolbeltCommand {
23 | public static readonly theDescription = messages.getMessage('mdDeployReportCommandCliDescription');
24 | public static readonly longDescription = messages.getMessage('mdDeployReportCommandCliLong');
25 | public static readonly help = messages.getMessage('mdDeployReportCommandCliHelp');
26 | public static readonly requiresProject = false;
27 | public static readonly requiresUsername = true;
28 | public static readonly flagsConfig: FlagsConfig = {
29 | wait: flags.minutes({
30 | char: 'w',
31 | description: messages.getMessage('mdapiCliWait', [consts.DEFAULT_MDAPI_WAIT_MINUTES]),
32 | longDescription: messages.getMessage('mdapiCliWaitLong', [consts.DEFAULT_MDAPI_WAIT_MINUTES]),
33 | required: false,
34 | }),
35 | jobid: flags.id({
36 | char: 'i',
37 | description: messages.getMessage('mdDeployCommandCliJobId'),
38 | longDescription: messages.getMessage('mdDeployCommandCliJobIdLong'),
39 | required: false,
40 | }),
41 | verbose: flags.builtin({
42 | description: messages.getMessage('mdDeployCommandCliVerbose'),
43 | longDescription: messages.getMessage('mdDeployReportCommandCliVerboseLong'),
44 | }),
45 | };
46 |
47 | public async run(): Promise {
48 | const context = await this.resolveLegacyContext();
49 | const MdapiDeployReportCommandImpl = require('../../../../lib/mdapi/mdapiDeployReportCommand');
50 | return this.execLegacyCommand(new MdapiDeployReportCommandImpl(context), context);
51 | }
52 | public resolveUsername(context) {
53 | return context.flags.jobid ? undefined : Stash.get('targetusername', Stash.Commands.MDAPI_DEPLOY);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/lib/core/errors.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | /* --------------------------------------------------------------------------------------------------------------------
9 | * WARNING: This file has been deprecated and should now be considered locked against further changes. Its contents
10 | * have been partially or wholely superceded by functionality included in the @salesforce/core npm package, and exists
11 | * now to service prior uses in this repository only until they can be ported to use the new @salesforce/core library.
12 | *
13 | * If you need or want help deciding where to add new functionality or how to migrate to the new library, please
14 | * contact the CLI team at alm-cli@salesforce.com.
15 | * ----------------------------------------------------------------------------------------------------------------- */
16 |
17 | import Messages = require('../messages');
18 | const messages = Messages();
19 |
20 | // @Todo Remove this file. Use almError.
21 |
22 | // @todo remove Validation Error. It's too generic.
23 | export function InvalidProjectWorkspace() {
24 | this.name = 'InvalidProjectWorkspace';
25 | this.code = this.name;
26 | this.message = messages.getMessage(this.name, this.code);
27 | this.stack = new Error().stack;
28 | }
29 | InvalidProjectWorkspace.prototype = Object.create(Error.prototype);
30 | InvalidProjectWorkspace.prototype.constructor = InvalidProjectWorkspace;
31 |
32 | // ----
33 |
34 | export function MissingAppConfig() {
35 | this.name = 'MissingAppConfig';
36 | this.message = messages.getMessage(this.name);
37 | this.code = this.name;
38 | }
39 | MissingAppConfig.prototype = Object.create(Error.prototype);
40 | MissingAppConfig.prototype.constructor = MissingAppConfig;
41 |
42 | // ---
43 |
44 | export function MissingRequiredParameter(paramName) {
45 | this.name = 'MissingRequiredParameter';
46 | this.message = messages.getMessage(this.name, [paramName]);
47 | this.code = this.name;
48 | }
49 | MissingRequiredParameter.prototype = Object.create(Error.prototype);
50 | MissingRequiredParameter.prototype.constructor = MissingRequiredParameter;
51 |
52 | // ---
53 |
54 | export function InvalidParameter(paramName, reason) {
55 | this.name = 'InvalidParameter';
56 | this.message = messages.getMessage(this.name, [paramName, reason]);
57 | this.code = this.name;
58 | }
59 | InvalidParameter.prototype = Object.create(Error.prototype);
60 | InvalidParameter.prototype.constructor = InvalidParameter;
61 |
--------------------------------------------------------------------------------
/src/commands/force/package/version/delete.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../../lib/core/constants');
18 |
19 | export class PackageVersionDeleteCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_version_delete');
21 | public static readonly longDescription = messages.getMessage('cliLongDescription', [], 'package_version_delete');
22 | public static readonly help = messages.getMessage('help', [], 'package_version_delete');
23 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
24 | public static readonly requiresDevhubUsername = true;
25 | public static readonly requiresProject = true;
26 | public static readonly flagsConfig: FlagsConfig = {
27 | noprompt: flags.boolean({
28 | char: 'n',
29 | description: messages.getMessage('noPrompt', [], 'package_version_delete'),
30 | longDescription: messages.getMessage('noPrompt', [], 'package_version_delete'),
31 | required: false,
32 | }),
33 | package: flags.string({
34 | char: 'p',
35 | description: messages.getMessage('package', [], 'package_version_delete'),
36 | longDescription: messages.getMessage('packageLong', [], 'package_version_delete'),
37 | required: true,
38 | }),
39 | undelete: flags.boolean({
40 | description: messages.getMessage('undelete', [], 'package_version_delete'),
41 | longDescription: messages.getMessage('undeleteLong', [], 'package_version_delete'),
42 | required: false,
43 | hidden: true,
44 | }),
45 | };
46 |
47 | public async run(): Promise {
48 | const context = await this.resolveLegacyContext();
49 | context.flagsConfig = this.statics.flagsConfig;
50 | const PackageVersionDeleteCommandImpl = require('../../../../lib/package/packageVersionDeleteCommand');
51 | const heroku = require('heroku-cli-util');
52 | return this.execLegacyCommand(new PackageVersionDeleteCommandImpl(heroku.prompt), context);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/lib/org/shapeRepCreateCommand.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | import { Messages, SfdxError } from '@salesforce/core';
9 | import VarargsCommand from '../core/varargsCommand';
10 |
11 | import ShapeRepApi = require('./shapeRepApi');
12 |
13 | Messages.importMessagesDirectory(__dirname);
14 | const messages = Messages.loadMessages('salesforce-alm', 'org_shape');
15 |
16 | interface ShapeResult {
17 | shapeId: string;
18 | shapeFile: string;
19 | success: boolean;
20 | errors: [];
21 | }
22 |
23 | class ShapeRepCreateCommand extends VarargsCommand {
24 | private shapeApi;
25 |
26 | constructor() {
27 | super('orgshape:create');
28 | }
29 |
30 | /**
31 | * secondary validation from the cli interface. this is a protocol style function intended to be represented by other
32 | * commands
33 | *
34 | * @param context - this cli context
35 | * @returns {Promise}
36 | */
37 | async validate(context): Promise {
38 | // validate varargs
39 | await super.validate(context);
40 |
41 | // Make sure the Org has the ShapePilotPref enabled
42 | this.shapeApi = new ShapeRepApi(context.org.force, context.org);
43 | const enabled = await this.shapeApi.isFeatureEnabled();
44 | if (!enabled) {
45 | return Promise.reject(new SfdxError(messages.getMessage('create_shape_command_no_access')));
46 | }
47 | }
48 |
49 | async execute(): Promise {
50 | const logger = await this.getLogger();
51 |
52 | // example response: { id: '3SRxx0000004D6iGAE', success: true, errors: [] }
53 | const createShapeResponse = await this.shapeApi.create();
54 |
55 | if (createShapeResponse['success'] != true) {
56 | logger.error('Shape create failed', createShapeResponse['errors']);
57 | throw Promise.reject(new SfdxError(messages.getMessage('shape_create_failed_message')));
58 | }
59 |
60 | const shapeId = createShapeResponse['id'];
61 |
62 | let scratchDefFileName;
63 |
64 | return { shapeId, shapeFile: scratchDefFileName, success: true, errors: [] };
65 | }
66 |
67 | getHumanSuccessMessage(shape) {
68 | const shapeFileName = shape.shapeFile;
69 |
70 | if (typeof shapeFileName != 'undefined' && shapeFileName) {
71 | return messages.getMessage('create_shape_command_success_file', [shape.shapeFile]);
72 | } else {
73 | return messages.getMessage('create_shape_command_success_id', [shape.shapeId]);
74 | }
75 | }
76 | }
77 |
78 | export = ShapeRepCreateCommand;
79 |
--------------------------------------------------------------------------------
/src/commands/force/source/status.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 |
18 | export class SourceStatusCommand extends ToolbeltCommand {
19 | public static readonly theDescription = messages.getMessage('statusCommandCliDescription');
20 | public static readonly longDescription = messages.getMessage('statusCommandCliLongDescription');
21 | public static readonly help = messages.getMessage('statusCommandCliHelp');
22 | public static readonly showProgress = true;
23 | public static readonly requiresProject = true;
24 | public static readonly requiresUsername = true;
25 | public static readonly flagsConfig: FlagsConfig = {
26 | all: flags.boolean({
27 | char: 'a',
28 | description: messages.getMessage('statusCommandAllOptionDescription'),
29 | longDescription: messages.getMessage('statusCommandAllOptionDescriptionLong'),
30 | required: false,
31 | }),
32 | local: flags.boolean({
33 | char: 'l',
34 | description: messages.getMessage('statusCommandLocalOptionDescription'),
35 | longDescription: messages.getMessage('statusCommandLocalOptionDescriptionLong'),
36 | required: false,
37 | }),
38 | remote: flags.boolean({
39 | char: 'r',
40 | description: messages.getMessage('statusCommandRemoteOptionDescription'),
41 | longDescription: messages.getMessage('statusCommandRemoteOptionDescriptionLong'),
42 | required: false,
43 | }),
44 | };
45 |
46 | public async run(): Promise {
47 | const _ = require('lodash');
48 | const context = await this.resolveLegacyContext();
49 | const SrcStatusCommand = require('../../../lib/source/srcStatusCommand');
50 | if ((_.isNil(context.flags.local) && _.isNil(context.flags.remote)) || context.flags.all) {
51 | context.local = true;
52 | context.remote = true;
53 | } else if (context.flags.local) {
54 | context.local = true;
55 | } else if (context.flags.remote) {
56 | context.remote = true;
57 | }
58 | const command = new SrcStatusCommand(context);
59 | return this.execLegacyCommand(command, context);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/commands/force/package/update.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../lib/core/constants');
18 |
19 | export class PackageUpdateCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('cliDescription', [], 'package_update');
21 | public static readonly longDescription = messages.getMessage('cliLongDescription', [], 'package_update');
22 | public static readonly help = messages.getMessage('help', [], 'package_update');
23 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
24 | public static readonly requiresDevhubUsername = true;
25 | public static readonly requiresProject = true;
26 | public static readonly flagsConfig: FlagsConfig = {
27 | package: flags.string({
28 | char: 'p',
29 | description: messages.getMessage('package', [], 'package_update'),
30 | longDescription: messages.getMessage('packageLong', [], 'package_update'),
31 | required: true,
32 | }),
33 | name: flags.string({
34 | char: 'n',
35 | description: messages.getMessage('name', [], 'package_update'),
36 | longDescription: messages.getMessage('nameLong', [], 'package_update'),
37 | required: false,
38 | }),
39 | description: flags.string({
40 | char: 'd',
41 | description: messages.getMessage('description', [], 'package_update'),
42 | longDescription: messages.getMessage('descriptionLong', [], 'package_update'),
43 | required: false,
44 | }),
45 | errornotificationusername: flags.string({
46 | char: 'o',
47 | description: messages.getMessage('errorNotificationUsername', [], 'package_create'),
48 | longDescription: messages.getMessage('errorNotificationUsernameLong', [], 'package_create'),
49 | required: false,
50 | }),
51 | };
52 |
53 | public async run(): Promise {
54 | const context = await this.resolveLegacyContext();
55 | const PackageUpdateCommandImpl = require('../../../lib/package/packageUpdateCommand');
56 | return this.execLegacyCommand(new PackageUpdateCommandImpl(), context);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/commands/force/org/snapshot/create.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, salesforce.com, inc.
3 | * All rights reserved.
4 | * Licensed under the BSD 3-Clause license.
5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6 | */
7 |
8 | // This is the legacy converted command file. Ignoring code-coverage since this is generated.
9 | // THIS SHOULD BE REMOVED WHEN CONVERTED TO EXTEND SfdxCommand
10 | /* istanbul ignore file */
11 |
12 | import { flags, FlagsConfig } from '@salesforce/command';
13 | import Messages = require('../../../../lib/messages');
14 | import { ToolbeltCommand } from '../../../../ToolbeltCommand';
15 |
16 | const messages = Messages();
17 | import consts = require('../../../../lib/core/constants');
18 |
19 | export class OrgSnapshotCreateCommand extends ToolbeltCommand {
20 | public static readonly theDescription = messages.getMessage('createSnapshotCmdDescription', [], 'orgSnapshot');
21 | public static readonly longDescription = messages.getMessage('createSnapshotCmdDescriptionLong', [], 'orgSnapshot');
22 | public static readonly help = messages.getMessage('createSnapshotCmdHelp', [], 'orgSnapshot');
23 | public static readonly showProgress = true;
24 | public static readonly requiresProject = false;
25 | public static readonly requiresDevhubUsername = true;
26 | public static readonly orgType = consts.DEFAULT_DEV_HUB_USERNAME;
27 | public static readonly flagsConfig: FlagsConfig = {
28 | sourceorg: flags.string({
29 | char: 'o',
30 | description: messages.getMessage('createSnapshotCmdSourceOrgDescription', [], 'orgSnapshot'),
31 | longDescription: messages.getMessage('createSnapshotCmdSourceOrgDescriptionLong', [], 'orgSnapshot'),
32 | required: true,
33 | }),
34 | snapshotname: flags.string({
35 | char: 'n',
36 | description: messages.getMessage('createSnapshotCmdNameDescription', [], 'orgSnapshot'),
37 | longDescription: messages.getMessage('createSnapshotCmdNameDescriptionLong', [], 'orgSnapshot'),
38 | required: true,
39 | }),
40 | description: flags.string({
41 | char: 'd',
42 | description: messages.getMessage('createSnapshotCmdDescriptionDescription', [], 'orgSnapshot'),
43 | longDescription: messages.getMessage('createSnapshotCmdDescriptionDescriptionLong', [], 'orgSnapshot'),
44 | required: false,
45 | }),
46 | };
47 |
48 | public async run(): Promise {
49 | const context = await this.resolveLegacyContext();
50 | const OrgSnapshotCreateCommandImpl = require('../../../../lib/org/snapshot/orgSnapshotCreateCommand'); // eslint-disable-line global-require
51 | return this.execLegacyCommand(new OrgSnapshotCreateCommandImpl(), context);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------