Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hborawski committed Mar 18, 2020
1 parent e14aca3 commit 870e991
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 20 deletions.
11 changes: 2 additions & 9 deletions plugins/cocoapods/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cocoapods Plugin

Use auto to version your [Cocoapod](https://cocoapods.org/), and push to your specs repository!
Use `auto` to version your [Cocoapod](https://cocoapods.org/), and push to your specs repository!

## Installation

Expand All @@ -27,10 +27,7 @@ yarn add -D @auto-it/cocoapods
}
]
// other plugins
],
// THIS IS REQUIRED
// Cocoapods cannot work with tags in the format v1.0.0
"noVersionPrefix": true
]
}
```

Expand All @@ -42,10 +39,6 @@ yarn add -D @auto-it/cocoapods

- Your `podspec` file must pass `pod lib lint` in order for publishing to a Specs repository to work.

### Versioning

[Cocoapods](https://cocoapods.org/) does not work with the version prefix of `v1.0.0` so all versions must be the plain semver number (`1.0.0`). You are required to set the `noVersionPrefix` setting in your auto configuration.

### Pushing to the Cocoapods Trunk

If a `specsRepo` is not provided in the plugin options, this plugin will push to the cocoapods trunk repository. This requires that the machine running this has followed the steps for pushing to trunk, the guide for that can be found [here](https://guides.cocoapods.org/making/getting-setup-with-trunk.html#getting-started).
Expand Down
8 changes: 8 additions & 0 deletions plugins/cocoapods/__tests__/cocoapods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ describe('Cocoapods Plugin', () => {
expect(mock).lastCalledWith(expect.any(String), specWithVersion('0.0.2'));
});
});
describe('modifyConfig hook', () => {
test('should set noVersionPrefix to true', () => {
const config = {};
expect(hooks.modifyConfig.call(config as any)).toStrictEqual({
noVersionPrefix: true
});
});
});
describe('getPreviousVersion hook', () => {
test('should get previous version from podspec', async () => {
mockPodspec(specWithVersion('0.0.1'));
Expand Down
3 changes: 3 additions & 0 deletions plugins/cocoapods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
},
"dependencies": {
"@auto-it/core": "link:../../packages/core",
"fp-ts": "^2.5.3",
"io-ts": "^2.1.2",
"semver": "^7.1.3",
"tslib": "1.10.0"
}
}
37 changes: 30 additions & 7 deletions plugins/cocoapods/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { Auto, IPlugin, execPromise } from '@auto-it/core';
import {
Auto,
IPlugin,
execPromise,
validatePluginConfiguration
} from '@auto-it/core';

import { inc, ReleaseType } from 'semver';

import * as t from 'io-ts';

import { getPodspecContents, writePodspecContents } from './utilities';

const logPrefix = '[Cocoapods-Plugin]';
Expand All @@ -16,13 +23,18 @@ const versionRegex = /\.version\s*=\s*['|"](?<version>\d+\.\d+\.\d+)['|"]/;
*/
const logMessage = (msg: string): string => `${logPrefix} ${msg}`;

export interface ICocoapodsPluginOptions {
/** path to podspec file */
podspecPath: string;
const required = t.interface({
/** Relative path to podspec file */
podspecPath: t.string
});

/** the Cocoapods repo to publish to */
specsRepo?: string;
}
const optional = t.partial({
/** The Cocoapods repo to publish to */
specsRepo: t.string
});

const pluginOptions = t.intersection([required, optional]);
export type ICocoapodsPluginOptions = t.TypeOf<typeof pluginOptions>;

/**
* Returns the regex'd version of the podspec file
Expand Down Expand Up @@ -108,6 +120,17 @@ export default class CocoapodsPlugin implements IPlugin {

/** Tap into auto plugin points. */
apply(auto: Auto) {
auto.hooks.validateConfig.tapPromise(this.name, async (name, options) => {
if (name === this.name || name === `@auto-it/${this.name}`) {
return validatePluginConfiguration(this.name, pluginOptions, options);
}
});

auto.hooks.modifyConfig.tap(this.name, (config: any) => {
config.noVersionPrefix = true;
return config;
});

auto.hooks.getPreviousVersion.tapPromise(this.name, async () => {
return auto.prefixRelease(getVersion(this.options.podspecPath));
});
Expand Down
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6944,8 +6944,8 @@ forwarded@~0.1.2:

fp-ts@^2.5.3:
version "2.5.3"
resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-2.5.3.tgz#7f09cc7f3e09623c6ade303d98a2cccdb2cc861f"
integrity sha512-lQd+hahLd8cygNoXbEHDjH/cbF6XVWlEPb8h5GXXlozjCSDxWgclvkpOoTRfBA0P+r69l9VvW1nEsSGIJRQpWw==
resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/fp-ts/-/fp-ts-2.5.3.tgz#7f09cc7f3e09623c6ade303d98a2cccdb2cc861f"
integrity sha1-fwnMfz4JYjxq3jA9mKLMzbLMhh8=

fragment-cache@^0.2.1:
version "0.2.1"
Expand Down Expand Up @@ -8305,8 +8305,8 @@ invert-kv@^1.0.0:

io-ts@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-2.1.2.tgz#8ea4439c902c3d15cda343900bed7ee5a9977f42"
integrity sha512-whVRGaNBZSrkPrg1y+sSy/kv/fDjweQPP1UCLhKwJUHWGD6rFgbZ44FBF98JlY/FFzTA0MkhGeHWZ/aFhF42eA==
resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/io-ts/-/io-ts-2.1.2.tgz#8ea4439c902c3d15cda343900bed7ee5a9977f42"
integrity sha1-jqRDnJAsPRXNo0OQC+1+5amXf0I=

ip-regex@^1.0.1:
version "1.0.3"
Expand Down Expand Up @@ -13382,6 +13382,11 @@ semver@^7.0.0, semver@^7.1.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.3.tgz#e4345ce73071c53f336445cfc19efb1c311df2a6"
integrity sha512-ekM0zfiA9SCBlsKa2X1hxyxiI4L3B6EbVJkkdgQXnSEEaHlGdvyodMruTiulSRWMMB4NeIuYNMC9rTKTz97GxA==

semver@^7.1.3:
version "7.1.3"
resolved "https://registry.npmjs.intuit.com:443/artifactory/api/npm/npm-intuit/semver/-/semver-7.1.3.tgz#e4345ce73071c53f336445cfc19efb1c311df2a6"
integrity sha1-5DRc5zBxxT8zZEXPwZ77HDEd8qY=

semver@~5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
Expand Down

0 comments on commit 870e991

Please sign in to comment.