@wp-operations/wp-ops 0.5.2 → 0.5.3

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.2",
3
+ "version": "0.5.3",
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",
@@ -3,24 +3,41 @@ import path from 'path';
3
3
  import { execSync } from 'child_process';
4
4
  import { findRootDir, listPackages } from '../project.js';
5
5
 
6
+ function subdirs(dir) {
7
+ return fs.existsSync(dir)
8
+ ? fs.readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path.join(dir, entry.name))
9
+ : [];
10
+ }
11
+
12
+ /**
13
+ * In a platform repository: every plugin (packages/<vendor>/<name>) and every
14
+ * app (<kind folder>/<slug>). Otherwise: packages/<name>.
15
+ */
16
+ function buildDirs(rootDir) {
17
+ const layoutFile = path.join(rootDir, '.github', 'platform.json');
18
+ if (!fs.existsSync(layoutFile)) {
19
+ return listPackages(rootDir);
20
+ }
21
+ const layout = JSON.parse(fs.readFileSync(layoutFile, 'utf8'));
22
+ const plugins = subdirs(path.join(rootDir, layout.packages || 'packages')).flatMap(subdirs);
23
+ const apps = Object.entries(layout.apps || {}).flatMap(([key, kind]) => subdirs(path.join(rootDir, kind?.folder || key)));
24
+ return [...plugins, ...apps];
25
+ }
26
+
6
27
  export function buildAll(startDir = process.cwd()) {
7
28
  const rootDir = findRootDir(startDir);
8
- const packages = listPackages(rootDir);
9
- if (packages.length === 0) {
10
- console.log('No packages/ directory with packages found.');
11
- return;
12
- }
13
29
  let built = 0;
14
- for (const dir of packages) {
15
- const pkg = JSON.parse(
16
- fs.readFileSync(path.join(dir, 'package.json'), 'utf8')
17
- );
18
- if (!pkg.scripts?.build) {
19
- continue;
30
+ for (const dir of buildDirs(rootDir)) {
31
+ const file = path.join(dir, 'package.json');
32
+ if (!fs.existsSync(file)) continue;
33
+ const pkg = JSON.parse(fs.readFileSync(file, 'utf8'));
34
+ if (!pkg.scripts?.build) continue;
35
+ console.log(`\n[wp-ops] build: ${path.relative(rootDir, dir).split(path.sep).join('/')}`);
36
+ if (!fs.existsSync(path.join(dir, 'node_modules')) && fs.existsSync(path.join(dir, 'package-lock.json'))) {
37
+ execSync('npm ci', { cwd: dir, stdio: 'inherit', shell: true });
20
38
  }
21
- console.log(`\n[wp-ops] build: ${pkg.name}`);
22
- execSync(pkg.scripts.build, { cwd: dir, stdio: 'inherit', shell: true });
39
+ execSync('npm run build', { cwd: dir, stdio: 'inherit', shell: true });
23
40
  built++;
24
41
  }
25
- console.log(`\n[wp-ops] built ${built} package(s).`);
42
+ console.log(built ? `\n[wp-ops] built ${built}.` : '[wp-ops] nothing to build: no package.json with a "build" script in the apps or plugins.');
26
43
  }
@@ -101,5 +101,6 @@ export async function doctor(startDir = process.cwd()) {
101
101
  await platformChecks(rootDir);
102
102
 
103
103
  console.log(pc.dim(`\n root: ${rootDir}`));
104
- console.log(pc.dim(` home data: ${process.env.WP_APP_HOME || path.join(os.homedir(), '.wp-app')}\n`));
104
+ const repoData = fs.existsSync(path.join(rootDir, '.github', 'platform.json')) ? path.join(rootDir, '.local') : '';
105
+ console.log(pc.dim(` site data: ${process.env.WP_APP_HOME || repoData || path.join(os.homedir(), '.wp-app')}\n`));
105
106
  }
@@ -1,6 +1,33 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
1
4
  import { spawn } from 'child_process';
2
5
  import { findRootDir, findWpAppCli } from '../project.js';
3
6
 
7
+ /**
8
+ * Downloads (WordPress, ClassicPress, SQLite) are shared between data folders:
9
+ * whatever one folder has cached, the other gets, so a new repository never
10
+ * downloads WordPress again.
11
+ */
12
+ function shareCache(home) {
13
+ const shared = path.join(os.homedir(), '.wp-app', 'cache');
14
+ const local = path.join(home, 'cache');
15
+ if (path.resolve(shared) === path.resolve(local)) return;
16
+ for (const [from, to] of [[shared, local], [local, shared]]) {
17
+ if (!fs.existsSync(from)) continue;
18
+ fs.mkdirSync(to, { recursive: true });
19
+ for (const name of fs.readdirSync(from)) {
20
+ const source = path.join(from, name);
21
+ const target = path.join(to, name);
22
+ if (!fs.existsSync(target) && fs.statSync(source).isFile()) {
23
+ try {
24
+ fs.copyFileSync(source, target);
25
+ } catch {}
26
+ }
27
+ }
28
+ }
29
+ }
30
+
4
31
  export function startApp({ appDir, flags = [], dev = false, env = process.env }) {
5
32
  const rootDir = findRootDir(appDir);
6
33
  const wpAppCli = findWpAppCli(rootDir);
@@ -10,8 +37,12 @@ export function startApp({ appDir, flags = [], dev = false, env = process.env })
10
37
  );
11
38
  process.exit(1);
12
39
  }
40
+ if (env.WP_APP_HOME) shareCache(env.WP_APP_HOME);
13
41
  const args = [wpAppCli, dev ? 'dev' : 'start', `--path=${appDir}`, ...flags];
14
42
  const child = spawn(process.execPath, args, { stdio: 'inherit', env });
15
- child.on('exit', (code) => process.exit(code ?? 0));
43
+ child.on('exit', (code) => {
44
+ if (env.WP_APP_HOME) shareCache(env.WP_APP_HOME);
45
+ process.exit(code ?? 0);
46
+ });
16
47
  return child;
17
48
  }
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1
4
+
5
+ - Sign-in screen shows the platform logo again (your Site Logo when set) and no longer scrolls.
6
+
3
7
  ## 0.1.0
