semantic-release-pub 0.6.2 → 0.7.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/README.md +9 -6
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/prepare.d.ts +3 -3
- package/dist/prepare.js +21 -9
- package/dist/publish.d.ts +2 -2
- package/dist/publish.js +10 -10
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +2 -2
- package/dist/types.d.ts +2 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +8 -7
- package/dist/verifyConditions.d.ts +2 -2
- package/dist/verifyConditions.js +4 -4
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/semantic-release-pub)
|
|
4
4
|
[](https://github.com/zeshuaro/semantic-release-pub/blob/main/LICENSE)
|
|
5
5
|
[](https://github.com/zeshuaro/semantic-release-pub/actions/workflows/github-actions.yml)
|
|
6
|
-
[](https://codecov.io/github/zeshuaro/semantic-release-pub)
|
|
7
|
+
[](https://app.codacy.com/gh/zeshuaro/semantic-release-pub/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
|
8
8
|
[](https://github.com/prettier/prettier)
|
|
9
9
|
|
|
10
10
|
[](https://github.com/sponsors/zeshuaro)
|
|
@@ -92,10 +92,11 @@ The following instructions are referenced from the [documentation](https://dart.
|
|
|
92
92
|
|
|
93
93
|
### Options
|
|
94
94
|
|
|
95
|
-
| Option
|
|
96
|
-
|
|
|
97
|
-
| `cli`
|
|
98
|
-
| `publishPub`
|
|
95
|
+
| Option | Description | Default |
|
|
96
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
97
|
+
| `cli` | The `dart` or `flutter` CLI to use to publish the package to the registry. | `dart` |
|
|
98
|
+
| `publishPub` | Whether to publish the package to the registry. If set to `false`, the `pubspec.yaml` version will still be updated. | `true` |
|
|
99
|
+
| `updateBuildNumber` | Whether to write build number for every newly bumped version in `pubspec.yaml`. Note that the build number will always be increased by one. Learn more on [Flutter docs](https://docs.flutter.dev/deployment/android#updating-the-apps-version-number). | `false` |
|
|
99
100
|
|
|
100
101
|
### Examples
|
|
101
102
|
|
|
@@ -115,3 +116,5 @@ The following instructions are referenced from the [documentation](https://dart.
|
|
|
115
116
|
]
|
|
116
117
|
}
|
|
117
118
|
```
|
|
119
|
+
|
|
120
|
+
See [here](https://github.com/zeshuaro/firestore_cache/pull/162) for a sample pull request utilising this plugin and `semantic-release` to publish a Flutter package.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { verifyConditions } from
|
|
2
|
-
export { PluginConfig } from
|
|
3
|
-
export { prepare } from
|
|
4
|
-
export { publish } from
|
|
1
|
+
export { verifyConditions } from "./verifyConditions.js";
|
|
2
|
+
export { PluginConfig } from "./types.js";
|
|
3
|
+
export { prepare } from "./prepare.js";
|
|
4
|
+
export { publish } from "./publish.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { verifyConditions } from
|
|
2
|
-
export { prepare } from
|
|
3
|
-
export { publish } from
|
|
1
|
+
export { verifyConditions } from "./verifyConditions.js";
|
|
2
|
+
export { prepare } from "./prepare.js";
|
|
3
|
+
export { publish } from "./publish.js";
|
package/dist/prepare.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PrepareContext } from
|
|
2
|
-
import { PluginConfig } from
|
|
3
|
-
export declare const prepare: (
|
|
1
|
+
import { PrepareContext } from "semantic-release";
|
|
2
|
+
import { PluginConfig } from "./types.js";
|
|
3
|
+
export declare const prepare: (pluginConfig: PluginConfig, { nextRelease: { version }, logger }: PrepareContext) => Promise<void>;
|
package/dist/prepare.js
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from
|
|
2
|
-
import { parse } from
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
2
|
+
import { parse } from "yaml";
|
|
3
|
+
import SemanticReleaseError from "@semantic-release/error";
|
|
4
|
+
import { Pubspec } from "./schemas.js";
|
|
5
|
+
import { getConfig } from "./utils.js";
|
|
6
|
+
const PUBSPEC_PATH = "pubspec.yaml";
|
|
7
|
+
export const prepare = async (pluginConfig, { nextRelease: { version }, logger }) => {
|
|
8
|
+
const { updateBuildNumber } = getConfig(pluginConfig);
|
|
9
|
+
const data = readFileSync(PUBSPEC_PATH, "utf-8");
|
|
7
10
|
const pubspec = Pubspec.parse(parse(data));
|
|
8
|
-
const pubspecVersionEscaped = pubspec.version.replace(/[/\-\\^$*+?.()|[\]{}]/g,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
const pubspecVersionEscaped = pubspec.version.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
12
|
+
let nextVersion = version;
|
|
13
|
+
if (updateBuildNumber) {
|
|
14
|
+
const parts = pubspec.version.split("+");
|
|
15
|
+
const buildNumber = parts.length > 1 ? Number(parts[1]) : 0;
|
|
16
|
+
if (isNaN(buildNumber)) {
|
|
17
|
+
throw new SemanticReleaseError(`Invalid build number: ${buildNumber} in ${pubspec.version}`);
|
|
18
|
+
}
|
|
19
|
+
nextVersion = `${version}+${buildNumber + 1}`;
|
|
20
|
+
}
|
|
21
|
+
const newData = data.replace(new RegExp(`version:[ \t]+${pubspecVersionEscaped}`), `version: ${nextVersion}`);
|
|
22
|
+
logger.log(`Writing version ${nextVersion} to ${PUBSPEC_PATH}`);
|
|
11
23
|
writeFileSync(PUBSPEC_PATH, newData);
|
|
12
24
|
};
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PublishContext } from
|
|
2
|
-
import { PluginConfig } from
|
|
1
|
+
import { PublishContext } from "semantic-release";
|
|
2
|
+
import { PluginConfig } from "./types.js";
|
|
3
3
|
export declare const publish: (pluginConfig: PluginConfig, { nextRelease: { version }, logger }: PublishContext) => Promise<void>;
|
package/dist/publish.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { execa } from
|
|
2
|
-
import { getConfig, getGoogleIdentityToken } from
|
|
3
|
-
const SEMANTIC_RELEASE_PUB_TOKEN =
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
import { getConfig, getGoogleIdentityToken } from "./utils.js";
|
|
3
|
+
const SEMANTIC_RELEASE_PUB_TOKEN = "SEMANTIC_RELEASE_PUB_TOKEN";
|
|
4
4
|
export const publish = async (pluginConfig, { nextRelease: { version }, logger }) => {
|
|
5
5
|
const { cli, publishPub } = getConfig(pluginConfig);
|
|
6
6
|
if (!publishPub) {
|
|
@@ -11,16 +11,16 @@ export const publish = async (pluginConfig, { nextRelease: { version }, logger }
|
|
|
11
11
|
const idToken = await getGoogleIdentityToken(GOOGLE_SERVICE_ACCOUNT_KEY);
|
|
12
12
|
await setPubToken(cli, idToken);
|
|
13
13
|
logger.log(`Publishing version ${version} to pub.dev`);
|
|
14
|
-
await execa(cli, [
|
|
15
|
-
logger.log(
|
|
14
|
+
await execa(cli, ["pub", "publish", "--force"]);
|
|
15
|
+
logger.log("Published package");
|
|
16
16
|
};
|
|
17
17
|
const setPubToken = async (cli, idToken) => {
|
|
18
18
|
process.env[SEMANTIC_RELEASE_PUB_TOKEN] = idToken;
|
|
19
19
|
await execa(cli, [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`--env-var=${SEMANTIC_RELEASE_PUB_TOKEN}
|
|
20
|
+
"pub",
|
|
21
|
+
"token",
|
|
22
|
+
"add",
|
|
23
|
+
"https://pub.dev",
|
|
24
|
+
`--env-var=${SEMANTIC_RELEASE_PUB_TOKEN}`,
|
|
25
25
|
]);
|
|
26
26
|
};
|
package/dist/schemas.d.ts
CHANGED
package/dist/schemas.js
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import SemanticReleaseError from
|
|
2
|
-
import { JWT } from
|
|
3
|
-
import { ServiceAccount } from
|
|
1
|
+
import SemanticReleaseError from "@semantic-release/error";
|
|
2
|
+
import { JWT } from "google-auth-library";
|
|
3
|
+
import { ServiceAccount } from "./schemas.js";
|
|
4
4
|
const DEFAULT_CONFIG = {
|
|
5
|
-
cli:
|
|
6
|
-
publishPub: true
|
|
5
|
+
cli: "dart",
|
|
6
|
+
publishPub: true,
|
|
7
|
+
updateBuildNumber: false,
|
|
7
8
|
};
|
|
8
|
-
const PUB_DEV_AUDIENCE =
|
|
9
|
+
const PUB_DEV_AUDIENCE = "https://pub.dev";
|
|
9
10
|
export const getConfig = (config) => {
|
|
10
11
|
return { ...DEFAULT_CONFIG, ...config };
|
|
11
12
|
};
|
|
@@ -14,7 +15,7 @@ export const getGoogleIdentityToken = async (serviceAccountStr) => {
|
|
|
14
15
|
const jwtClient = new JWT(serviceAccountJson.client_email, undefined, serviceAccountJson.private_key, PUB_DEV_AUDIENCE);
|
|
15
16
|
const creds = await jwtClient.authorize();
|
|
16
17
|
if (!creds.id_token) {
|
|
17
|
-
throw new SemanticReleaseError(
|
|
18
|
+
throw new SemanticReleaseError("Failed to retrieve identity token from Google");
|
|
18
19
|
}
|
|
19
20
|
return creds.id_token;
|
|
20
21
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { VerifyConditionsContext } from
|
|
2
|
-
import { PluginConfig } from
|
|
1
|
+
import { VerifyConditionsContext } from "semantic-release";
|
|
2
|
+
import { PluginConfig } from "./types.js";
|
|
3
3
|
export declare const verifyConditions: (pluginConfig: PluginConfig, { logger }: VerifyConditionsContext) => Promise<void>;
|
package/dist/verifyConditions.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import SemanticReleaseError from
|
|
2
|
-
import { execa } from
|
|
3
|
-
import { getConfig, getGoogleIdentityToken } from
|
|
1
|
+
import SemanticReleaseError from "@semantic-release/error";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import { getConfig, getGoogleIdentityToken } from "./utils.js";
|
|
4
4
|
export const verifyConditions = async (pluginConfig, { logger }) => {
|
|
5
5
|
const { cli, publishPub } = getConfig(pluginConfig);
|
|
6
6
|
const { GOOGLE_SERVICE_ACCOUNT_KEY } = process.env;
|
|
7
7
|
if (publishPub) {
|
|
8
8
|
if (!GOOGLE_SERVICE_ACCOUNT_KEY) {
|
|
9
|
-
throw new SemanticReleaseError(
|
|
9
|
+
throw new SemanticReleaseError("Environment variable not found: GOOGLE_SERVICE_ACCOUNT_KEY");
|
|
10
10
|
}
|
|
11
11
|
await getGoogleIdentityToken(GOOGLE_SERVICE_ACCOUNT_KEY);
|
|
12
12
|
await verifyCommand(cli);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release-pub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "semantic-release plugin to publish a Dart or Flutter package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "zeshuaro@gmail.com",
|
|
@@ -45,21 +45,22 @@
|
|
|
45
45
|
"@types/semantic-release": "20.0.6",
|
|
46
46
|
"@types/semantic-release__error": "3.0.3",
|
|
47
47
|
"@types/signale": "1.4.7",
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
49
|
-
"@typescript-eslint/parser": "6.
|
|
50
|
-
"@vitest/coverage-v8": "1.
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "6.17.0",
|
|
49
|
+
"@typescript-eslint/parser": "6.17.0",
|
|
50
|
+
"@vitest/coverage-v8": "1.1.1",
|
|
51
51
|
"common-tags": "1.8.2",
|
|
52
52
|
"conventional-changelog-conventionalcommits": "7.0.2",
|
|
53
|
-
"eslint": "8.
|
|
53
|
+
"eslint": "8.56.0",
|
|
54
|
+
"eslint-config-prettier": "^9.1.0",
|
|
54
55
|
"eslint-config-semistandard": "17.0.0",
|
|
55
56
|
"eslint-config-standard": "17.1.0",
|
|
56
|
-
"eslint-plugin-import": "2.29.
|
|
57
|
-
"eslint-plugin-n": "16.
|
|
57
|
+
"eslint-plugin-import": "2.29.1",
|
|
58
|
+
"eslint-plugin-n": "16.6.1",
|
|
58
59
|
"eslint-plugin-promise": "6.1.1",
|
|
59
|
-
"prettier": "3.1.
|
|
60
|
-
"semantic-release": "22.0.
|
|
60
|
+
"prettier": "3.1.1",
|
|
61
|
+
"semantic-release": "22.0.12",
|
|
61
62
|
"typescript": "5.3.3",
|
|
62
|
-
"vitest": "1.
|
|
63
|
+
"vitest": "1.1.1",
|
|
63
64
|
"vitest-mock-extended": "1.3.1"
|
|
64
65
|
}
|
|
65
66
|
}
|