semantic-release-pub 0.7.0 → 0.8.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 zeshuaro
3
+ Copyright (c) 2023-2024 zeshuaro
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/prepare.js CHANGED
@@ -1,13 +1,10 @@
1
- import { readFileSync, writeFileSync } from "fs";
2
- import { parse } from "yaml";
3
1
  import SemanticReleaseError from "@semantic-release/error";
4
- import { Pubspec } from "./schemas.js";
5
- import { getConfig } from "./utils.js";
6
- const PUBSPEC_PATH = "pubspec.yaml";
2
+ import { writeFileSync } from "fs";
3
+ import { PUBSPEC_PATH, getConfig, getPubspecFromString, getPubspecString, } from "./utils.js";
7
4
  export const prepare = async (pluginConfig, { nextRelease: { version }, logger }) => {
8
5
  const { updateBuildNumber } = getConfig(pluginConfig);
9
- const data = readFileSync(PUBSPEC_PATH, "utf-8");
10
- const pubspec = Pubspec.parse(parse(data));
6
+ const data = getPubspecString();
7
+ const pubspec = getPubspecFromString(data);
11
8
  const pubspecVersionEscaped = pubspec.version.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&");
12
9
  let nextVersion = version;
13
10
  if (updateBuildNumber) {
package/dist/publish.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  import { PublishContext } from "semantic-release";
2
2
  import { PluginConfig } from "./types.js";
3
- export declare const publish: (pluginConfig: PluginConfig, { nextRelease: { version }, logger }: PublishContext) => Promise<void>;
3
+ export declare const publish: (pluginConfig: PluginConfig, { nextRelease: { version }, logger }: PublishContext) => Promise<{
4
+ name: string;
5
+ url: string;
6
+ }>;
package/dist/publish.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { execa } from "execa";
2
- import { getConfig, getGoogleIdentityToken } from "./utils.js";
2
+ import { getConfig, getGoogleIdentityToken, getPubspec } from "./utils.js";
3
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);
@@ -7,12 +7,17 @@ export const publish = async (pluginConfig, { nextRelease: { version }, logger }
7
7
  logger.log(`Skipping publishing to pub.dev as publishPub is ${publishPub}`);
8
8
  return;
9
9
  }
10
+ const pubspec = getPubspec();
10
11
  const { GOOGLE_SERVICE_ACCOUNT_KEY } = process.env;
11
12
  const idToken = await getGoogleIdentityToken(GOOGLE_SERVICE_ACCOUNT_KEY);
12
13
  await setPubToken(cli, idToken);
13
14
  logger.log(`Publishing version ${version} to pub.dev`);
14
15
  await execa(cli, ["pub", "publish", "--force"]);
15
- logger.log("Published package");
16
+ logger.log(`Published ${pubspec.name}@${version} on pub.dev`);
17
+ return {
18
+ name: "pub.dev package",
19
+ url: `https://pub.dev/packages/${pubspec.name}/versions/${version}`,
20
+ };
16
21
  };
