Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add skipValidation to dart publishing #544

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,10 @@ For this target to work correctly, either `dart` must be installed on the system

| Option | Description |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dartCliPath` | **optional** Path to the Dart CLI. It must be executable by the calling process. Defaults to `dart`. |
| `packages` | **optional** List of directories to be released, relative to the root. Useful when a single repository contains multiple packages. When skipped, root directory is assumed as the only package. |
| `dartCliPath` | **optional** Path to the Dart CLI. It must be executable by the calling process. Defaults to `dart`. |
| `packages` | **optional** List of directories to be released, relative to the root. Useful when a single repository contains multiple packages. When skipped, root directory is assumed as the only package. |
| `skipValidation` | **optional** Publishes the package without going through validation steps, such as analyzer & dependency checks. This is useful in particular situations when package maintainers know why the validation fails and wish to side step the issue. For example, there may be analyzer issues due to not following the current (latest) dart SDK recommendation because the package needs to maintain the package compatibility with an old SDK version.
This option should be used with caution and only after testing and verifying the reported issue shouldn't affect the package. It is advisable to do an alpha pre-release to further reduce the chance of a potential negative impact. |

**Example**

Expand Down
22 changes: 22 additions & 0 deletions src/targets/__tests__/pubDev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ describe('PubDev target configuration', () => {
PUBDEV_REFRESH_TOKEN: DEFAULT_OPTION_VALUE,
dartCliPath: 'dart',
packages: ['.'],
skipValidation: false,
});
});

Expand All @@ -114,13 +115,15 @@ describe('PubDev target configuration', () => {
dos: undefined,
tres: undefined,
},
skipValidation: true
});

expect(target.pubDevConfig).toStrictEqual({
PUBDEV_ACCESS_TOKEN: 'access',
PUBDEV_REFRESH_TOKEN: 'refresh',
dartCliPath: '/custom/path/dart',
packages: ['uno', 'dos', 'tres'],
skipValidation: true,
});
});
});
Expand Down Expand Up @@ -390,6 +393,25 @@ dependency_overrides:
);
});

test('should call `dart` cli with skip-validation if requesteed', async () => {
const pkg = 'uno';
const target = createPubDevTarget({ skipValidation: true });
await target.publishPackage(TMP_DIR, pkg);

const spawnProcessMock = spawnProcess as jest.MockedFunction<
typeof spawnProcess
>;

expect(spawnProcessMock).toHaveBeenCalledWith(
'dart',
['pub', 'publish', '--force', '--skip-validation'],
{
cwd: `${TMP_DIR}/${pkg}`,
},
{ showStdout: true }
);
});

test('should use custom cli path if provided', async () => {
const dartCliPath = '/custom/path/dart';
const pkg = 'uno';
Expand Down
7 changes: 7 additions & 0 deletions src/targets/pubDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface PubDevTargetOptions {
dartCliPath: string;
/** List of directories to be released. Useful when a single repository contains multiple packages. */
packages: string[];
/** Whether to skip validation */
skipValidation: boolean;
}

/**
Expand Down Expand Up @@ -69,6 +71,7 @@ export class PubDevTarget extends BaseTarget {
? Object.keys(this.config.packages)
: ['.'],
...this.getTargetSecrets(),
skipValidation: this.config.skipValidation ?? false,
};

this.checkRequiredSoftware(config);
Expand Down Expand Up @@ -212,6 +215,10 @@ export class PubDevTarget extends BaseTarget {
}
}

if (this.pubDevConfig.skipValidation) {
args.push('--skip-validation');
}

await spawnProcess(
this.pubDevConfig.dartCliPath,
args,
Expand Down
Loading