|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
15 | | -import { readdirSync, readFileSync } from "fs"; |
16 | | -import { join } from "path"; |
17 | | -import { existsSync } from "node:fs"; |
18 | 15 | import { execSync } from "node:child_process"; |
| 16 | +import { findWorkspaceVersion } from "./utils.js"; |
19 | 17 |
|
20 | 18 | /* |
21 | 19 | * Publish connect-query |
22 | 20 | * |
23 | 21 | * Recommended procedure: |
24 | | - * 1. Set a new version with `npm run setversion 1.2.3` |
25 | | - * 2. Commit and push all changes to a PR, wait for approval. |
26 | | - * 3. Login with `npm login` |
27 | | - * 4. Publish to npmjs.com with `npm run release` |
28 | | - * 5. Merge PR and create a release on GitHub |
| 22 | + * 1. Trigger the prepare-release workflow with the version you want to release. |
| 23 | + * 2. Reviews release notes in the created PR, wait for approval. |
| 24 | + * 3. Merge the PR. |
29 | 25 | */ |
30 | 26 |
|
31 | 27 | const tag = determinePublishTag(findWorkspaceVersion("packages")); |
@@ -79,35 +75,3 @@ function determinePublishTag(version) { |
79 | 75 | throw new Error(`Unable to determine publish tag from version ${version}`); |
80 | 76 | } |
81 | 77 | } |
82 | | - |
83 | | -/** |
84 | | - * @param {string} packagesDir |
85 | | - * @returns {string} |
86 | | - */ |
87 | | -function findWorkspaceVersion(packagesDir) { |
88 | | - let version = undefined; |
89 | | - for (const entry of readdirSync(packagesDir, { withFileTypes: true })) { |
90 | | - if (!entry.isDirectory()) { |
91 | | - continue; |
92 | | - } |
93 | | - const path = join(packagesDir, entry.name, "package.json"); |
94 | | - if (existsSync(path)) { |
95 | | - const pkg = JSON.parse(readFileSync(path, "utf-8")); |
96 | | - if (pkg.private === true) { |
97 | | - continue; |
98 | | - } |
99 | | - if (!pkg.version) { |
100 | | - throw new Error(`${path} is missing "version"`); |
101 | | - } |
102 | | - if (version === undefined) { |
103 | | - version = pkg.version; |
104 | | - } else if (version !== pkg.version) { |
105 | | - throw new Error(`${path} has unexpected version ${pkg.version}`); |
106 | | - } |
107 | | - } |
108 | | - } |
109 | | - if (version === undefined) { |
110 | | - throw new Error(`unable to find workspace version`); |
111 | | - } |
112 | | - return version; |
113 | | -} |
0 commit comments