Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions messages/deploy.metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,8 @@ The `pushPackageDirectoriesSequentially` property is not respected by this comma
# apiVersionMsgDetailed

%s %s metadata to %s using the v%s %s API.

# noSourceTrackingWarning

Starting in December 2025, this command will require source tracking support.
Production orgs and other non-tracking orgs will no longer be supported without explicit metadata specification.
5 changes: 5 additions & 0 deletions messages/retrieve.start.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,8 @@ This command expects the org to support source tracking. If it doesn't, you must
- Use the `--source-dir`, `--manifest` or `--package-name` flags to retrieve metadata in source format.

- Use the `--target-metadata-dir` flag to retrieve metadata in metadata format to a directory.

# noSourceTrackingWarning

Starting in December 2025, this command will require source tracking support.
Production orgs and other non-tracking orgs will no longer be supported without explicit metadata specification.
1 change: 1 addition & 0 deletions src/commands/project/deploy/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
...flags,
'target-org': username,
api,
warnCallback: this.warn.bind(this),
},
project
);
Expand Down
14 changes: 14 additions & 0 deletions src/commands/project/retrieve/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ export default class RetrieveMetadata extends SfCommand<RetrieveResultJson> {
// eslint-disable-next-line complexity
public async run(): Promise<RetrieveResultJson> {
const { flags } = await this.parse(RetrieveMetadata);

// Add warning for non-source-tracking orgs when using default behavior
const isChanges =
!flags['source-dir'] &&
!flags['manifest'] &&
!flags['metadata'] &&
!flags['target-metadata-dir'] &&
!flags['package-name']?.length;

if (isChanges && !(await flags['target-org'].tracksSource())) {
this.warn(messages.getMessage('noSourceTrackingWarning'));
}

let resolvedTargetDir: string | undefined;
if (flags['output-dir']) {
resolvedTargetDir = resolve(flags['output-dir']);
Expand Down Expand Up @@ -518,6 +531,7 @@ const buildRetrieveOptions = async (
output: string | undefined
): Promise<RetrieveSetOptions> => {
const apiVersion = await resolveApiVersion(flags);

return {
usernameOrConnection: flags['target-org'].getUsername() ?? flags['target-org'].getConnection(flags['api-version']),
merge: true,
Expand Down
7 changes: 6 additions & 1 deletion src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ export type DeployOptions = {
'pre-destructive-changes'?: string;
'post-destructive-changes'?: string;
'purge-on-delete'?: boolean;
warnCallback?: (message: string) => void;
};

/** Manifest is expected. You cannot pass metadata and source-dir array--use those to get a manifest */
export type CachedOptions = Omit<DeployOptions, 'wait' | 'metadata' | 'source-dir'> & {
export type CachedOptions = Omit<DeployOptions, 'wait' | 'metadata' | 'source-dir' | 'warnCallback'> & {
wait: number;
/** whether the user passed in anything for metadata-dir (could be a folder, could be a zip) */
isMdapi: boolean;
Expand Down Expand Up @@ -150,6 +151,10 @@ export async function executeDeploy(
subscribeSDREvents: !opts['dry-run'] || !(await org.tracksSource()),
ignoreConflicts: opts['ignore-conflicts'],
});

if (!(await org.tracksSource()) && opts.warnCallback) {
opts.warnCallback(deployMessages.getMessage('noSourceTrackingWarning'));
}
registry = stl.registry;

componentSet = await buildComponentSet(opts, stl);
Expand Down
9 changes: 9 additions & 0 deletions test/nuts/retrieve/noTracking.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ describe('retrieve mdapi format without project', () => {
expect(result?.files).to.not.be.empty;
});

it('should fail when retrieving changes from a non-tracking org', () => {
const result = execCmd<RetrieveResultJson>(`project:retrieve:start -o ${session.hubOrg.username} --json`, {
ensureExitCode: 1,
});

expect(result.jsonOutput?.name).to.equal('noSourceTracking');
expect(result.jsonOutput?.message).to.include('Unable to track changes in your source files');
});

after(async () => {
await session?.clean();
});
Expand Down
Loading