release-please 14.11.2 → 14.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ## [14.12.0](https://github.com/googleapis/release-please/compare/v14.11.2...v14.12.0) (2022-10-12)
8
+
9
+
10
+ ### Features
11
+
12
+ * Added expo strategy and updater ([#1646](https://github.com/googleapis/release-please/issues/1646)) ([9cb84cb](https://github.com/googleapis/release-please/commit/9cb84cb18211c61ed94d856b936fff30036b0988))
13
+
7
14
  ## [14.11.2](https://github.com/googleapis/release-please/compare/v14.11.1...v14.11.2) (2022-10-11)
8
15
 
9
16
 
package/README.md CHANGED
@@ -141,6 +141,7 @@ Release Please automates releases for the following flavors of repositories:
141
141
  | `krm-blueprint` | [A kpt package, with 1 or more KRM files and a CHANGELOG.md](https://github.com/GoogleCloudPlatform/blueprints/tree/main/catalog/project) |
142
142
  | `maven` | [Strategy for Maven projects, generates SNAPSHOT version after each release and updates `pom.xml` automatically](docs/java.md) |
143
143
  | `node` | [A Node.js repository, with a package.json and CHANGELOG.md](https://github.com/yargs/yargs) |
144
+ | `expo` | [An Expo based React Native repository, with a package.json, app.json and CHANGELOG.md](https://github.com/yargs/yargs) |
144
145
  | `ocaml` | [An OCaml repository, containing 1 or more opam or esy files and a CHANGELOG.md](https://github.com/grain-lang/binaryen.ml) |
145
146
  | `php` | A repository with a composer.json and a CHANGELOG.md |
146
147
  | `python` | [A Python repository, with a setup.py, setup.cfg, CHANGELOG.md](https://github.com/googleapis/python-storage) and optionally a pyproject.toml and a <project>/\_\_init\_\_.py |
@@ -45,6 +45,7 @@ const helm_1 = require("./strategies/helm");
45
45
  const elixir_1 = require("./strategies/elixir");
46
46
  const dart_1 = require("./strategies/dart");
47
47
  const node_1 = require("./strategies/node");
48
+ const expo_1 = require("./strategies/expo");
48
49
  const always_bump_patch_1 = require("./versioning-strategies/always-bump-patch");
49
50
  const service_pack_1 = require("./versioning-strategies/service-pack");
50
51
  const dependency_manifest_1 = require("./versioning-strategies/dependency-manifest");
@@ -81,6 +82,7 @@ const releasers = {
81
82
  }),
82
83
  'krm-blueprint': options => new krm_blueprint_1.KRMBlueprint(options),
83
84
  node: options => new node_1.Node(options),
85
+ expo: options => new expo_1.Expo(options),
84
86
  ocaml: options => new ocaml_1.OCaml(options),
85
87
  php: options => new php_1.PHP(options),
86
88
  'php-yoshi': options => new php_yoshi_1.PHPYoshi(options),
@@ -0,0 +1,15 @@
1
+ import { BuildUpdatesOptions } from './base';
2
+ import { Node } from './node';
3
+ import { Update } from '../update';
4
+ import { Version } from '../version';
5
+ /**
6
+ * Strategy for building Expo based React Native projects. This strategy extends
7
+ * the Node strategy to additionally update the `app.json` file of a project.
8
+ */
9
+ export declare class Expo extends Node {
10
+ protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
11
+ /**
12
+ * Determine the Expo SDK version by parsing the package.json dependencies.
13
+ */
14
+ getExpoSDKVersion(): Promise<Version>;
15
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ // Copyright 2022 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Expo = void 0;
17
+ const node_1 = require("./node");
18
+ const app_json_1 = require("../updaters/expo/app-json");
19
+ const version_1 = require("../version");
20
+ /**
21
+ * Strategy for building Expo based React Native projects. This strategy extends
22
+ * the Node strategy to additionally update the `app.json` file of a project.
23
+ */
24
+ class Expo extends node_1.Node {
25
+ async buildUpdates(options) {
26
+ const version = options.newVersion;
27
+ const updates = await super.buildUpdates(options);
28
+ const expoSDKVersion = await this.getExpoSDKVersion();
29
+ updates.push({
30
+ path: this.addPath('app.json'),
31
+ createIfMissing: false,
32
+ updater: new app_json_1.AppJson({ version, expoSDKVersion }),
33
+ });
34
+ return updates;
35
+ }
36
+ /**
37
+ * Determine the Expo SDK version by parsing the package.json dependencies.
38
+ */
39
+ async getExpoSDKVersion() {
40
+ var _a, _b, _c, _d;
41
+ const pkgJsonContents = await this.getPkgJsonContents();
42
+ const pkg = JSON.parse(pkgJsonContents.parsedContent);
43
+ return version_1.Version.parse(((_a = pkg.dependencies) === null || _a === void 0 ? void 0 : _a.expo) ||
44
+ ((_b = pkg.devDependencies) === null || _b === void 0 ? void 0 : _b.expo) ||
45
+ ((_c = pkg.peerDependencies) === null || _c === void 0 ? void 0 : _c.expo) ||
46
+ ((_d = pkg.optionalDependencies) === null || _d === void 0 ? void 0 : _d.expo) ||
47
+ '0.0.0');
48
+ }
49
+ }
50
+ exports.Expo = Expo;
51
+ //# sourceMappingURL=expo.js.map
@@ -1,9 +1,10 @@
1
1
  import { BaseStrategy, BuildUpdatesOptions } from './base';
2
2
  import { Update } from '../update';
3
+ import { GitHubFileContents } from '@google-automations/git-file-utils';
3
4
  export declare class Node extends BaseStrategy {
4
5
  private pkgJsonContents?;
5
6
  protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
6
7
  getDefaultPackageName(): Promise<string | undefined>;
7
8
  protected normalizeComponent(component: string | undefined): string;
8
- private getPkgJsonContents;
9
+ protected getPkgJsonContents(): Promise<GitHubFileContents>;
9
10
  }
@@ -0,0 +1,31 @@
1
+ import { Logger } from '../../util/logger';
2
+ import { DefaultUpdater, UpdateOptions } from '../default';
3
+ import { Version } from '../../version';
4
+ export interface AppJson {
5
+ expo: {
6
+ version: string;
7
+ ios?: {
8
+ buildNumber?: string;
9
+ };
10
+ android?: {
11
+ versionCode?: string;
12
+ };
13
+ };
14
+ }
15
+ export interface AppJsonOptions extends UpdateOptions {
16
+ expoSDKVersion: Version;
17
+ }
18
+ /**
19
+ * This updates a React Natve Expo project app.json file's main, ios and android
20
+ * versions. All values except the `android.versionCode` are standard semver
21
+ * version numbers. For the `android.versionCode`, the semver number is used as
22
+ * the basis for the `versionCode`.
23
+ */
24
+ export declare class AppJson extends DefaultUpdater {
25
+ expoSDKVersion: Version;
26
+ constructor(options: AppJsonOptions);
27
+ /**
28
+ * Given initial file contents, return updated contents.
29
+ */
30
+ updateContent(content: string, logger?: Logger): string;
31
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ // Copyright 2022 Google LLC
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.AppJson = void 0;
17
+ const json_stringify_1 = require("../../util/json-stringify");
18
+ const logger_1 = require("../../util/logger");
19
+ const default_1 = require("../default");
20
+ /**
21
+ * This updates a React Natve Expo project app.json file's main, ios and android
22
+ * versions. All values except the `android.versionCode` are standard semver
23
+ * version numbers. For the `android.versionCode`, the semver number is used as
24
+ * the basis for the `versionCode`.
25
+ */
26
+ class AppJson extends default_1.DefaultUpdater {
27
+ constructor(options) {
28
+ super(options);
29
+ this.expoSDKVersion = options.expoSDKVersion;
30
+ }
31
+ /**
32
+ * Given initial file contents, return updated contents.
33
+ */
34
+ updateContent(content, logger = logger_1.logger) {
35
+ var _a, _b;
36
+ const parsed = JSON.parse(content);
37
+ logger.info(`updating Expo version from ${parsed.expo.version} to ${this.version}`);
38
+ parsed.expo.version = this.version.toString();
39
+ if ((_a = parsed.expo.ios) === null || _a === void 0 ? void 0 : _a.buildNumber) {
40
+ logger.info(`updating iOS version from ${parsed.expo.ios.buildNumber} to ${this.version}`);
41
+ parsed.expo.ios.buildNumber = this.version.toString();
42
+ }
43
+ if ((_b = parsed.expo.android) === null || _b === void 0 ? void 0 : _b.versionCode) {
44
+ // Android versionCode
45
+ // https://developer.android.com/studio/publish/versioning#appversioning
46
+ let expoMajorVersion = 0;
47
+ try {
48
+ expoMajorVersion = this.expoSDKVersion.major;
49
+ }
50
+ catch (e) {
51
+ // Rethrow with a nice error message.
52
+ throw new Error('Unable to determine the Expo SDK version for this project. Make sure that the expo package is installed for your project.');
53
+ }
54
+ // Implements the `versionCode` strategy described by Maxi Rosson
55
+ // @see https://medium.com/@maxirosson/versioning-android-apps-d6ec171cfd82
56
+ const versionCode = expoMajorVersion * 10000000 +
57
+ this.version.major * 10000 +
58
+ this.version.minor * 100 +
59
+ this.version.patch;
60
+ logger.info(`updating Android version from ${parsed.expo.android.versionCode} to ${versionCode}`);
61
+ parsed.expo.android.versionCode = versionCode.toString();
62
+ }
63
+ return (0, json_stringify_1.jsonStringify)(parsed, content);
64
+ }
65
+ }
66
+ exports.AppJson = AppJson;
67
+ //# sourceMappingURL=app-json.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-please",
3
- "version": "14.11.2",
3
+ "version": "14.12.0",
4
4
  "description": "generate release PRs based on the conventionalcommits.org spec",
5
5
  "main": "./build/src/index.js",
6
6
  "bin": "./build/src/bin/release-please.js",