17
22
  const setPubToken = async (cli, idToken) => {
18
23
  process.env[SEMANTIC_RELEASE_PUB_TOKEN] = idToken;
package/dist/schemas.d.ts CHANGED
@@ -11,10 +11,13 @@ export declare const ServiceAccount: z.ZodObject<{
11
11
  }>;
12
12
  export type ServiceAccount = z.infer<typeof ServiceAccount>;
13
13
  export declare const Pubspec: z.ZodObject<{
14
+ name: z.ZodString;
14
15
  version: z.ZodString;
15
16
  }, "strip", z.ZodTypeAny, {
17
+ name?: string;
16
18
  version?: string;
17
19
  }, {
20
+ name?: string;
18
21
  version?: string;
19
22
  }>;
20
23
  export type Pubspec = z.infer<typeof Pubspec>;
package/dist/schemas.js CHANGED
@@ -3,4 +3,4 @@ export const ServiceAccount = z.object({
3
3
  client_email: z.string(),
4
4
  private_key: z.string(),
5
5
  });
6
- export const Pubspec = z.object({ version: z.string() });
6
+ export const Pubspec = z.object({ name: z.string(), version: z.string() });
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,13 @@
1
1
  import { PluginConfig } from "./types.js";
2
+ export declare const PUBSPEC_PATH = "pubspec.yaml";
2
3
  export declare const getConfig: (config: PluginConfig) => PluginConfig;
3
4
  export declare const getGoogleIdentityToken: (serviceAccountStr: string) => Promise<string>;
5
+ export declare const getPubspecString: () => string;
6
+ export declare const getPubspecFromString: (data: string) => {
7
+ name?: string;
8
+ version?: string;
9
+ };
10
+ export declare const getPubspec: () => {
11
+ name?: string;
12
+ version?: string;
13
+ };
package/dist/utils.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import SemanticReleaseError from "@semantic-release/error";
2
+ import { readFileSync } from "fs";
2
3
  import { JWT } from "google-auth-library";
3
- import { ServiceAccount } from "./schemas.js";
4
+ import { parse } from "yaml";
5
+ import { Pubspec, ServiceAccount } from "./schemas.js";
6
+ export const PUBSPEC_PATH = "pubspec.yaml";
4
7
  const DEFAULT_CONFIG = {
5
8
  cli: "dart",
6
9
  publishPub: true,
@@ -19,6 +22,16 @@ export const getGoogleIdentityToken = async (serviceAccountStr) => {
19
22
  }
20
23
  return creds.id_token;
21
24
  };
25
+ export const getPubspecString = () => {
26
+ return readFileSync(PUBSPEC_PATH, "utf-8");
27
+ };
28
+ export const getPubspecFromString = (data) => {
29
+ return Pubspec.parse(parse(data));
30
+ };
31
+ export const getPubspec = () => {
32
+ const data = getPubspecString();
33
+ return getPubspecFromString(data);
34
+ };
22
35
  const getServiceAccount = (serviceAccountStr) => {
23
36
  try {
24
37
  return ServiceAccount.parse(JSON.parse(serviceAccountStr));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantic-release-pub",
3
- "version": "0.7.0",
3
+ "version": "0.8.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",
@@ -29,12 +29,12 @@
29
29
  "format": "eslint --ext .ts --fix src tests && prettier --write src/**/*.ts tests/**/*.ts"
30
30
  },
31
31
  "engines": {
32
- "node": ">=20.10.0"
32
+ "node": ">=20.11.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@semantic-release/error": "^4.0.0",
36
36
  "execa": "^8.0.1",
37
- "google-auth-library": "^9.4.1",
37
+ "google-auth-library": "^9.4.2",
38
38
  "yaml": "^2.3.4",
39
39
  "zod": "^3.22.4"
40
40
  },
@@ -45,9 +45,9 @@
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.17.0",
49
- "@typescript-eslint/parser": "6.17.0",
50
- "@vitest/coverage-v8": "1.1.1",
48
+ "@typescript-eslint/eslint-plugin": "6.19.0",
49
+ "@typescript-eslint/parser": "6.19.0",
50
+ "@vitest/coverage-v8": "1.2.1",
51
51
  "common-tags": "1.8.2",
52
52
  "conventional-changelog-conventionalcommits": "7.0.2",
53
53
  "eslint": "8.56.0",
@@ -55,12 +55,12 @@
55
55
  "eslint-config-semistandard": "17.0.0",
56
56
  "eslint-config-standard": "17.1.0",
57
57
  "eslint-plugin-import": "2.29.1",
58
- "eslint-plugin-n": "16.6.1",
58
+ "eslint-plugin-n": "16.6.2",
59
59
  "eslint-plugin-promise": "6.1.1",
60
- "prettier": "3.1.1",
61
- "semantic-release": "22.0.12",
60
+ "prettier": "3.2.4",
61
+ "semantic-release": "23.0.0",
62
62
  "typescript": "5.3.3",
63
- "vitest": "1.1.1",
63
+ "vitest": "1.2.1",
64
64
  "vitest-mock-extended": "1.3.1"
65
65
  }
66
66
  }