@wp-operations/wp-ops 0.5.1 → 0.5.2
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/doctor.js +5 -2
- package/src/tui.js +32 -1
package/package.json
CHANGED
package/src/commands/doctor.js
CHANGED
|
@@ -56,12 +56,15 @@ async function platformChecks(rootDir) {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
check('.github/platform.json', layout.kinds.length > 0, `${layout.kinds.length} kinds, plugins in ${layout.packages}/`);
|
|
59
|
-
check('platform.json', fs.existsSync(path.join(rootDir, 'platform.json')), fs.existsSync(path.join(rootDir, 'platform.json')) ? 'present' :
|
|
59
|
+
check('platform.json', fs.existsSync(path.join(rootDir, 'platform.json')), fs.existsSync(path.join(rootDir, 'platform.json')) ? 'present' : 'missing; run "wp-ops update"');
|
|
60
|
+
const themeCss = path.join(rootDir, 'wp-operations', 'style.css');
|
|
61
|
+
const themeVersion = fs.existsSync(themeCss) ? (fs.readFileSync(themeCss, 'utf8').match(/^Version:\s*(\S+)/m)?.[1] ?? '?') : '';
|
|
62
|
+
check('platform (wp-operations/)', Boolean(themeVersion), themeVersion ? `version ${themeVersion}` : 'missing; run "wp-ops update"');
|
|
60
63
|
const workflows = path.join(rootDir, '.github', 'workflows');
|
|
61
64
|
for (const name of ['composer.yml', 'deploy-apps.yml', 'deploy-platform.yml']) {
|
|
62
65
|
const present = fs.existsSync(path.join(workflows, name));
|
|
63
66
|
if (name === 'composer.yml') check(`workflow ${name}`, present, present ? '' : 'missing; "wp-ops init" adds it');
|
|
64
|
-
else if (!present) warn(`workflow ${name}`, '
|
|
67
|
+
else if (!present) warn(`workflow ${name}`, 'missing; run "wp-ops update"');
|
|
65
68
|
else check(`workflow ${name}`, true);
|
|
66
69
|
}
|
|
67
70
|
try {
|
package/src/tui.js
CHANGED
|
@@ -5,7 +5,9 @@ import { findRootDir, listApps } from './project.js';
|
|
|
5
5
|
import { startApp } from './commands/start.js';
|
|
6
6
|
import { buildAll } from './commands/build.js';
|
|
7
7
|
import { doctor } from './commands/doctor.js';
|
|
8
|
-
import
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { PLATFORM_DIR, apps, newApp, newPlugin, plugins, update } from './commands/platform.js';
|
|
9
11
|
import { ide } from './deps.js';
|
|
10
12
|
|
|
11
13
|
async function appChoices(rootDir) {
|
|
@@ -48,18 +50,24 @@ export async function tui(version) {
|
|
|
48
50
|
const rootDir = findRootDir();
|
|
49
51
|
const { hasLayout } = await ide();
|
|
50
52
|
const platform = hasLayout(rootDir);
|
|
53
|
+
const platformTheme = path.join(rootDir, PLATFORM_DIR);
|
|
54
|
+
const hasPlatform = platform && fs.existsSync(path.join(platformTheme, 'style.css'));
|
|
51
55
|
p.intro(pc.inverse(' wp-ops '));
|
|
52
56
|
|
|
53
57
|
for (;;) {
|
|
54
58
|
const action = await p.select({
|
|
55
59
|
message: 'What do you want to do?',
|
|
56
60
|
options: [
|
|
61
|
+
...(hasPlatform ? [{ value: 'platform', label: 'Start the platform', hint: 'admin / password' }] : []),
|
|
57
62
|
{ value: 'start', label: 'Start an app', hint: 'wp-app start' },
|
|
58
63
|
{ value: 'dev', label: 'Dev an app', hint: 'start + watch' },
|
|
59
64
|
...(platform
|
|
60
65
|
? [
|
|
66
|
+
{ value: 'new-app', label: 'New app' },
|
|
67
|
+
{ value: 'new-plugin', label: 'New plugin' },
|
|
61
68
|
{ value: 'apps', label: 'List apps' },
|
|
62
69
|
{ value: 'plugins', label: 'List plugins' },
|
|
70
|
+
{ value: 'update', label: 'Update the platform', hint: 'wp-operations/' },
|
|
63
71
|
]
|
|
64
72
|
: []),
|
|
65
73
|
{ value: 'build', label: 'Build all packages' },
|
|
@@ -72,6 +80,29 @@ export async function tui(version) {
|
|
|
72
80
|
return;
|
|
73
81
|
}
|
|
74
82
|
try {
|
|
83
|
+
if (action === 'platform') {
|
|
84
|
+
p.outro('Starting the platform');
|
|
85
|
+
startApp({ appDir: platformTheme, env: { ...process.env, WP_APP_HOME: process.env.WP_APP_HOME || path.join(rootDir, '.local') } });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (action === 'new-app') {
|
|
89
|
+
const kind = await p.text({ message: 'Kind (folder):', initialValue: 'service-apps' });
|
|
90
|
+
if (p.isCancel(kind)) continue;
|
|
91
|
+
const slug = await p.text({ message: 'App name:' });
|
|
92
|
+
if (p.isCancel(slug)) continue;
|
|
93
|
+
await newApp({ root: rootDir, kind, slug, server: '', appPath: '' });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (action === 'new-plugin') {
|
|
97
|
+
const name = await p.text({ message: 'Plugin (vendor/name):' });
|
|
98
|
+
if (p.isCancel(name)) continue;
|
|
99
|
+
await newPlugin({ root: rootDir, name, description: '' });
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (action === 'update') {
|
|
103
|
+
await update({ root: rootDir, version });
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
75
106
|
if (action === 'start' || action === 'dev') {
|
|
76
107
|
const appDir = await pickApp(rootDir);
|
|
77
108
|
if (!appDir) continue;
|