4
8
 
5
9
  - The theme now lives in the wp-operations repository and updates itself from its releases, with this changelog in Dashboard → Updates.
@@ -6,7 +6,7 @@
6
6
  html,body{height:100%}
7
7
  body.platform-gate,body.login{margin:0;background:var(--bg);color:var(--text);font:14px/1.5 Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased}
8
8
 
9
- .gate{min-height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:48px 20px;position:relative;overflow:hidden}
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
12
  .gate__mark{display:block;width:56px;height:56px;object-fit:contain;margin:0 auto 20px}
@@ -121,9 +121,7 @@ final class App {
121
121
  <body class="platform-gate">
122
122
  <main class="gate">
123
123
  <section class="gate__card">
124
- <?php if ( '' !== $brand['logo'] ) : ?>
125
- <img class="gate__mark" src="<?php echo esc_url( $brand['logo'] ); ?>" alt="">
126
- <?php endif; ?>
124
+ <img class="gate__mark" src="<?php echo esc_url( $brand['logo'] ?: $brand['mark'] ); ?>" alt="">
127
125
  <?php if ( 'login' === $view ) : ?>
128
126
  <h1>Sign in to <?php echo esc_html( $brand['name'] ); ?></h1>
129
127
  <?php
@@ -3,7 +3,7 @@ Theme Name: wp-operations
3
3
  Theme URI: https://github.com/wordpress-operations/wordpress-operations
4
4
  Author: wp-operations
5
5
  Description: The wp-operations platform: content engine (platform.json), CMS, app builder and operations for one platform repository.
6
- Version: 0.1.0
6
+ Version: 0.1.1
7
7
  Requires at least: 6.4
8
8
  Requires PHP: 8.0
9
9
  License: GPL-2.0-or-later