@wp-operations/wp-ops 0.5.3 → 0.5.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-operations/wp-ops",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "The wp-operations tool. One install gives the platform and wp-ops, wp-app, wp-ide and wp-code.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -10,6 +10,7 @@ import {
10
10
  APP_INDEX,
11
11
  DEPLOY_APPS,
12
12
  DEPLOY_PLATFORM,
13
+ GITATTRIBUTES,
13
14
  GITIGNORE,
14
15
  appStyle,
15
16
  composerWorkflow,
@@ -123,6 +124,7 @@ function writeWorkflows(root, version, created) {
123
124
  writeNew(path.join(dir, 'composer.yml'), composerWorkflow(version), created);
124
125
  writeNew(path.join(dir, 'deploy-apps.yml'), DEPLOY_APPS, created);
125
126
  writeNew(path.join(dir, 'deploy-platform.yml'), DEPLOY_PLATFORM, created);
127
+ writeNew(path.join(root, '.gitattributes'), GITATTRIBUTES, created);
126
128
  }
127
129
 
128
130
  function themeVersion(dir) {
package/src/templates.js CHANGED
@@ -7,6 +7,18 @@ node_modules/
7
7
  Thumbs.db
8
8
  `;
9
9
 
10
+ export const GITATTRIBUTES = `* text=auto eol=lf
11
+ *.png binary
12
+ *.jpg binary
13
+ *.jpeg binary
14
+ *.gif binary
15
+ *.webp binary
16
+ *.ico binary
17
+ *.woff binary
18
+ *.woff2 binary
19
+ *.zip binary
20
+ `;
21
+
10
22
  export function composerWorkflow(version) {
11
23
  return `name: composer
12
24
 
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+
5
+ - changed logo size from mine to my father's (tried to fool boss)
6
+ - Theme updates work while the repository is private: set `PLATFORM_UPDATES_TOKEN` in wp-config.php.
7
+
3
8
  ## 0.1.1
4
9
 
5
10
  - Sign-in screen shows the platform logo again (your Site Logo when set) and no longer scrolls.
@@ -14,6 +14,7 @@ define( 'PLATFORM_OPENAI_KEY', 'sk-…' ); // one constant per AI mod
14
14
  define( 'PLATFORM_SANDBOX_TOKEN', '…' ); // optional, per sandbox (same value as SANDBOX_TOKEN for wp-ops sandbox)
15
15
  define( 'PLATFORM_STORAGE_BUCKET', '…' ); // optional S3/R2 storage: PLATFORM_STORAGE_ENDPOINT, _BUCKET, _ACCESS_KEY, _SECRET_KEY, _PUBLIC_URL
16
16
  define( 'PLATFORM_CONFIG', '/path/to/platform.json' ); // optional: use another platform.json than the theme's
17
+ define( 'PLATFORM_UPDATES_TOKEN', 'github_pat_…' ); // needed for theme updates while the wp-operations repository is private (read access to its releases)
17
18
  ```
18
19
 
19
20
  ## Settings
@@ -9,7 +9,7 @@ body.platform-gate,body.login{margin:0;background:var(--bg);color:var(--text);fo
9
9
  .gate{box-sizing:border-box;min-height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:48px 20px;position:relative;overflow:hidden}
10
10
  .gate__glow{position:absolute;inset:-40% -20% auto;height:90%;background:radial-gradient(50% 50% at 50% 40%,rgba(255,255,255,.07),transparent 70%);pointer-events:none}
11
11
  .gate__card{position:relative;width:100%;max-width:380px;background:linear-gradient(180deg,rgba(255,255,255,.035),rgba(255,255,255,.01));border:1px solid var(--line);border-radius:20px;padding:36px 32px 28px;box-shadow:0 30px 80px -20px rgba(0,0,0,.7)}
12
- .gate__mark{display:block;width:56px;height:56px;object-fit:contain;margin:0 auto 20px}
12
+ .gate__mark{display:block;width:80px;height:80px;object-fit:contain;margin:0 auto 20px}
13
13
  .gate h1{font-size:20px;font-weight:600;letter-spacing:-.01em;text-align:center;margin:0 0 24px}
14
14
  .gate__lead{color:var(--muted);text-align:center;margin:0 0 24px}
15
15
  .gate__foot{position:relative;margin-top:28px;color:var(--faint);font-size:12px}
@@ -15,13 +15,42 @@ final class Updates {
15
15
  const TAG = 'theme-v';
16
16
  const ASSET = 'wp-operations.zip';
17
17
  const CACHE = 'platform_theme_release';
18
+ const TOKEN = 'PLATFORM_UPDATES_TOKEN';
18
19
 
19
20
  public static function register(): void {
20
21
  add_filter( 'pre_set_site_transient_update_themes', [ __CLASS__, 'check' ] );
22
+ add_filter( 'http_request_args', [ __CLASS__, 'authorize' ], 10, 2 );
21
23
  add_action( 'upgrader_process_complete', [ __CLASS__, 'forget' ], 10, 0 );
22
24
  add_action( 'wp_ajax_platform_theme_changelog', [ __CLASS__, 'changelog' ] );
23
25
  }
24
26
 
27
+ private static function token(): string {
28
+ return defined( self::TOKEN ) ? trim( (string) constant( self::TOKEN ) ) : '';
29
+ }
30
+
31
+ /**
32
+ * With PLATFORM_UPDATES_TOKEN set (needed while the repository is private),
33
+ * GitHub API requests to this repository carry the token, and the release
34
+ * asset is downloaded through the API.
35
+ */
36
+ public static function authorize( array $args, string $url ): array {
37
+ $token = self::token();
38
+
39
+ if ( '' === $token || 0 !== strpos( $url, 'https://api.github.com/repos/' . self::REPOSITORY . '/' ) ) {
40
+ return $args;
41
+ }
42
+
43
+ $args['headers'] = (array) ( $args['headers'] ?? [] );
44
+ $args['headers']['Authorization'] = 'Bearer ' . $token;
45
+ $args['headers']['User-Agent'] = 'wp-operations';
46
+
47
+ if ( false !== strpos( $url, '/releases/assets/' ) ) {
48
+ $args['headers']['Accept'] = 'application/octet-stream';
49
+ }
50
+
51
+ return $args;
52
+ }
53
+
25
54
  public static function changelog(): void {
26
55
  if ( ! current_user_can( 'update_themes' ) ) {
27
56
  wp_die( esc_html__( 'Sorry, you are not allowed to update themes.', 'wp-operations' ), 403 );
@@ -131,7 +160,7 @@ final class Updates {
131
160
  $release = [
132
161
  'version' => substr( $tag, strlen( self::TAG ) ),
133
162
  'url' => esc_url_raw( (string) ( $item['html_url'] ?? '' ) ),
134
- 'package' => esc_url_raw( (string) ( $asset['browser_download_url'] ?? '' ) ),
163
+ 'package' => esc_url_raw( (string) ( '' !== self::token() ? ( $asset['url'] ?? '' ) : ( $asset['browser_download_url'] ?? '' ) ) ),
135
164
  'notes' => (string) ( $item['body'] ?? '' ),
136
165
  ];
137
166
  break 2;
@@ -2,8 +2,8 @@
2
2
  Theme Name: wp-operations
3
3
  Theme URI: https://github.com/wordpress-operations/wordpress-operations
4
4
  Author: wp-operations
5
- Description: The wp-operations platform: content engine (platform.json), CMS, app builder and operations for one platform repository.
6
- Version: 0.1.1
5
+ Description: wp-operations: AI-powered content engine with platform builder, CMS and operations for one repository.
6
+ Version: 0.1.2
7
7
  Requires at least: 6.4
8
8
  Requires PHP: 8.0
9
9
  License: GPL-2.0-or-later