@wp-operations/wp-ops 0.5.2 → 0.5.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/package.json +1 -1
- package/src/commands/build.js +31 -14
- package/src/commands/doctor.js +2 -1
- package/src/commands/platform.js +2 -0
- package/src/commands/start.js +32 -1
- package/src/templates.js +12 -0
- package/wp-operations/CHANGELOG.md +4 -0
- package/wp-operations/assets/app/login.css +1 -1
- package/wp-operations/src/App/App.php +1 -3
- package/wp-operations/style.css +1 -1
package/package.json
CHANGED
package/src/commands/build.js
CHANGED
|
@@ -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
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
);
|
|
18
|
-
if (!pkg.scripts?.build)
|
|
19
|
-
|
|
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
|
-
|
|
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
|
|
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
|
}
|
package/src/commands/doctor.js
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|
package/src/commands/platform.js
CHANGED
|
@@ -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/commands/start.js
CHANGED
|
@@ -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) =>
|
|
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
|
}
|
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,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
|
|
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
|
package/wp-operations/style.css
CHANGED
|
@@ -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.
|
|
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
|