@wp-operations/wp-ops 0.5.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-operations/wp-ops",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
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",
@@ -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' : "missing; copy the theme's platform.json to the root");
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}`, 'not found; the theme dispatches it for deploys (the name is set in Settings → Operations)');
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/templates.js CHANGED
@@ -228,19 +228,21 @@ ${SSH_SETUP}
228
228
  env:
229
229
  SERVERS: \${{ secrets.SERVERS }}
230
230
  run: |
231
- SERVER_LABEL=$(jq -r '.platform.server' .github/platform.json)
232
- APP_PATH=$(jq -r '.platform.app_path' .github/platform.json)
231
+ SERVER_LABEL=$(jq -r '.platform.server // ""' .github/platform.json)
232
+ APP_PATH=$(jq -r '.platform.app_path // ""' .github/platform.json)
233
233
  THEME_SLUG=$(jq -r '.platform.theme_slug // "wp-operations"' .github/platform.json)
234
- if [ -z "$SERVER_LABEL" ] || [ -z "$APP_PATH" ]; then echo "Set platform.server and platform.app_path in .github/platform.json."; exit 1; fi
234
+ if [ -z "$SERVER_LABEL" ] || [ -z "$APP_PATH" ]; then echo "::notice::Set platform.server and platform.app_path in .github/platform.json to deploy the platform."; echo "skip=true" >> "$GITHUB_OUTPUT"; exit 0; fi
235
235
  ${SERVER_LOOKUP}
236
236
  echo "target=$SSH_USER@$SERVER_IP" >> "$GITHUB_OUTPUT"
237
237
  echo "app_path=$APP_PATH" >> "$GITHUB_OUTPUT"
238
238
  echo "theme_slug=$THEME_SLUG" >> "$GITHUB_OUTPUT"
239
239
 
240
240
  - name: Use this repository's platform.json
241
+ if: steps.target.outputs.skip != 'true'
241
242
  run: cp platform.json wp-operations/platform.json
242
243
 
243
244
  - name: Deploy via rsync
245
+ if: steps.target.outputs.skip != 'true'
244
246
  uses: nick-fields/retry@v3
245
247
  with:
246
248
  timeout_minutes: 5
@@ -253,6 +255,7 @@ ${SERVER_LOOKUP}
253
255
  \${{ steps.target.outputs.target }}:\${{ steps.target.outputs.app_path }}/wp-content/themes/\${{ steps.target.outputs.theme_slug }}/
254
256
 
255
257
  - name: Activate the platform and flush cache
258
+ if: steps.target.outputs.skip != 'true'
256
259
  uses: nick-fields/retry@v3
257
260
  with:
258
261
  timeout_minutes: 5
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 { apps, plugins } from './commands/platform.js';
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;