@wp-operations/wp-ops 0.3.0 → 0.3.1
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/package.json +6 -2
- package/src/commands/platform.js +16 -2
- package/src/main.js +9 -3
- package/wp-operations/CHANGELOG.md +14 -0
- package/wp-operations/README.md +39 -0
- package/wp-operations/agents/builder/AGENT.md +15 -0
- package/wp-operations/assets/admin.css +631 -0
- package/wp-operations/assets/admin.js +614 -0
- package/wp-operations/assets/app/app.css +1 -0
- package/wp-operations/assets/app/app.js +70 -0
- package/wp-operations/assets/app/fonts/inter-medium.woff +0 -0
- package/wp-operations/assets/app/fonts/inter-regular.woff +0 -0
- package/wp-operations/assets/app/fonts/inter-semibold.woff +0 -0
- package/wp-operations/assets/app/login.css +42 -0
- package/wp-operations/assets/brand/icon.svg +20 -0
- package/wp-operations/assets/brand/mark.svg +19 -0
- package/wp-operations/assets/editors/audiobook.css +311 -0
- package/wp-operations/assets/editors/audiofile.css +286 -0
- package/wp-operations/assets/editors/course.css +701 -0
- package/wp-operations/assets/editors/course.js +698 -0
- package/wp-operations/assets/editors/faq.css +258 -0
- package/wp-operations/assets/editors/faq.js +196 -0
- package/wp-operations/assets/editors/interactive.css +220 -0
- package/wp-operations/assets/editors/interactive.js +378 -0
- package/wp-operations/assets/editors/media-sources.css +3 -0
- package/wp-operations/assets/editors/media-sources.js +40 -0
- package/wp-operations/assets/editors/open-media.css +114 -0
- package/wp-operations/assets/editors/open-media.js +182 -0
- package/wp-operations/assets/editors/thumbnails.css +335 -0
- package/wp-operations/assets/editors/thumbnails.js +447 -0
- package/wp-operations/assets/editors/translator.css +818 -0
- package/wp-operations/functions.php +24 -0
- package/wp-operations/index.php +14 -0
- package/wp-operations/platform.json +1836 -0
- package/wp-operations/skills/ai-development-guardrails/SKILL.md +49 -0
- package/wp-operations/skills/gutenberg-reference/SKILL.md +45 -0
- package/wp-operations/skills/js-tooling-for-themes/SKILL.md +51 -0
- package/wp-operations/skills/tailwind-for-wp/SKILL.md +62 -0
- package/wp-operations/skills/wp-clean-classic-themes/SKILL.md +112 -0
- package/wp-operations/skills/wp-psr4-plugins/SKILL.md +2043 -0
- package/wp-operations/skills/wp-security/SKILL.md +90 -0
- package/wp-operations/src/Admin.php +78 -0
- package/wp-operations/src/App/Access.php +57 -0
- package/wp-operations/src/App/Admin.php +442 -0
- package/wp-operations/src/App/App.php +157 -0
- package/wp-operations/src/App/Apps.php +379 -0
- package/wp-operations/src/App/Bundle.php +111 -0
- package/wp-operations/src/App/Contents.php +676 -0
- package/wp-operations/src/App/Engine.php +554 -0
- package/wp-operations/src/App/Github.php +308 -0
- package/wp-operations/src/App/Module.php +23 -0
- package/wp-operations/src/App/Ops.php +470 -0
- package/wp-operations/src/App/Packages.php +289 -0
- package/wp-operations/src/App/Rest.php +539 -0
- package/wp-operations/src/App/Sandboxes.php +206 -0
- package/wp-operations/src/App/Store.php +104 -0
- package/wp-operations/src/App/Usage.php +268 -0
- package/wp-operations/src/Config.php +249 -0
- package/wp-operations/src/Content/Editor.php +223 -0
- package/wp-operations/src/Content/Fields.php +681 -0
- package/wp-operations/src/Content/Scoring.php +253 -0
- package/wp-operations/src/Content/Structure.php +293 -0
- package/wp-operations/src/Content/Types.php +150 -0
- package/wp-operations/src/Content/Uploads.php +50 -0
- package/wp-operations/src/Editors/AudiobookAuthor.php +61 -0
- package/wp-operations/src/Editors/AudiobookChapters.php +632 -0
- package/wp-operations/src/Editors/AudiobookCover.php +235 -0
- package/wp-operations/src/Editors/Audiofile.php +462 -0
- package/wp-operations/src/Editors/Course.php +784 -0
- package/wp-operations/src/Editors/Ebook.php +242 -0
- package/wp-operations/src/Editors/Editors.php +44 -0
- package/wp-operations/src/Editors/Faq.php +237 -0
- package/wp-operations/src/Editors/Files.php +139 -0
- package/wp-operations/src/Editors/Interactive/Builder.php +103 -0
- package/wp-operations/src/Editors/Interactive/Card.php +76 -0
- package/wp-operations/src/Editors/Interactive/Editor.php +42 -0
- package/wp-operations/src/Editors/Interactive/Field.php +272 -0
- package/wp-operations/src/Editors/Interactive/Map.php +84 -0
- package/wp-operations/src/Editors/Interactive/Models.php +227 -0
- package/wp-operations/src/Editors/Interactive/Report.php +59 -0
- package/wp-operations/src/Editors/Interactive/Save.php +323 -0
- package/wp-operations/src/Editors/Interactive/Scoring.php +244 -0
- package/wp-operations/src/Editors/Interactive/Structure.php +195 -0
- package/wp-operations/src/Editors/Legal.php +235 -0
- package/wp-operations/src/Editors/OpenMedia.php +140 -0
- package/wp-operations/src/Editors/OriginalTitle.php +112 -0
- package/wp-operations/src/Editors/Sources.php +28 -0
- package/wp-operations/src/Editors/Thumbnails/Admin.php +306 -0
- package/wp-operations/src/Editors/Thumbnails/Ajax.php +163 -0
- package/wp-operations/src/Editors/Thumbnails/Box.php +188 -0
- package/wp-operations/src/Editors/Thumbnails/Storage.php +228 -0
- package/wp-operations/src/Editors/Translator/Admin.php +913 -0
- package/wp-operations/src/Editors/Translator/Api.php +63 -0
- package/wp-operations/src/Editors/Translator/Bar.php +83 -0
- package/wp-operations/src/Editors/Translator/Fields.php +273 -0
- package/wp-operations/src/Editors/Translator/Storage.php +131 -0
- package/wp-operations/src/Editors/Translator/Thumbnail.php +215 -0
- package/wp-operations/src/Identity.php +104 -0
- package/wp-operations/src/Languages.php +45 -0
- package/wp-operations/src/Lockdown.php +85 -0
- package/wp-operations/src/Modules/Apps/Admin.php +472 -0
- package/wp-operations/src/Modules/Apps/Api.php +193 -0
- package/wp-operations/src/Modules/Apps/Apps.php +279 -0
- package/wp-operations/src/Modules/Apps/Formatters.php +478 -0
- package/wp-operations/src/Modules/Apps/Schemes.php +248 -0
- package/wp-operations/src/Modules/Apps/Table.php +101 -0
- package/wp-operations/src/Modules/Thumbnails.php +68 -0
- package/wp-operations/src/Modules/Translations.php +133 -0
- package/wp-operations/src/Platform.php +59 -0
- package/wp-operations/src/Setup.php +273 -0
- package/wp-operations/src/Status.php +99 -0
- package/wp-operations/src/Storage/Client.php +168 -0
- package/wp-operations/src/Storage/Offload.php +120 -0
- package/wp-operations/src/Storage/Settings.php +166 -0
- package/wp-operations/src/Storage/Storage.php +35 -0
- package/wp-operations/src/Updates.php +151 -0
- package/wp-operations/style.css +11 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
namespace Platform\App;
|
|
3
|
+
|
|
4
|
+
use Platform\Config;
|
|
5
|
+
|
|
6
|
+
defined( 'ABSPATH' ) || exit;
|
|
7
|
+
|
|
8
|
+
final class Github {
|
|
9
|
+
|
|
10
|
+
public static function constant(): string {
|
|
11
|
+
return preg_replace( '/[^A-Z0-9_]/', '', strtoupper( (string) Config::get( 'ops.github.token_constant', 'PLATFORM_GITHUB_TOKEN' ) ) ) ?: 'PLATFORM_GITHUB_TOKEN';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private static function token(): string {
|
|
15
|
+
$constant = self::constant();
|
|
16
|
+
|
|
17
|
+
return defined( $constant ) ? trim( (string) constant( $constant ) ) : '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static function ready(): bool {
|
|
21
|
+
return '' !== self::token() && '' !== Ops::settings()['repo'];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static function parse( string $url ): string {
|
|
25
|
+
$url = trim( $url );
|
|
26
|
+
|
|
27
|
+
if ( preg_match( '#^(?:https?://)?(?:www\.)?github\.com[/:]([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+?)(?:\.git)?/?$#', $url, $m ) ) {
|
|
28
|
+
return $m[1] . '/' . $m[2];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if ( preg_match( '#^git@github\.com:([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+?)(?:\.git)?$#', $url, $m ) ) {
|
|
32
|
+
return $m[1] . '/' . $m[2];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public static function call( string $method, string $path, ?array $body = null ) {
|
|
39
|
+
if ( '' === self::token() ) {
|
|
40
|
+
return new \WP_Error( 'github_token', sprintf( 'Add define( \'%s\', \'…\' ) to wp-config.php to reach GitHub.', self::constant() ), [ 'status' => 409 ] );
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
$api = untrailingslashit( (string) Config::get( 'ops.github.api', 'https://api.github.com' ) );
|
|
44
|
+
$response = wp_remote_request(
|
|
45
|
+
$api . '/' . ltrim( $path, '/' ),
|
|
46
|
+
[
|
|
47
|
+
'method' => $method,
|
|
48
|
+
'timeout' => 20,
|
|
49
|
+
'headers' => [
|
|
50
|
+
'Authorization' => 'Bearer ' . self::token(),
|
|
51
|
+
'Accept' => 'application/vnd.github+json',
|
|
52
|
+
'X-GitHub-Api-Version' => '2022-11-28',
|
|
53
|
+
'User-Agent' => 'wp-operations',
|
|
54
|
+
'Content-Type' => 'application/json',
|
|
55
|
+
],
|
|
56
|
+
'body' => null === $body ? null : wp_json_encode( $body ),
|
|
57
|
+
]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if ( is_wp_error( $response ) ) {
|
|
61
|
+
return new \WP_Error( 'github', $response->get_error_message(), [ 'status' => 502 ] );
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
$code = (int) wp_remote_retrieve_response_code( $response );
|
|
65
|
+
$data = json_decode( (string) wp_remote_retrieve_body( $response ), true );
|
|
66
|
+
|
|
67
|
+
if ( $code >= 400 ) {
|
|
68
|
+
return new \WP_Error( 'github', sprintf( 'GitHub: %s', (string) ( $data['message'] ?? 'request failed' ) ), [ 'status' => 404 === $code ? 404 : 502 ] );
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return is_array( $data ) ? $data : [];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public static function repo_call( string $method, string $path, ?array $body = null ) {
|
|
75
|
+
$repo = Ops::settings()['repo'];
|
|
76
|
+
|
|
77
|
+
if ( '' === $repo ) {
|
|
78
|
+
return new \WP_Error( 'repo', 'Connect the platform repository in Settings → Operations first.', [ 'status' => 409 ] );
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return self::call( $method, 'repos/' . $repo . ( '' === $path ? '' : '/' . ltrim( $path, '/' ) ), $body );
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public static function ref( string $branch ): string {
|
|
85
|
+
return implode( '/', array_map( 'rawurlencode', explode( '/', $branch ) ) );
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public static function branch(): string {
|
|
89
|
+
$settings = Ops::settings();
|
|
90
|
+
|
|
91
|
+
if ( '' !== $settings['branch'] ) {
|
|
92
|
+
return $settings['branch'];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
$cached = get_transient( 'platform_ops_default_branch' );
|
|
96
|
+
|
|
97
|
+
if ( is_string( $cached ) && '' !== $cached ) {
|
|
98
|
+
return $cached;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
$repo = self::repo_call( 'GET', '' );
|
|
102
|
+
$branch = is_wp_error( $repo ) ? 'main' : (string) ( $repo['default_branch'] ?? 'main' );
|
|
103
|
+
|
|
104
|
+
set_transient( 'platform_ops_default_branch', $branch, HOUR_IN_SECONDS );
|
|
105
|
+
|
|
106
|
+
return $branch;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public static function tree( string $branch = '' ) {
|
|
110
|
+
$branch = '' === $branch ? self::branch() : $branch;
|
|
111
|
+
$ref = self::repo_call( 'GET', 'branches/' . self::ref( $branch ) );
|
|
112
|
+
|
|
113
|
+
if ( is_wp_error( $ref ) ) {
|
|
114
|
+
return $ref;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
$sha = (string) ( $ref['commit']['sha'] ?? '' );
|
|
118
|
+
$key = 'platform_ops_tree_' . md5( $sha );
|
|
119
|
+
$cached = get_transient( $key );
|
|
120
|
+
|
|
121
|
+
if ( is_array( $cached ) ) {
|
|
122
|
+
return $cached;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
$tree = self::repo_call( 'GET', 'git/trees/' . rawurlencode( $sha ) . '?recursive=1' );
|
|
126
|
+
|
|
127
|
+
if ( is_wp_error( $tree ) ) {
|
|
128
|
+
return $tree;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
$result = [
|
|
132
|
+
'sha' => $sha,
|
|
133
|
+
'branch' => $branch,
|
|
134
|
+
'truncated' => ! empty( $tree['truncated'] ),
|
|
135
|
+
'files' => array_values(
|
|
136
|
+
array_map(
|
|
137
|
+
static fn( array $node ): array => [ 'path' => (string) $node['path'], 'sha' => (string) ( $node['sha'] ?? '' ), 'size' => (int) ( $node['size'] ?? 0 ) ],
|
|
138
|
+
array_filter( (array) ( $tree['tree'] ?? [] ), static fn( $node ): bool => is_array( $node ) && 'blob' === ( $node['type'] ?? '' ) )
|
|
139
|
+
)
|
|
140
|
+
),
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
set_transient( $key, $result, 10 * MINUTE_IN_SECONDS );
|
|
144
|
+
|
|
145
|
+
return $result;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public static function blob( string $sha ) {
|
|
149
|
+
$key = 'platform_ops_blob_' . md5( $sha );
|
|
150
|
+
$cached = get_transient( $key );
|
|
151
|
+
|
|
152
|
+
if ( is_string( $cached ) ) {
|
|
153
|
+
return $cached;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
$blob = self::repo_call( 'GET', 'git/blobs/' . rawurlencode( $sha ) );
|
|
157
|
+
|
|
158
|
+
if ( is_wp_error( $blob ) ) {
|
|
159
|
+
return $blob;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
$content = (string) base64_decode( (string) ( $blob['content'] ?? '' ) );
|
|
163
|
+
|
|
164
|
+
set_transient( $key, $content, DAY_IN_SECONDS );
|
|
165
|
+
|
|
166
|
+
return $content;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public static function read( string $path, string $branch = '' ) {
|
|
170
|
+
$data = self::repo_call( 'GET', 'contents/' . implode( '/', array_map( 'rawurlencode', explode( '/', ltrim( $path, '/' ) ) ) ) . '?ref=' . rawurlencode( '' === $branch ? self::branch() : $branch ) );
|
|
171
|
+
|
|
172
|
+
if ( is_wp_error( $data ) ) {
|
|
173
|
+
return $data;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if ( isset( $data[0] ) || 'file' !== ( $data['type'] ?? '' ) ) {
|
|
177
|
+
return new \WP_Error( 'not_file', 'That path is a folder.', [ 'status' => 400 ] );
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return [ 'content' => (string) base64_decode( (string) ( $data['content'] ?? '' ) ), 'url' => (string) ( $data['html_url'] ?? '' ) ];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public static function json( string $path, array $files ) {
|
|
184
|
+
foreach ( $files as $file ) {
|
|
185
|
+
if ( $file['path'] === $path ) {
|
|
186
|
+
$raw = self::blob( $file['sha'] );
|
|
187
|
+
|
|
188
|
+
if ( is_wp_error( $raw ) ) {
|
|
189
|
+
return $raw;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
$data = json_decode( $raw, true );
|
|
193
|
+
|
|
194
|
+
return is_array( $data ) ? $data : new \WP_Error( 'json', sprintf( '%s is not valid JSON.', $path ), [ 'status' => 422 ] );
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public static function commit( string $message, array $changes, string $branch = '' ) {
|
|
202
|
+
$branch = '' === $branch ? self::branch() : $branch;
|
|
203
|
+
$ref = self::repo_call( 'GET', 'git/ref/heads/' . self::ref( $branch ) );
|
|
204
|
+
|
|
205
|
+
if ( is_wp_error( $ref ) && 404 === (int) ( $ref->get_error_data()['status'] ?? 0 ) ) {
|
|
206
|
+
$base = self::repo_call( 'GET', 'git/ref/heads/' . self::ref( self::branch() ) );
|
|
207
|
+
|
|
208
|
+
if ( is_wp_error( $base ) ) {
|
|
209
|
+
return $base;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
$ref = self::repo_call( 'POST', 'git/refs', [ 'ref' => 'refs/heads/' . $branch, 'sha' => (string) $base['object']['sha'] ] );
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if ( is_wp_error( $ref ) ) {
|
|
216
|
+
return $ref;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
$parent = (string) ( $ref['object']['sha'] ?? '' );
|
|
220
|
+
$head = self::repo_call( 'GET', 'git/commits/' . $parent );
|
|
221
|
+
|
|
222
|
+
if ( is_wp_error( $head ) ) {
|
|
223
|
+
return $head;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
$tree = [];
|
|
227
|
+
|
|
228
|
+
foreach ( $changes as $path => $content ) {
|
|
229
|
+
$path = ltrim( (string) $path, '/' );
|
|
230
|
+
|
|
231
|
+
if ( null === $content ) {
|
|
232
|
+
$tree[] = [ 'path' => $path, 'mode' => '100644', 'type' => 'blob', 'sha' => null ];
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
$blob = self::repo_call( 'POST', 'git/blobs', [ 'content' => base64_encode( (string) $content ), 'encoding' => 'base64' ] );
|
|
237
|
+
|
|
238
|
+
if ( is_wp_error( $blob ) ) {
|
|
239
|
+
return $blob;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
$tree[] = [ 'path' => $path, 'mode' => '100644', 'type' => 'blob', 'sha' => (string) $blob['sha'] ];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
$new = self::repo_call( 'POST', 'git/trees', [ 'base_tree' => (string) $head['tree']['sha'], 'tree' => $tree ] );
|
|
246
|
+
|
|
247
|
+
if ( is_wp_error( $new ) ) {
|
|
248
|
+
return $new;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
$user = wp_get_current_user();
|
|
252
|
+
$commit = self::repo_call(
|
|
253
|
+
'POST',
|
|
254
|
+
'git/commits',
|
|
255
|
+
[
|
|
256
|
+
'message' => $message . ( $user->ID ? "\n\nRequested-By: " . $user->display_name . ' <' . $user->user_email . '>' : '' ),
|
|
257
|
+
'tree' => (string) $new['sha'],
|
|
258
|
+
'parents' => [ $parent ],
|
|
259
|
+
]
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
if ( is_wp_error( $commit ) ) {
|
|
263
|
+
return $commit;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
$update = self::repo_call( 'PATCH', 'git/refs/heads/' . self::ref( $branch ), [ 'sha' => (string) $commit['sha'], 'force' => false ] );
|
|
267
|
+
|
|
268
|
+
if ( is_wp_error( $update ) ) {
|
|
269
|
+
return $update;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return [ 'sha' => (string) $commit['sha'], 'branch' => $branch, 'url' => (string) ( $commit['html_url'] ?? '' ), 'files' => count( $changes ) ];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public static function dispatch( string $workflow, array $inputs = [], string $branch = '' ) {
|
|
276
|
+
$workflow = preg_replace( '#[^A-Za-z0-9._-]#', '', $workflow );
|
|
277
|
+
|
|
278
|
+
if ( '' === $workflow ) {
|
|
279
|
+
return new \WP_Error( 'workflow', 'Choose a workflow.', [ 'status' => 400 ] );
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
$result = self::repo_call(
|
|
283
|
+
'POST',
|
|
284
|
+
'actions/workflows/' . rawurlencode( $workflow ) . '/dispatches',
|
|
285
|
+
[ 'ref' => '' === $branch ? self::branch() : $branch, 'inputs' => (object) array_map( 'strval', $inputs ) ]
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
return is_wp_error( $result ) ? $result : [ 'ok' => true, 'workflow' => $workflow ];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public static function seal( string $value, string $environment = '' ) {
|
|
292
|
+
if ( ! function_exists( 'sodium_crypto_box_seal' ) ) {
|
|
293
|
+
return new \WP_Error( 'sodium', 'The PHP sodium extension is required to send secrets.', [ 'status' => 500 ] );
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
$key = self::repo_call( 'GET', self::secrets_path( $environment ) . '/public-key' );
|
|
297
|
+
|
|
298
|
+
if ( is_wp_error( $key ) ) {
|
|
299
|
+
return $key;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return [ 'key_id' => (string) $key['key_id'], 'encrypted_value' => base64_encode( sodium_crypto_box_seal( $value, base64_decode( (string) $key['key'] ) ) ) ];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
public static function secrets_path( string $environment ): string {
|
|
306
|
+
return '' === $environment ? 'actions/secrets' : 'environments/' . rawurlencode( $environment ) . '/secrets';
|
|
307
|
+
}
|
|
308
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
namespace Platform\App;
|
|
3
|
+
|
|
4
|
+
use Platform\Config;
|
|
5
|
+
|
|
6
|
+
defined( 'ABSPATH' ) || exit;
|
|
7
|
+
|
|
8
|
+
final class Module {
|
|
9
|
+
|
|
10
|
+
public static function register(): void {
|
|
11
|
+
Access::register();
|
|
12
|
+
Rest::register();
|
|
13
|
+
Admin::register();
|
|
14
|
+
App::register();
|
|
15
|
+
|
|
16
|
+
add_action( 'admin_init', [ Bundle::class, 'maybe_sync' ] );
|
|
17
|
+
add_action( 'rest_api_init', [ Bundle::class, 'maybe_sync' ] );
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static function config( string $path = '', $fallback = null ) {
|
|
21
|
+
return Config::get( '' === $path ? 'app' : 'app.' . $path, $fallback );
|
|
22
|
+
}
|
|
23
|
+
}
|