Skip to content

Commit

Permalink
feat: add skipValidation to dart publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Jun 26, 2024
1 parent 9a77fb9 commit 869170f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1157,8 +1157,9 @@ 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** Whether to skip validation, which is useful if there are known issues but you need to make a release anyway. |
**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

0 comments on commit 869170f

Please sign in to comment.