@wpmoo/toolkit 0.9.3 → 0.9.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/dist/cli.js CHANGED
@@ -14,6 +14,7 @@ import { isDailyActionCommand, runDailyAction } from './daily-actions.js';
14
14
  import { getDoctorReport, runDoctor } from './doctor.js';
15
15
  import { getOriginUrl, realGit } from './git.js';
16
16
  import { renderHelp } from './help.js';
17
+ import { runLocalCockpit } from './local-cockpit.js';
17
18
  import { addModuleToSourceRepo, listModulesInSourceRepo, removeModuleFromSourceRepo, } from './module-actions.js';
18
19
  import { supportedOdooVersions } from './odoo-versions.js';
19
20
  import { renderRepositorySetupNote } from './prompt-copy.js';
@@ -114,10 +115,25 @@ function jsonOption(values) {
114
115
  function printJson(value) {
115
116
  console.log(JSON.stringify(value));
116
117
  }
117
- function yellow(value) {
118
- if (!process.stdout.isTTY || process.env.NO_COLOR !== undefined)
118
+ function supportsAnsi() {
119
+ return Boolean(process.stdout.isTTY) && process.env.NO_COLOR === undefined;
120
+ }
121
+ function ansi(value, open, close) {
122
+ if (!supportsAnsi())
119
123
  return value;
120
- return `\u001b[33m${value}\u001b[39m`;
124
+ return `${open}${value}${close}`;
125
+ }
126
+ function yellow(value) {
127
+ return ansi(value, '\u001B[33m', '\u001B[39m');
128
+ }
129
+ function cyan(value) {
130
+ return ansi(value, '\u001B[36m', '\u001B[39m');
131
+ }
132
+ function boldGreen(value) {
133
+ return ansi(value, '\u001B[1m\u001B[32m', '\u001B[39m\u001B[22m');
134
+ }
135
+ function dim(value) {
136
+ return ansi(value, '\u001B[2m', '\u001B[22m');
121
137
  }
122
138
  function shellQuote(value) {
123
139
  if (/^[A-Za-z0-9_./:-]+$/.test(value))
@@ -132,12 +148,22 @@ function renderedSourceRepoPath(target, sourceType, repoPath) {
132
148
  }
133
149
  function renderPostCreateGuidance(target, cwd) {
134
150
  const relativeTarget = relative(cwd, target) || '.';
135
- return yellow([
136
- 'Environment is ready. Enter the development folder, then run the local WPMoo cockpit:',
151
+ const cdCommand = `cd ${shellQuote(relativeTarget)}`;
152
+ if (!supportsAnsi()) {
153
+ return [
154
+ 'Environment is ready. Open it now, or copy these commands:',
155
+ '',
156
+ cdCommand,
157
+ './moo',
158
+ ].join('\n');
159
+ }
160
+ return [
161
+ boldGreen('✓ Environment is ready.'),
162
+ cyan('Open it now, or copy these commands:'),
137
163
  '',
138
- `cd ${shellQuote(relativeTarget)}`,
139
- './moo',
140
- ].join('\n'));
164
+ yellow(cdCommand),
165
+ yellow('./moo'),
166
+ ].join('\n');
141
167
  }
142
168
  function validateRepoName(value) {
143
169
  const normalized = value.trim();
@@ -260,7 +286,7 @@ async function resolveEnvironmentTargetFromPrompts(product, cancelAction) {
260
286
  message: 'This environment folder already exists. What do you want to do?',
261
287
  options: [
262
288
  { value: 'update-existing', label: 'Update existing environment' },
263
- { value: 'reinstall-environment', label: 'Reinstall environment from backup' },
289
+ { value: 'reinstall-environment', label: 'Back up existing environment folder and create a new one' },
264
290
  { value: 'delete-environment', label: 'Delete environment' },
265
291
  { value: 'cancel', label: 'Cancel' },
266
292
  ],
@@ -837,11 +863,11 @@ async function ensureGitHubRepositories(options, interactive) {
837
863
  throw new Error(`Dev environment repository is non-empty or could not be verified: ${blocked.map((repo) => repo.slug).join(', ')}`);
838
864
  }
839
865
  if (interactive && accessible.length > 0) {
840
- notePrompt([
866
+ notePrompt(dim([
841
867
  'These GitHub repositories already exist and are accessible:',
842
868
  '',
843
869
  ...accessible.map((repository) => `- ${repository.label}: ${repository.slug}`),
844
- ].join('\n'), 'Repository check');
870
+ ].join('\n')), 'Repository check');
845
871
  }
846
872
  if (missing.length === 0) {
847
873
  return;
@@ -922,7 +948,19 @@ async function finishCreateFlow(result, cwd, interactive) {
922
948
  console.log(`- ${command}`);
923
949
  return;
924
950
  }
925
- notePrompt(renderPostCreateGuidance(options.target, cwd), 'Next steps');
951
+ notePrompt(renderPostCreateGuidance(options.target, cwd), 'Next steps', { indent: false });
952
+ if (interactive) {
953
+ const shouldOpenCockpit = await confirmPrompt({
954
+ message: 'Open the local WPMoo cockpit now?',
955
+ active: 'Y',
956
+ inactive: 'n',
957
+ initialValue: true,
958
+ });
959
+ if (shouldOpenCockpit === true) {
960
+ await runLocalCockpit(options.target);
961
+ return;
962
+ }
963
+ }
926
964
  outroPrompt(`Created Odoo dev overlay in ${options.target}. Review staged changes, then commit.`);
927
965
  }
928
966
  async function runCockpitCommand(command, cwd) {
@@ -0,0 +1,15 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { join } from 'node:path';
3
+ export async function runLocalCockpit(target) {
4
+ const child = spawn(join(target, 'moo'), [], {
5
+ cwd: target,
6
+ stdio: 'inherit',
7
+ });
8
+ const exitCode = await new Promise((resolve, reject) => {
9
+ child.on('error', reject);
10
+ child.on('close', resolve);
11
+ });
12
+ if (exitCode !== 0) {
13
+ throw new Error(`Local WPMoo cockpit exited with code ${exitCode ?? 'unknown'}: ${join(target, 'moo')}`);
14
+ }
15
+ }
@@ -162,11 +162,12 @@ export function introPrompt(title) {
162
162
  console.log(title);
163
163
  console.log(rule);
164
164
  }
165
- export function notePrompt(message, title = 'Note') {
165
+ export function notePrompt(message, title = 'Note', options = {}) {
166
166
  const lines = message.split('\n');
167
+ const prefix = options.indent === false ? '' : ' ';
167
168
  console.log(`[${title}]`);
168
169
  for (const line of lines) {
169
- console.log(` ${line}`);
170
+ console.log(`${prefix}${line}`);
170
171
  }
171
172
  }
172
173
  export function outroPrompt(message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpmoo/toolkit",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "WPMoo Toolkit for development, staging, and production lifecycle workflows.",
5
5
  "type": "module",
6
6
  "repository": {