pressship 0.1.3 → 0.1.4
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 +266 -357
- package/assets/logo-new.png +0 -0
- package/assets/pressship-dark.png +0 -0
- package/assets/pressship-square-dark.png +0 -0
- package/assets/pressship-square.png +0 -0
- package/assets/pressship-symbol-dark.png +0 -0
- package/assets/pressship-symbol.png +0 -0
- package/assets/pressship-wordmark-dark.png +0 -0
- package/assets/pressship-wordmark.png +0 -0
- package/assets/pressship.png +0 -0
- package/dist/cli.js +22 -2
- package/dist/cli.js.map +1 -1
- package/dist/package/ignore.js +2 -0
- package/dist/package/ignore.js.map +1 -1
- package/dist/plugin/list.d.ts +24 -0
- package/dist/plugin/list.js +174 -0
- package/dist/plugin/list.js.map +1 -0
- package/dist/svn/credentials.d.ts +9 -0
- package/dist/svn/credentials.js +94 -0
- package/dist/svn/credentials.js.map +1 -0
- package/dist/svn/get.d.ts +45 -0
- package/dist/svn/get.js +139 -0
- package/dist/svn/get.js.map +1 -0
- package/dist/svn/release.d.ts +1 -0
- package/dist/svn/release.js +90 -13
- package/dist/svn/release.js.map +1 -1
- package/dist/svn/subversion.d.ts +18 -0
- package/dist/svn/subversion.js +171 -0
- package/dist/svn/subversion.js.map +1 -0
- package/dist/utils/paths.d.ts +1 -0
- package/dist/utils/paths.js +3 -0
- package/dist/utils/paths.js.map +1 -1
- package/dist/wordpress-org/publish.d.ts +1 -0
- package/dist/wordpress-org/publish.js +4 -2
- package/dist/wordpress-org/publish.js.map +1 -1
- package/package.json +2 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/pressship.png
CHANGED
|
Binary file
|
package/dist/cli.js
CHANGED
|
@@ -7,9 +7,11 @@ import { pack } from "./package/pack.js";
|
|
|
7
7
|
import { publish } from "./wordpress-org/publish.js";
|
|
8
8
|
import { submit } from "./wordpress-org/submit.js";
|
|
9
9
|
import { status } from "./wordpress-org/state.js";
|
|
10
|
+
import { getPlugin } from "./svn/get.js";
|
|
10
11
|
import { release } from "./svn/release.js";
|
|
11
12
|
import { demo } from "./plugin/demo.js";
|
|
12
13
|
import { info } from "./plugin/info.js";
|
|
14
|
+
import { listPlugins } from "./plugin/list.js";
|
|
13
15
|
import { version } from "./plugin/version.js";
|
|
14
16
|
const program = new Command();
|
|
15
17
|
program
|
|
@@ -45,6 +47,22 @@ program
|
|
|
45
47
|
.argument("[slug-or-path]", "Local plugin path, WordPress.org plugin slug, or plugin URL")
|
|
46
48
|
.option("--json", "Print plugin info as JSON")
|
|
47
49
|
.action((target, options) => run(() => info(target, options))());
|
|
50
|
+
program
|
|
51
|
+
.command("ls")
|
|
52
|
+
.alias("list")
|
|
53
|
+
.description("List WordPress.org plugins for the saved account or a public profile username.")
|
|
54
|
+
.argument("[username]", "WordPress.org username. Defaults to the saved login user.")
|
|
55
|
+
.option("--public", "Use the public author archive even for the saved login user")
|
|
56
|
+
.option("--json", "Print plugin list as JSON")
|
|
57
|
+
.action((username, options) => run(() => listPlugins(username, options))());
|
|
58
|
+
program
|
|
59
|
+
.command("get")
|
|
60
|
+
.description("Checkout or update a WordPress.org plugin SVN repository.")
|
|
61
|
+
.argument("<slug>", "WordPress.org plugin slug or plugin URL")
|
|
62
|
+
.argument("[path]", "Destination directory. Defaults to ./<slug>.")
|
|
63
|
+
.option("--json", "Print checkout details as JSON")
|
|
64
|
+
.option("--no-install-svn", "Do not try to install Subversion automatically when svn is missing")
|
|
65
|
+
.action((slug, destination, options) => run(() => getPlugin(slug, destination, options))());
|
|
48
66
|
program
|
|
49
67
|
.command("publish")
|
|
50
68
|
.description("Submit for review or release an approved plugin, similar to npm publish.")
|
|
@@ -59,8 +77,9 @@ program
|
|
|
59
77
|
.option("--slug <slug>", "Approved WordPress.org plugin slug for release detection or release")
|
|
60
78
|
.option("--version <version>", "Version tag to create for release")
|
|
61
79
|
.option("--svn-dir <path>", "Local SVN working copy directory for release")
|
|
62
|
-
.option("--username <username>", "WordPress.org SVN username for release")
|
|
80
|
+
.option("--username <username>", "WordPress.org SVN username for release; defaults to the saved login user")
|
|
63
81
|
.option("-m, --message <message>", "SVN commit message for release")
|
|
82
|
+
.option("--no-install-svn", "Do not try to install Subversion automatically when svn is missing")
|
|
64
83
|
.option("--ignore <glob>", "Ignore files in the package; repeat for multiple globs", collectValues, [])
|
|
65
84
|
.option("-y, --yes", "Continue without interactive confirmations where possible")
|
|
66
85
|
.action((pluginPath, options) => run(() => publish(pluginPath, options))());
|
|
@@ -106,11 +125,12 @@ program
|
|
|
106
125
|
.option("--slug <slug>", "Approved WordPress.org plugin slug")
|
|
107
126
|
.option("--version <version>", "Version tag to create")
|
|
108
127
|
.option("--svn-dir <path>", "Local SVN working copy directory")
|
|
109
|
-
.option("--username <username>", "WordPress.org SVN username")
|
|
128
|
+
.option("--username <username>", "WordPress.org SVN username; defaults to the saved login user")
|
|
110
129
|
.option("-m, --message <message>", "SVN commit message")
|
|
111
130
|
.option("--ignore <glob>", "Ignore files in the SVN release; repeat for multiple globs", collectValues, [])
|
|
112
131
|
.option("--dry-run", "Print the SVN command plan without changing SVN")
|
|
113
132
|
.option("-y, --yes", "Commit without the final confirmation prompt")
|
|
133
|
+
.option("--no-install-svn", "Do not try to install Subversion automatically when svn is missing")
|
|
114
134
|
.action((pluginPath, options) => run(() => release(pluginPath, options))());
|
|
115
135
|
await program.parseAsync(process.argv);
|
|
116
136
|
function run(action) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAsB,M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E1D,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,MAAM,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,MAAM,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,CAAC,YAAoB,EAAW,EAAE;QACvC,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1D,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const listOptionsSchema: z.ZodObject<{
|
|
3
|
+
json: z.ZodDefault<z.ZodBoolean>;
|
|
4
|
+
public: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export type ListOptions = z.input<typeof listOptionsSchema>;
|
|
7
|
+
export type ListedPlugin = {
|
|
8
|
+
name: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
url: string;
|
|
11
|
+
author?: string;
|
|
12
|
+
activeInstalls?: string;
|
|
13
|
+
testedWith?: string;
|
|
14
|
+
roles: Array<"contributor" | "committer">;
|
|
15
|
+
};
|
|
16
|
+
export type PluginListResult = {
|
|
17
|
+
username: string;
|
|
18
|
+
source: "public" | "logged-in";
|
|
19
|
+
plugins: ListedPlugin[];
|
|
20
|
+
};
|
|
21
|
+
export declare function listPlugins(username: string | undefined, rawOptions?: ListOptions): Promise<void>;
|
|
22
|
+
export declare function getPluginList(username: string | undefined, options?: ListOptions): Promise<PluginListResult>;
|
|
23
|
+
export declare function parsePluginArchiveHtml(html: string, username: string): ListedPlugin[];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { hasSavedSession, openBrowserSession } from "../auth/session.js";
|
|
3
|
+
import { getWordPressOrgAccount } from "../auth/whoami.js";
|
|
4
|
+
import { ui } from "../ui.js";
|
|
5
|
+
const listOptionsSchema = z.object({
|
|
6
|
+
json: z.boolean().default(false),
|
|
7
|
+
public: z.boolean().default(false)
|
|
8
|
+
});
|
|
9
|
+
export async function listPlugins(username, rawOptions = {}) {
|
|
10
|
+
const options = listOptionsSchema.parse(rawOptions);
|
|
11
|
+
const result = options.json
|
|
12
|
+
? await getPluginList(username, options)
|
|
13
|
+
: await ui.task("Listing WordPress.org plugins", () => getPluginList(username, options), (value) => `Found ${value.plugins.length} plugin${value.plugins.length === 1 ? "" : "s"} for ${value.username}`);
|
|
14
|
+
if (options.json) {
|
|
15
|
+
console.log(JSON.stringify(result, null, 2));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
printPluginList(result);
|
|
19
|
+
}
|
|
20
|
+
export async function getPluginList(username, options = {}) {
|
|
21
|
+
const resolvedUsername = username ?? (await inferCurrentUsername());
|
|
22
|
+
const canUseLoggedInArchive = !options.public && (await shouldUseLoggedInArchive(resolvedUsername, username));
|
|
23
|
+
const plugins = canUseLoggedInArchive
|
|
24
|
+
? await fetchLoggedInAuthorArchive(resolvedUsername)
|
|
25
|
+
: await fetchPublicAuthorArchive(resolvedUsername);
|
|
26
|
+
return {
|
|
27
|
+
username: resolvedUsername,
|
|
28
|
+
source: canUseLoggedInArchive ? "logged-in" : "public",
|
|
29
|
+
plugins: dedupeListedPlugins(plugins)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function parsePluginArchiveHtml(html, username) {
|
|
33
|
+
const cards = html.match(/<li\b[^>]*\btype-plugin\b[\s\S]*?<\/li>/g) ?? [];
|
|
34
|
+
return cards.map((card) => parsePluginCard(card, username)).filter((plugin) => Boolean(plugin));
|
|
35
|
+
}
|
|
36
|
+
async function inferCurrentUsername() {
|
|
37
|
+
if (!(await hasSavedSession())) {
|
|
38
|
+
throw new Error("No username passed and no WordPress.org browser session found. Run `pressship login` or pass a username.");
|
|
39
|
+
}
|
|
40
|
+
return (await getWordPressOrgAccount()).username;
|
|
41
|
+
}
|
|
42
|
+
async function shouldUseLoggedInArchive(resolvedUsername, originalUsername) {
|
|
43
|
+
if (!(await hasSavedSession())) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (!originalUsername) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const account = await getWordPressOrgAccount();
|
|
51
|
+
return account.username.toLowerCase() === resolvedUsername.toLowerCase();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function fetchPublicAuthorArchive(username) {
|
|
58
|
+
const plugins = [];
|
|
59
|
+
let nextUrl = getAuthorArchiveUrl(username);
|
|
60
|
+
for (let page = 0; nextUrl && page < 20; page += 1) {
|
|
61
|
+
const response = await fetch(nextUrl);
|
|
62
|
+
const html = await response.text();
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
throw new Error(`Could not fetch WordPress.org plugin list for ${username}.`);
|
|
65
|
+
}
|
|
66
|
+
plugins.push(...parsePluginArchiveHtml(html, username));
|
|
67
|
+
nextUrl = getNextArchivePageUrl(html);
|
|
68
|
+
}
|
|
69
|
+
return plugins;
|
|
70
|
+
}
|
|
71
|
+
async function fetchLoggedInAuthorArchive(username) {
|
|
72
|
+
const { context, page } = await openBrowserSession({ headless: true });
|
|
73
|
+
const plugins = [];
|
|
74
|
+
let nextUrl = getAuthorArchiveUrl(username);
|
|
75
|
+
try {
|
|
76
|
+
for (let pageCount = 0; nextUrl && pageCount < 20; pageCount += 1) {
|
|
77
|
+
await page.goto(nextUrl, { waitUntil: "domcontentloaded" });
|
|
78
|
+
const html = await page.content();
|
|
79
|
+
plugins.push(...parsePluginArchiveHtml(html, username));
|
|
80
|
+
nextUrl = getNextArchivePageUrl(html);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
await context.browser()?.close();
|
|
85
|
+
}
|
|
86
|
+
return plugins;
|
|
87
|
+
}
|
|
88
|
+
function parsePluginCard(card, username) {
|
|
89
|
+
const linkMatch = card.match(/<h3[^>]*class=["'][^"']*entry-title[^"']*["'][\s\S]*?<a[^>]+href=["']([^"']*\/plugins\/([^/"']+)\/)["'][^>]*>([\s\S]*?)<\/a>/i);
|
|
90
|
+
if (!linkMatch) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const classValue = card.match(/<li\b[^>]*class=["']([^"']+)["']/i)?.[1] ?? "";
|
|
94
|
+
const normalizedUsername = username.toLowerCase();
|
|
95
|
+
const roles = [];
|
|
96
|
+
if (classValue.toLowerCase().split(/\s+/).includes(`plugin_contributors-${normalizedUsername}`)) {
|
|
97
|
+
roles.push("contributor");
|
|
98
|
+
}
|
|
99
|
+
if (classValue.toLowerCase().split(/\s+/).includes(`plugin_committers-${normalizedUsername}`)) {
|
|
100
|
+
roles.push("committer");
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
name: cleanText(linkMatch[3]) ?? linkMatch[2],
|
|
104
|
+
slug: linkMatch[2],
|
|
105
|
+
url: normalizePluginUrl(linkMatch[1]),
|
|
106
|
+
author: cleanText(card.match(/<span class=["']plugin-author["'][\s\S]*?<span>([\s\S]*?)<\/span>/i)?.[1]),
|
|
107
|
+
activeInstalls: cleanText(card.match(/<span class=["']active-installs["'][\s\S]*?<span>([\s\S]*?)<\/span>/i)?.[1]),
|
|
108
|
+
testedWith: cleanText(card.match(/<span class=["']tested-with["'][\s\S]*?<span>([\s\S]*?)<\/span>/i)?.[1]),
|
|
109
|
+
roles: roles.length > 0 ? roles : ["contributor"]
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function getAuthorArchiveUrl(username) {
|
|
113
|
+
return `https://wordpress.org/plugins/author/${encodeURIComponent(username)}/`;
|
|
114
|
+
}
|
|
115
|
+
function getNextArchivePageUrl(html) {
|
|
116
|
+
const nextHref = html.match(/<a[^>]+rel=["']next["'][^>]+href=["']([^"']+)["']/i)?.[1] ??
|
|
117
|
+
html.match(/<a[^>]+href=["']([^"']+)["'][^>]+rel=["']next["']/i)?.[1];
|
|
118
|
+
return nextHref ? normalizePluginUrl(nextHref) : undefined;
|
|
119
|
+
}
|
|
120
|
+
function dedupeListedPlugins(plugins) {
|
|
121
|
+
const bySlug = new Map();
|
|
122
|
+
for (const plugin of plugins) {
|
|
123
|
+
const existing = bySlug.get(plugin.slug);
|
|
124
|
+
if (!existing) {
|
|
125
|
+
bySlug.set(plugin.slug, plugin);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
bySlug.set(plugin.slug, {
|
|
129
|
+
...existing,
|
|
130
|
+
...plugin,
|
|
131
|
+
roles: Array.from(new Set([...existing.roles, ...plugin.roles]))
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return Array.from(bySlug.values()).sort((a, b) => a.name.localeCompare(b.name));
|
|
135
|
+
}
|
|
136
|
+
function printPluginList(result) {
|
|
137
|
+
ui.section(`${result.username} (${result.source})`);
|
|
138
|
+
if (result.plugins.length === 0) {
|
|
139
|
+
ui.warn(result.source === "public"
|
|
140
|
+
? "No public contributor plugins found. Log in and run `pressship ls` to include plugins where you only have SVN commit access."
|
|
141
|
+
: "No plugins found.");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
for (const plugin of result.plugins) {
|
|
145
|
+
ui.section(plugin.name);
|
|
146
|
+
ui.keyValue("Slug", plugin.slug);
|
|
147
|
+
ui.keyValue("Role", plugin.roles.join(", "));
|
|
148
|
+
ui.keyValue("Active", plugin.activeInstalls ?? "unknown");
|
|
149
|
+
ui.keyValue("Tested", plugin.testedWith ?? "unknown");
|
|
150
|
+
ui.keyValue("URL", ui.path(plugin.url));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function normalizePluginUrl(value) {
|
|
154
|
+
return value.startsWith("//") ? `https:${value}` : new URL(value, "https://wordpress.org").toString();
|
|
155
|
+
}
|
|
156
|
+
function cleanText(value) {
|
|
157
|
+
if (!value) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
const text = value
|
|
161
|
+
.replace(/<[^>]+>/g, " ")
|
|
162
|
+
.replace(/ /g, " ")
|
|
163
|
+
.replace(/&/g, "&")
|
|
164
|
+
.replace(/"/g, '"')
|
|
165
|
+
.replace(/'|'/g, "'")
|
|
166
|
+
.replace(/</g, "<")
|
|
167
|
+
.replace(/>/g, ">")
|
|
168
|
+
.replace(/&#(\d+);/g, (_match, code) => String.fromCodePoint(Number(code)))
|
|
169
|
+
.replace(/&#x([0-9a-f]+);/gi, (_match, code) => String.fromCodePoint(Number.parseInt(code, 16)))
|
|
170
|
+
.replace(/\s+/g, " ")
|
|
171
|
+
.trim();
|
|
172
|
+
return text || undefined;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/plugin/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CA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
|
5
|
+
export declare function resolveSvnCredentials(username?: string): Promise<SvnCredentials>;
|
|
6
|
+
export declare function resolveSvnUsername(): Promise<string>;
|
|
7
|
+
export declare function getSavedSvnPassword(username: string): Promise<string | undefined>;
|
|
8
|
+
export declare function saveSvnPassword(username: string, svnPassword: string): Promise<void>;
|
|
9
|
+
export declare function getSvnPasswordUrl(username: string): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { input, password } from "@inquirer/prompts";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { hasSavedSession, openBrowserSession } from "../auth/session.js";
|
|
5
|
+
import { getWordPressOrgAccount } from "../auth/whoami.js";
|
|
6
|
+
import { ui } from "../ui.js";
|
|
7
|
+
import { ensureConfigDir, getSvnCredentialsPath, pathExists } from "../utils/paths.js";
|
|
8
|
+
const svnCredentialsSchema = z.object({
|
|
9
|
+
credentials: z.record(z.string(), z.object({
|
|
10
|
+
password: z.string().min(1)
|
|
11
|
+
}))
|
|
12
|
+
});
|
|
13
|
+
export async function resolveSvnCredentials(username) {
|
|
14
|
+
const resolvedUsername = username ?? (await resolveSvnUsername());
|
|
15
|
+
const savedPassword = await getSavedSvnPassword(resolvedUsername);
|
|
16
|
+
if (savedPassword) {
|
|
17
|
+
return { username: resolvedUsername, password: savedPassword };
|
|
18
|
+
}
|
|
19
|
+
if (!process.stdin.isTTY) {
|
|
20
|
+
throw new Error(`No saved WordPress.org SVN password found for ${resolvedUsername}. Generate one at ${getSvnPasswordUrl(resolvedUsername)} and run this command interactively once.`);
|
|
21
|
+
}
|
|
22
|
+
ui.section("WordPress.org SVN password");
|
|
23
|
+
const svnPasswordUrl = getSvnPasswordUrl(resolvedUsername);
|
|
24
|
+
ui.info(`Open ${ui.path(svnPasswordUrl)}`);
|
|
25
|
+
ui.info("Generate an SVN password there, then paste it below. Pressship will save it locally for future releases.");
|
|
26
|
+
const openedContext = await openSvnPasswordPage(svnPasswordUrl);
|
|
27
|
+
try {
|
|
28
|
+
const svnPassword = await password({
|
|
29
|
+
message: `SVN password for ${resolvedUsername}`,
|
|
30
|
+
mask: "*",
|
|
31
|
+
validate: (value) => (value.trim() ? true : "Enter the generated WordPress.org SVN password.")
|
|
32
|
+
});
|
|
33
|
+
await saveSvnPassword(resolvedUsername, svnPassword);
|
|
34
|
+
ui.success(`Saved SVN password for ${resolvedUsername} in ${ui.path(getSvnCredentialsPath())}`);
|
|
35
|
+
return { username: resolvedUsername, password: svnPassword };
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await openedContext?.browser()?.close().catch(() => undefined);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export async function resolveSvnUsername() {
|
|
42
|
+
if (await hasSavedSession()) {
|
|
43
|
+
try {
|
|
44
|
+
return (await getWordPressOrgAccount()).username;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Fall through to prompt; the browser session may be stale.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!process.stdin.isTTY) {
|
|
51
|
+
throw new Error("Could not infer a WordPress.org username. Re-run with `--username <username>`.");
|
|
52
|
+
}
|
|
53
|
+
return input({
|
|
54
|
+
message: "WordPress.org SVN username",
|
|
55
|
+
validate: (value) => (value.trim() ? true : "Enter your WordPress.org username.")
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export async function getSavedSvnPassword(username) {
|
|
59
|
+
const file = await readSvnCredentialsFile();
|
|
60
|
+
return file.credentials[username]?.password;
|
|
61
|
+
}
|
|
62
|
+
export async function saveSvnPassword(username, svnPassword) {
|
|
63
|
+
await ensureConfigDir();
|
|
64
|
+
const file = await readSvnCredentialsFile();
|
|
65
|
+
file.credentials[username] = { password: svnPassword };
|
|
66
|
+
await writeFile(getSvnCredentialsPath(), `${JSON.stringify(file, null, 2)}\n`, { mode: 0o600 });
|
|
67
|
+
}
|
|
68
|
+
export function getSvnPasswordUrl(username) {
|
|
69
|
+
return `https://profiles.wordpress.org/${encodeURIComponent(username)}/profile/edit/group/3/?screen=svn-password`;
|
|
70
|
+
}
|
|
71
|
+
async function openSvnPasswordPage(url) {
|
|
72
|
+
try {
|
|
73
|
+
const { context, page } = await openBrowserSession({ headless: false });
|
|
74
|
+
await page.goto(url, { waitUntil: "domcontentloaded" });
|
|
75
|
+
return context;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
ui.warn("Could not open the SVN password page automatically. Open the URL above in your browser.");
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function readSvnCredentialsFile() {
|
|
83
|
+
const credentialsPath = getSvnCredentialsPath();
|
|
84
|
+
if (!pathExists(credentialsPath)) {
|
|
85
|
+
return { credentials: {} };
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
return svnCredentialsSchema.parse(JSON.parse(await readFile(credentialsPath, "utf8")));
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return { credentials: {} };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/svn/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEvF,MAAM,oBAA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AE,MAAM,CAAC,CAAC,CAAC,CAAC;IACzF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const getOptionsSchema: z.ZodObject<{
|
|
3
|
+
json: z.ZodDefault<z.ZodBoolean>;
|
|
4
|
+
installSvn: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export type GetOptions = z.input<typeof getOptionsSchema>;
|
|
7
|
+
export type SvnGetRuntimeOptions = {
|
|
8
|
+
installSvn?: boolean;
|
|
9
|
+
interactive?: boolean;
|
|
10
|
+
quiet?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type SvnGetAction = "checkout" | "update";
|
|
13
|
+
export type SvnInfo = {
|
|
14
|
+
workingCopyRoot?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
relativeUrl?: string;
|
|
17
|
+
repositoryRoot?: string;
|
|
18
|
+
repositoryUuid?: string;
|
|
19
|
+
revision?: string;
|
|
20
|
+
nodeKind?: string;
|
|
21
|
+
schedule?: string;
|
|
22
|
+
lastChangedAuthor?: string;
|
|
23
|
+
lastChangedRevision?: string;
|
|
24
|
+
lastChangedDate?: string;
|
|
25
|
+
};
|
|
26
|
+
export type SvnGetResult = {
|
|
27
|
+
slug: string;
|
|
28
|
+
action: SvnGetAction;
|
|
29
|
+
svnUrl: string;
|
|
30
|
+
path: string;
|
|
31
|
+
info: SvnInfo;
|
|
32
|
+
layout: {
|
|
33
|
+
trunk: boolean;
|
|
34
|
+
assets: boolean;
|
|
35
|
+
tags: boolean;
|
|
36
|
+
tagCount: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare function getPlugin(slugOrUrl: string, destination: string | undefined, rawOptions?: GetOptions): Promise<void>;
|
|
40
|
+
export declare function checkoutOrUpdatePlugin(slug: string, checkoutPath: string, options?: SvnGetRuntimeOptions): Promise<SvnGetResult>;
|
|
41
|
+
export declare function resolveCheckoutPath(slug: string, destination: string | undefined): string;
|
|
42
|
+
export declare function getPluginSvnUrl(slug: string): string;
|
|
43
|
+
export declare function resolveSvnGetAction(checkoutPath: string): Promise<SvnGetAction>;
|
|
44
|
+
export declare function parseSvnInfo(output: string): SvnInfo;
|
|
45
|
+
export {};
|
package/dist/svn/get.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
import { mkdir, readdir } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { slugFromHostedTarget } from "../plugin/info.js";
|
|
6
|
+
import { ui } from "../ui.js";
|
|
7
|
+
import { pathExists } from "../utils/paths.js";
|
|
8
|
+
import { ensureSvnAvailable } from "./subversion.js";
|
|
9
|
+
const getOptionsSchema = z.object({
|
|
10
|
+
json: z.boolean().default(false),
|
|
11
|
+
installSvn: z.boolean().default(true)
|
|
12
|
+
});
|
|
13
|
+
export async function getPlugin(slugOrUrl, destination, rawOptions = {}) {
|
|
14
|
+
const options = getOptionsSchema.parse(rawOptions);
|
|
15
|
+
const slug = slugFromHostedTarget(slugOrUrl);
|
|
16
|
+
const checkoutPath = resolveCheckoutPath(slug, destination);
|
|
17
|
+
const runtimeOptions = {
|
|
18
|
+
installSvn: options.installSvn,
|
|
19
|
+
interactive: !options.json && process.stdin.isTTY,
|
|
20
|
+
quiet: options.json
|
|
21
|
+
};
|
|
22
|
+
await ensureSvnAvailable({ autoInstall: runtimeOptions.installSvn, interactive: runtimeOptions.interactive });
|
|
23
|
+
const result = options.json
|
|
24
|
+
? await checkoutOrUpdatePlugin(slug, checkoutPath, runtimeOptions)
|
|
25
|
+
: await ui.task("Preparing SVN working copy", () => checkoutOrUpdatePlugin(slug, checkoutPath, runtimeOptions), (value) => value.action === "checkout" ? `Checked out ${value.slug}` : `Updated ${value.slug}`);
|
|
26
|
+
if (options.json) {
|
|
27
|
+
console.log(JSON.stringify(result, null, 2));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
printSvnGetResult(result);
|
|
31
|
+
}
|
|
32
|
+
export async function checkoutOrUpdatePlugin(slug, checkoutPath, options = {}) {
|
|
33
|
+
await ensureSvnAvailable({ autoInstall: options.installSvn, interactive: options.interactive });
|
|
34
|
+
const svnUrl = getPluginSvnUrl(slug);
|
|
35
|
+
const action = await resolveSvnGetAction(checkoutPath);
|
|
36
|
+
const commandOptions = { capture: options.quiet };
|
|
37
|
+
if (action === "checkout") {
|
|
38
|
+
await mkdir(path.dirname(checkoutPath), { recursive: true });
|
|
39
|
+
await runSvn(["checkout", svnUrl, checkoutPath], process.cwd(), commandOptions);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
await runSvn(["update"], checkoutPath, commandOptions);
|
|
43
|
+
}
|
|
44
|
+
const info = parseSvnInfo(await runSvn(["info"], checkoutPath, { capture: true }));
|
|
45
|
+
return {
|
|
46
|
+
slug,
|
|
47
|
+
action,
|
|
48
|
+
svnUrl,
|
|
49
|
+
path: checkoutPath,
|
|
50
|
+
info,
|
|
51
|
+
layout: await readSvnLayout(checkoutPath)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function resolveCheckoutPath(slug, destination) {
|
|
55
|
+
return path.resolve(destination ?? slug);
|
|
56
|
+
}
|
|
57
|
+
export function getPluginSvnUrl(slug) {
|
|
58
|
+
return `https://plugins.svn.wordpress.org/${slug}`;
|
|
59
|
+
}
|
|
60
|
+
export async function resolveSvnGetAction(checkoutPath) {
|
|
61
|
+
if (!pathExists(checkoutPath)) {
|
|
62
|
+
return "checkout";
|
|
63
|
+
}
|
|
64
|
+
if (pathExists(path.join(checkoutPath, ".svn"))) {
|
|
65
|
+
return "update";
|
|
66
|
+
}
|
|
67
|
+
const entries = await readdir(checkoutPath);
|
|
68
|
+
if (entries.length === 0) {
|
|
69
|
+
return "checkout";
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`Target directory already exists and is not an SVN working copy: ${checkoutPath}. Choose another path or remove the directory.`);
|
|
72
|
+
}
|
|
73
|
+
export function parseSvnInfo(output) {
|
|
74
|
+
const values = Object.fromEntries(output
|
|
75
|
+
.split(/\r?\n/)
|
|
76
|
+
.map((line) => line.match(/^([^:]+):\s*(.*)$/))
|
|
77
|
+
.filter((match) => Boolean(match))
|
|
78
|
+
.map((match) => [match[1].toLowerCase(), match[2]]));
|
|
79
|
+
return {
|
|
80
|
+
workingCopyRoot: values["working copy root path"],
|
|
81
|
+
url: values.url,
|
|
82
|
+
relativeUrl: values["relative url"],
|
|
83
|
+
repositoryRoot: values["repository root"],
|
|
84
|
+
repositoryUuid: values["repository uuid"],
|
|
85
|
+
revision: values.revision,
|
|
86
|
+
nodeKind: values["node kind"],
|
|
87
|
+
schedule: values.schedule,
|
|
88
|
+
lastChangedAuthor: values["last changed author"],
|
|
89
|
+
lastChangedRevision: values["last changed rev"],
|
|
90
|
+
lastChangedDate: values["last changed date"]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function readSvnLayout(checkoutPath) {
|
|
94
|
+
const tagsPath = path.join(checkoutPath, "tags");
|
|
95
|
+
const tagEntries = pathExists(tagsPath) ? await readdir(tagsPath, { withFileTypes: true }) : [];
|
|
96
|
+
return {
|
|
97
|
+
trunk: pathExists(path.join(checkoutPath, "trunk")),
|
|
98
|
+
assets: pathExists(path.join(checkoutPath, "assets")),
|
|
99
|
+
tags: pathExists(tagsPath),
|
|
100
|
+
tagCount: tagEntries.filter((entry) => entry.isDirectory()).length
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function runSvn(args, cwd, options = {}) {
|
|
104
|
+
const result = await execa("svn", args, {
|
|
105
|
+
cwd,
|
|
106
|
+
reject: false,
|
|
107
|
+
stdout: options.capture ? "pipe" : "inherit",
|
|
108
|
+
stderr: options.capture ? "pipe" : "inherit"
|
|
109
|
+
}).catch((error) => {
|
|
110
|
+
if (isMissingSvnError(error)) {
|
|
111
|
+
throw new Error("`svn` is required for `pressship get`. Install Subversion and try again.");
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
114
|
+
});
|
|
115
|
+
if (result.failed && result.exitCode === undefined && !result.stderr && !result.stdout) {
|
|
116
|
+
throw new Error("`svn` is required for `pressship get`. Install Subversion and try again.");
|
|
117
|
+
}
|
|
118
|
+
if (result.exitCode !== 0) {
|
|
119
|
+
throw new Error(result.stderr || result.stdout || `svn ${args.join(" ")} failed.`);
|
|
120
|
+
}
|
|
121
|
+
return `${result.stdout ?? ""}\n${result.stderr ?? ""}`.trim();
|
|
122
|
+
}
|
|
123
|
+
function isMissingSvnError(error) {
|
|
124
|
+
return (error instanceof Error &&
|
|
125
|
+
("code" in error ? error.code === "ENOENT" : /ENOENT|not found/i.test(error.message)));
|
|
126
|
+
}
|
|
127
|
+
function printSvnGetResult(result) {
|
|
128
|
+
ui.section(result.slug);
|
|
129
|
+
ui.keyValue("Action", result.action === "checkout" ? "checked out" : "updated");
|
|
130
|
+
ui.keyValue("SVN", ui.path(result.svnUrl));
|
|
131
|
+
ui.keyValue("Path", ui.path(result.path));
|
|
132
|
+
ui.keyValue("Revision", result.info.revision ?? "unknown");
|
|
133
|
+
ui.keyValue("Last rev", result.info.lastChangedRevision ?? "unknown");
|
|
134
|
+
ui.keyValue("Last author", result.info.lastChangedAuthor ?? "unknown");
|
|
135
|
+
ui.keyValue("Trunk", result.layout.trunk ? ui.value("available") : "missing");
|
|
136
|
+
ui.keyValue("Assets", result.layout.assets ? ui.value("available") : "missing");
|
|
137
|
+
ui.keyValue("Tags", result.layout.tags ? `${result.layout.tagCount}` : "missing");
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=get.js.map
|