diff --git a/.agents/skills/upsert-process-bpmn/SKILL.md b/.agents/skills/upsert-process-bpmn/SKILL.md index c55da52..0beb0bd 100644 --- a/.agents/skills/upsert-process-bpmn/SKILL.md +++ b/.agents/skills/upsert-process-bpmn/SKILL.md @@ -19,10 +19,25 @@ BC alias: `POST /api/1.0/package-skeleton/deploy-process`. php .agents/skills/upsert-process-bpmn/scripts/sync-process.php upsert projects/{slug}/bpmn/{name}.xml ``` +## Alternative B + +Add `--alternative B` to write the BPMN to **Alternative B** of an existing process. The live process (Alternative A) is never changed. Without `--publish` it saves the B draft; with `--publish` it publishes a B version and links it to the A/B record (`process_version_b_id`). Requires package-ab-testing and a process that already exists (deploy it as A first). `version_name` is not needed for B. + +```bash +php .agents/skills/upsert-process-bpmn/scripts/sync-process.php upsert projects/{slug}/bpmn/{name}.xml --alternative B --publish +``` + +Publishing B does **not** route cases to it: A/B routing stays as configured. Check the routing expression before switching (see the `pm4-process-refactor` skill, "Run a case on B"). + ## Pull ```bash php .agents/skills/upsert-process-bpmn/scripts/sync-process.php get {name} --output projects/{slug}/bpmn/{name}.xml ``` +## Local HTTPS and updates + +- A local instance with a self-signed certificate fails with `SSL certificate problem`. Pass `--insecure` (or set `PM_INSECURE=1`) for local development only, or set `PM_CA_BUNDLE=/path/to/ca.pem` (or `CURL_CA_BUNDLE`) to keep verification on. Using `http://` for a local host also works. +- Updating an asset that already exists needs `--version-name "short change summary"`. Without it the API returns 422 and the CLI prints a hint. + Order: upsert-script-php → upsert-screen-yaml → this skill. diff --git a/.agents/skills/upsert-process-bpmn/scripts/sync-process.php b/.agents/skills/upsert-process-bpmn/scripts/sync-process.php index c26339d..e732e38 100755 --- a/.agents/skills/upsert-process-bpmn/scripts/sync-process.php +++ b/.agents/skills/upsert-process-bpmn/scripts/sync-process.php @@ -74,6 +74,7 @@ function upsertProcess(string $file, string $host, string $token, array $options if (is_string($versionName) && $versionName !== '') { $payload['version_name'] = $versionName; } + $payload += resolveAlternativePayload($options); $response = request( 'POST', @@ -86,6 +87,27 @@ function upsertProcess(string $file, string $host, string $token, array $options exit(0); } +/** + * @return array + */ +function resolveAlternativePayload(array $options): array +{ + $alternative = strtoupper((string) ($options['alternative'] ?? '')); + $publish = (bool) $options['publish']; + + if ($alternative !== '' && !in_array($alternative, ['A', 'B'], true)) { + fail('--alternative must be A or B.'); + } + if ($publish && $alternative !== 'B') { + fail('--publish is only valid with --alternative B.'); + } + if ($alternative !== 'B') { + return []; + } + + return ['alternative' => 'B', 'publish' => $publish]; +} + function getProcess( string $name, string $host, @@ -152,11 +174,10 @@ function request( $options[CURLOPT_POSTFIELDS] = $encoded; } - curl_setopt_array($handle, $options); + curl_setopt_array($handle, tlsOptions() + $options); $body = curl_exec($handle); $status = (int) curl_getinfo($handle, CURLINFO_HTTP_CODE); $error = curl_error($handle); - curl_close($handle); if ($body === false) { fail("Request failed: {$error}"); @@ -171,6 +192,7 @@ function request( ) { fwrite(STDERR, "HTTP {$status} from {$url}" . PHP_EOL); fwrite(STDERR, $body . PHP_EOL); + printVersionNameHint((string) $body); exit(1); } @@ -178,7 +200,7 @@ function request( } /** - * @return array{0: ?string, 1: ?string, 2: array{host: ?string, token: ?string, output: ?string, description: ?string, version-name: ?string}} + * @return array{0: ?string, 1: ?string, 2: array{host: ?string, token: ?string, output: ?string, description: ?string, version-name: ?string, alternative: ?string, publish: bool}} */ function parseArguments(array $arguments): array { @@ -191,11 +213,22 @@ function parseArguments(array $arguments): array 'description' => null, 'category' => null, 'version-name' => null, + 'alternative' => null, ]; + $flags = ['publish' => false]; for ($index = 0; $index < count($arguments); $index++) { $argument = $arguments[$index]; + if ($argument === '--publish') { + $flags['publish'] = true; + continue; + } + + if ($argument === '--insecure') { + continue; // Read by tlsOptions(). + } + foreach (array_keys($options) as $option) { if ($argument === "--{$option}") { $options[$option] = $arguments[++$index] ?? ''; @@ -215,7 +248,7 @@ function parseArguments(array $arguments): array fail("Unknown argument: {$argument}"); } - return [$command, $target, $options]; + return [$command, $target, $options + $flags]; } function resolvePath(string $path): string @@ -331,7 +364,11 @@ function usage(): never fwrite(STDERR, << + */ +function tlsOptions(): array +{ + $env = loadDotEnv(dirname(__DIR__, 4) . '/.env'); + $flag = strtolower((string) ($env['PM_INSECURE'] ?? getenv('PM_INSECURE') ?: '')); + if (in_array('--insecure', $GLOBALS['argv'] ?? [], true) || in_array($flag, ['1', 'true', 'yes'], true)) { + fwrite(STDERR, "Warning: TLS verification is disabled (--insecure or PM_INSECURE).\n"); + + return [CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0]; + } + + $bundle = (string) ($env['PM_CA_BUNDLE'] ?? getenv('PM_CA_BUNDLE') ?: getenv('CURL_CA_BUNDLE') ?: ''); + + return $bundle !== '' && is_file($bundle) ? [CURLOPT_CAINFO => $bundle] : []; +} + +/** + * Updating an existing asset needs a version name; say so instead of only printing the raw 422. + */ +function printVersionNameHint(string $body): void +{ + if (stripos($body, 'version name') !== false) { + fwrite(STDERR, "Hint: this asset already exists, so an update needs --version-name \"short change summary\".\n"); + } +} diff --git a/.agents/skills/upsert-screen-yaml/SKILL.md b/.agents/skills/upsert-screen-yaml/SKILL.md index e40120d..00426c0 100644 --- a/.agents/skills/upsert-screen-yaml/SKILL.md +++ b/.agents/skills/upsert-screen-yaml/SKILL.md @@ -41,4 +41,15 @@ php .agents/skills/upsert-screen-yaml/scripts/upsert-screen.php projects/{slug}/ php .agents/skills/upsert-screen-yaml/scripts/get-screen.php projects/{slug}/screens/{title}.yaml ``` +Every item in the pulled YAML carries `inspector: []` (the export drops the inspector metadata and adds the empty list back), so a pulled screen can be pushed again without editing. + +## Titles with `/` + +The YAML basename is the screen title, and a file name cannot contain `/`. For a converter title such as `PD.01 / DT.13 / Totals v1.0`, use `PD.01 - DT.13 - Totals v1.0` as the file name and push it. That creates a screen with the new title; the original keeps its old title, so point the task's `${screen:...}` ref to the new one. Do not use look-alike Unicode slashes. + +## Local HTTPS and updates + +- A local instance with a self-signed certificate fails with `SSL certificate problem`. Pass `--insecure` (or set `PM_INSECURE=1`) for local development only, or set `PM_CA_BUNDLE=/path/to/ca.pem` (or `CURL_CA_BUNDLE`) to keep verification on. Using `http://` for a local host also works. +- Updating an asset that already exists needs `--version-name "short change summary"`. Without it the API returns 422 and the CLI prints a hint. + Publish **after** scripts, **before** process BPMN. diff --git a/.agents/skills/upsert-screen-yaml/scripts/get-screen.php b/.agents/skills/upsert-screen-yaml/scripts/get-screen.php index debe783..d23dace 100755 --- a/.agents/skills/upsert-screen-yaml/scripts/get-screen.php +++ b/.agents/skills/upsert-screen-yaml/scripts/get-screen.php @@ -36,7 +36,7 @@ } if ($name === null || $name === '') { - fwrite(STDERR, "Usage: php get-screen.php path/to/screen.yaml [--host URL] [--token TOKEN]\n"); + fwrite(STDERR, "Usage: php get-screen.php path/to/screen.yaml [--host URL] [--token TOKEN] [--insecure]\n"); fwrite(STDERR, " php get-screen.php --name screen-title [--out path/to/screen.yaml]\n"); exit(1); } @@ -57,7 +57,7 @@ $url = rtrim($host, '/') . ENDPOINT_PATH . '?name=' . rawurlencode($name); $ch = curl_init($url); -curl_setopt_array($ch, [ +curl_setopt_array($ch, tlsOptions() + [ CURLOPT_HTTPGET => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, @@ -70,7 +70,6 @@ $body = curl_exec($ch); $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); -curl_close($ch); if ($body === false) { fwrite(STDERR, "Request failed: {$error}\n"); @@ -199,3 +198,26 @@ function loadDotEnv(string $path): array return $vars; } + +/** + * TLS options for a local HTTPS instance with a self-signed or private CA. + * + * --insecure or PM_INSECURE=1 skips verification (local development only). + * PM_CA_BUNDLE or CURL_CA_BUNDLE points to a CA file and keeps verification on. + * + * @return array + */ +function tlsOptions(): array +{ + $env = loadDotEnv(dirname(__DIR__, 4) . '/.env'); + $flag = strtolower((string) ($env['PM_INSECURE'] ?? getenv('PM_INSECURE') ?: '')); + if (in_array('--insecure', $GLOBALS['argv'] ?? [], true) || in_array($flag, ['1', 'true', 'yes'], true)) { + fwrite(STDERR, "Warning: TLS verification is disabled (--insecure or PM_INSECURE).\n"); + + return [CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0]; + } + + $bundle = (string) ($env['PM_CA_BUNDLE'] ?? getenv('PM_CA_BUNDLE') ?: getenv('CURL_CA_BUNDLE') ?: ''); + + return $bundle !== '' && is_file($bundle) ? [CURLOPT_CAINFO => $bundle] : []; +} diff --git a/.agents/skills/upsert-screen-yaml/scripts/upsert-screen.php b/.agents/skills/upsert-screen-yaml/scripts/upsert-screen.php index b28fb60..99fd994 100755 --- a/.agents/skills/upsert-screen-yaml/scripts/upsert-screen.php +++ b/.agents/skills/upsert-screen-yaml/scripts/upsert-screen.php @@ -22,7 +22,7 @@ [$yamlFile, $hostOverride, $tokenOverride, $versionName] = parseCliArgs(array_slice($argv, 1)); if ($yamlFile === null) { - fwrite(STDERR, "Usage: php upsert-screen.php path/to/screen.yaml [--host URL] [--token TOKEN] [--version-name TEXT]\n"); + fwrite(STDERR, "Usage: php upsert-screen.php path/to/screen.yaml [--host URL] [--token TOKEN] [--version-name TEXT] [--insecure]\n"); exit(1); } @@ -69,7 +69,7 @@ $payload = json_encode($body, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $ch = curl_init($url); -curl_setopt_array($ch, [ +curl_setopt_array($ch, tlsOptions() + [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => $payload, CURLOPT_RETURNTRANSFER => true, @@ -84,7 +84,6 @@ $body = curl_exec($ch); $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); -curl_close($ch); if ($body === false) { fwrite(STDERR, "Request failed: {$error}\n"); @@ -95,6 +94,7 @@ if (!is_array($data) || empty($data['success'])) { fwrite(STDERR, "HTTP {$status} from {$url}\n"); fwrite(STDERR, $body . "\n"); + printVersionNameHint((string) $body); exit(1); } @@ -188,3 +188,36 @@ function loadDotEnv(string $path): array return $vars; } + +/** + * TLS options for a local HTTPS instance with a self-signed or private CA. + * + * --insecure or PM_INSECURE=1 skips verification (local development only). + * PM_CA_BUNDLE or CURL_CA_BUNDLE points to a CA file and keeps verification on. + * + * @return array + */ +function tlsOptions(): array +{ + $env = loadDotEnv(dirname(__DIR__, 4) . '/.env'); + $flag = strtolower((string) ($env['PM_INSECURE'] ?? getenv('PM_INSECURE') ?: '')); + if (in_array('--insecure', $GLOBALS['argv'] ?? [], true) || in_array($flag, ['1', 'true', 'yes'], true)) { + fwrite(STDERR, "Warning: TLS verification is disabled (--insecure or PM_INSECURE).\n"); + + return [CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0]; + } + + $bundle = (string) ($env['PM_CA_BUNDLE'] ?? getenv('PM_CA_BUNDLE') ?: getenv('CURL_CA_BUNDLE') ?: ''); + + return $bundle !== '' && is_file($bundle) ? [CURLOPT_CAINFO => $bundle] : []; +} + +/** + * Updating an existing asset needs a version name; say so instead of only printing the raw 422. + */ +function printVersionNameHint(string $body): void +{ + if (stripos($body, 'version name') !== false) { + fwrite(STDERR, "Hint: this asset already exists, so an update needs --version-name \"short change summary\".\n"); + } +} diff --git a/.agents/skills/upsert-script-php/SKILL.md b/.agents/skills/upsert-script-php/SKILL.md index 68189c1..d480c67 100644 --- a/.agents/skills/upsert-script-php/SKILL.md +++ b/.agents/skills/upsert-script-php/SKILL.md @@ -13,7 +13,11 @@ Auth: Bearer `PM_SYNC_TOKEN`, base `PM_BASE_URL` in package root `.env` (set by `POST /api/1.0/deploy-script` — on **update**, required `version_name` → Version History `subject` (package-versions) -Body: `name` (title), `code` (full PHP), optional `description` and `script_category_name`. +Body: `name` (title), `code` (full PHP), optional `description`, `script_category_name`, and `script_executor_id` or `script_executor_title` (a `php` executor; the id wins). + +### Executor + +Without an executor, a new script goes to the first `php` executor on the instance. A plugin that runs its own classes in a script (`use ProcessMaker\Package\...`) needs the **plugin executor** (the one built with this package), so pass it: `--executor 13` (id) or `--executor "my-executor"` (title), or set `PM_SCRIPT_EXECUTOR` in `.env`. The option also moves an existing script to that executor on update. An update without it keeps the current executor. A missing executor or one that is not `php` returns 422. Sidecars (same basename as the script): `{name}.description.txt`, `{name}.category.txt` (default category **Uncategorized** when the category file is absent). @@ -37,6 +41,11 @@ XDEBUG_MODE=off php .agents/skills/upsert-script-php/scripts/get-script.php --na Do not reimplement HTTP. Do not `git commit` unless asked. +## Local HTTPS and updates + +- A local instance with a self-signed certificate fails with `SSL certificate problem`. Pass `--insecure` (or set `PM_INSECURE=1`) for local development only, or set `PM_CA_BUNDLE=/path/to/ca.pem` (or `CURL_CA_BUNDLE`) to keep verification on. Using `http://` for a local host also works. +- Updating an asset that already exists needs `--version-name "short change summary"`. Without it the API returns 422 and the CLI prints a hint. + ## Compose | Next step | Skill | diff --git a/.agents/skills/upsert-script-php/scripts/get-script.php b/.agents/skills/upsert-script-php/scripts/get-script.php index e900031..f03071e 100755 --- a/.agents/skills/upsert-script-php/scripts/get-script.php +++ b/.agents/skills/upsert-script-php/scripts/get-script.php @@ -29,7 +29,7 @@ } if ($name === null || $name === '') { - fwrite(STDERR, "Usage: php get-script.php path/to/script.php [--host URL] [--token TOKEN]\n"); + fwrite(STDERR, "Usage: php get-script.php path/to/script.php [--host URL] [--token TOKEN] [--insecure]\n"); fwrite(STDERR, " php get-script.php --name script-title [--out path/to/script.php]\n"); exit(1); } @@ -56,7 +56,7 @@ $url = rtrim($host, '/') . ENDPOINT_PATH . '?name=' . rawurlencode($name); $ch = curl_init($url); -curl_setopt_array($ch, [ +curl_setopt_array($ch, tlsOptions() + [ CURLOPT_HTTPGET => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, @@ -69,7 +69,6 @@ $body = curl_exec($ch); $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); -curl_close($ch); if ($body === false) { fwrite(STDERR, "Request failed: {$error}\n"); @@ -209,3 +208,26 @@ function loadDotEnv(string $path): array return $vars; } + +/** + * TLS options for a local HTTPS instance with a self-signed or private CA. + * + * --insecure or PM_INSECURE=1 skips verification (local development only). + * PM_CA_BUNDLE or CURL_CA_BUNDLE points to a CA file and keeps verification on. + * + * @return array + */ +function tlsOptions(): array +{ + $env = loadDotEnv(dirname(__DIR__, 4) . '/.env'); + $flag = strtolower((string) ($env['PM_INSECURE'] ?? getenv('PM_INSECURE') ?: '')); + if (in_array('--insecure', $GLOBALS['argv'] ?? [], true) || in_array($flag, ['1', 'true', 'yes'], true)) { + fwrite(STDERR, "Warning: TLS verification is disabled (--insecure or PM_INSECURE).\n"); + + return [CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0]; + } + + $bundle = (string) ($env['PM_CA_BUNDLE'] ?? getenv('PM_CA_BUNDLE') ?: getenv('CURL_CA_BUNDLE') ?: ''); + + return $bundle !== '' && is_file($bundle) ? [CURLOPT_CAINFO => $bundle] : []; +} diff --git a/.agents/skills/upsert-script-php/scripts/upsert-script.php b/.agents/skills/upsert-script-php/scripts/upsert-script.php index ebd3b31..4ffd502 100755 --- a/.agents/skills/upsert-script-php/scripts/upsert-script.php +++ b/.agents/skills/upsert-script-php/scripts/upsert-script.php @@ -6,7 +6,8 @@ * * POST /api/1.0/deploy-script (ProcessMaker core) * - * Reads PM_BASE_URL and PM_SYNC_TOKEN from the package root .env + * Reads PM_BASE_URL, PM_SYNC_TOKEN and the optional PM_SCRIPT_EXECUTOR + * (executor id or title) from the package root .env */ const ENDPOINT_PATH = '/api/1.0/deploy-script'; @@ -14,10 +15,10 @@ $projectRoot = dirname(__DIR__, 4); $envPath = $projectRoot . '/.env'; -[$phpFile, $hostOverride, $tokenOverride, $versionName] = parseCliArgs(array_slice($argv, 1)); +[$phpFile, $hostOverride, $tokenOverride, $versionName, $executorOverride] = parseCliArgs(array_slice($argv, 1)); if ($phpFile === null) { - fwrite(STDERR, "Usage: php upsert-script.php path/to/script.php [--host URL] [--token TOKEN] [--version-name TEXT]\n"); + fwrite(STDERR, "Usage: php upsert-script.php path/to/script.php [--host URL] [--token TOKEN] [--version-name TEXT] [--executor ID|TITLE] [--insecure]\n"); exit(1); } @@ -51,6 +52,11 @@ exit(1); } +$executor = $executorOverride ?: firstNonEmpty( + $env['PM_SCRIPT_EXECUTOR'] ?? null, + getenv('PM_SCRIPT_EXECUTOR') ?: null +); + $name = pathinfo($phpPath, PATHINFO_FILENAME); $code = file_get_contents($phpPath); if ($code === false) { @@ -75,10 +81,15 @@ if ($versionName !== null && $versionName !== '') { $body['version_name'] = $versionName; } +if ($executor !== '') { + // A number is an executor id, anything else is the executor title. + $body[ctype_digit($executor) ? 'script_executor_id' : 'script_executor_title'] = + ctype_digit($executor) ? (int) $executor : $executor; +} $payload = json_encode($body, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $ch = curl_init($url); -curl_setopt_array($ch, [ +curl_setopt_array($ch, tlsOptions() + [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => $payload, CURLOPT_RETURNTRANSFER => true, @@ -93,7 +104,6 @@ $body = curl_exec($ch); $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); -curl_close($ch); if ($body === false) { fwrite(STDERR, "Request failed: {$error}\n"); @@ -104,6 +114,7 @@ if (!is_array($data) || empty($data['success'])) { fwrite(STDERR, "HTTP {$status} from {$url}\n"); fwrite(STDERR, $body . "\n"); + printVersionNameHint((string) $body); exit(1); } @@ -117,7 +128,7 @@ exit(0); /** - * @return array{0: ?string, 1: ?string, 2: ?string, 3: ?string} + * @return array{0: ?string, 1: ?string, 2: ?string, 3: ?string, 4: ?string} */ function parseCliArgs(array $args): array { @@ -125,6 +136,7 @@ function parseCliArgs(array $args): array $host = null; $token = null; $versionName = null; + $executor = null; for ($i = 0; $i < count($args); $i++) { $arg = $args[$i]; @@ -140,6 +152,14 @@ function parseCliArgs(array $args): array $versionName = $args[++$i] ?? ''; continue; } + if ($arg === '--executor') { + $executor = $args[++$i] ?? ''; + continue; + } + if (str_starts_with($arg, '--executor=')) { + $executor = substr($arg, 11); + continue; + } if (str_starts_with($arg, '--host=')) { $host = substr($arg, 7); continue; @@ -157,7 +177,7 @@ function parseCliArgs(array $args): array } } - return [$phpFile, $host, $token, $versionName]; + return [$phpFile, $host, $token, $versionName, $executor]; } function resolvePath(string $path, string $cwd): string @@ -225,3 +245,36 @@ function loadDotEnv(string $path): array return $vars; } + +/** + * TLS options for a local HTTPS instance with a self-signed or private CA. + * + * --insecure or PM_INSECURE=1 skips verification (local development only). + * PM_CA_BUNDLE or CURL_CA_BUNDLE points to a CA file and keeps verification on. + * + * @return array + */ +function tlsOptions(): array +{ + $env = loadDotEnv(dirname(__DIR__, 4) . '/.env'); + $flag = strtolower((string) ($env['PM_INSECURE'] ?? getenv('PM_INSECURE') ?: '')); + if (in_array('--insecure', $GLOBALS['argv'] ?? [], true) || in_array($flag, ['1', 'true', 'yes'], true)) { + fwrite(STDERR, "Warning: TLS verification is disabled (--insecure or PM_INSECURE).\n"); + + return [CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0]; + } + + $bundle = (string) ($env['PM_CA_BUNDLE'] ?? getenv('PM_CA_BUNDLE') ?: getenv('CURL_CA_BUNDLE') ?: ''); + + return $bundle !== '' && is_file($bundle) ? [CURLOPT_CAINFO => $bundle] : []; +} + +/** + * Updating an existing asset needs a version name; say so instead of only printing the raw 422. + */ +function printVersionNameHint(string $body): void +{ + if (stripos($body, 'version name') !== false) { + fwrite(STDERR, "Hint: this asset already exists, so an update needs --version-name \"short change summary\".\n"); + } +} diff --git a/.env.example b/.env.example index cffacce..7fdc464 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,8 @@ # ProcessMaker sync target (used by deploy scripts and local tooling). PM_BASE_URL=__PROCESSMAKER_SERVER__ PM_SYNC_TOKEN= +# Optional: executor id or title for new scripts (the plugin executor, php only). +PM_SCRIPT_EXECUTOR= +# Optional, local HTTPS with a self-signed certificate: a CA file, or PM_INSECURE=1 to skip verification. +PM_CA_BUNDLE= +PM_INSECURE= diff --git a/AGENTS.md b/AGENTS.md index 52cddca..69a7d46 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -192,7 +192,7 @@ MCP (`/mcp/screens`, `/mcp/processes`) is optional for authoring; git → instan Before publishing or handing off a new screen: - Run ESLint on modified Vue/JavaScript source. -- Run relevant Storybook interaction tests for loading, empty, error, success, and submit/cancel behavior. +- Run relevant Storybook interaction tests for loading, empty, error, success, and submit/cancel behavior. The first `npm run test-storybook` can fail with `__test is not defined` while Vite optimizes dependencies: start `npm run storybook`, open it once, and run the tests again. If Playwright reports "Executable doesn't exist", run `npx playwright install chromium`. - After Storybook verification, list each relevant story as a markdown link `[ExportName](http://127.0.0.1:7007/?path=/story/)`. - Review SonarQube findings introduced in `resources/js/projects/**`; fix new Blocker, Critical, and Major issues. - Guard `this.data` in `handlerVue`. @@ -272,6 +272,23 @@ docker exec -it --env-file /compose/envs/app.env.testing pm4_core \ ./vendor/bin/phpunit storage/plugins/{package-name}/tests/{test_path} ``` +PHPUnit 12 ignores `@dataProvider` annotations (the test then fails with `ArgumentCountError`). Use the attribute and a static provider: + +```php +use PHPUnit\Framework\Attributes\DataProvider; + +#[DataProvider('cases')] +public function testSomething(string $input, string $expected): void +{ + // ... +} + +public static function cases(): array +{ + return ['empty' => ['', '']]; +} +``` + Script tasks usually expect a global `$data` and return an array. Script wrapper tests live under `tests/Unit/Documentation` when present. ## Cross-domain architecture diff --git a/phpcs.xml b/phpcs.xml index ef5e7a9..b66ea62 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -2,6 +2,8 @@ PHP_CodeSniffer configuration + + diff --git a/rename-project.php b/rename-project.php index df18edf..57ec7d5 100644 --- a/rename-project.php +++ b/rename-project.php @@ -606,6 +606,7 @@ function setupGitRepository(string $projectRoot, string $repoUrl, string $branch 'pm4-pm-block', 'pm4-process', 'pm4-process-health', + 'pm4-process-refactor', 'pm4-screen', 'pm4-script', 'pm4-send-email', diff --git a/routes/web.php b/routes/web.php index cffcc8f..6cfc6ea 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,6 +3,8 @@ use ProcessMaker\Package\PackageSkeleton\Http\Controllers\PackageSkeletonController; Route::group(['middleware' => ['auth']], function () { - Route::get('admin/package-skeleton', [PackageSkeletonController::class, 'index'])->name('package.skeleton.index'); - Route::get('package-skeleton', [PackageSkeletonController::class, 'index'])->name('package.skeleton.tab.index'); + Route::get('admin/package-skeleton', [PackageSkeletonController::class, 'index']) + ->name('package.skeleton.index'); + Route::get('package-skeleton', [PackageSkeletonController::class, 'index']) + ->name('package.skeleton.tab.index'); }); diff --git a/src/Traits/ValidatesWithJsonSchema.php b/src/Traits/ValidatesWithJsonSchema.php index c921e8b..ec89785 100644 --- a/src/Traits/ValidatesWithJsonSchema.php +++ b/src/Traits/ValidatesWithJsonSchema.php @@ -18,7 +18,7 @@ trait ValidatesWithJsonSchema protected ?\Swaggest\JsonSchema\RemoteRef\Preloaded $refProvider = null; - /** @var array */ + /** @var array */ protected array $attributes = []; /** @var array */ diff --git a/stories/RenderTemplate.stories.js b/stories/RenderTemplate.stories.js index d309fdd..a62b833 100644 --- a/stories/RenderTemplate.stories.js +++ b/stories/RenderTemplate.stories.js @@ -2,6 +2,20 @@ import { expect, within } from '@storybook/test'; import RenderTemplate from '../resources/js/components/screen-builder/freeEditor/RenderTemplate'; +/** + * First SFC under resources/js/projects, as the catalog key Screen Builder stores + * ("@/projects/..."). A fresh plugin has none yet, so the catalog story falls back to a + * plain template instead of failing. + */ +const [firstProjectModule] = Object.keys(import.meta.glob('../resources/js/projects/**/*.vue')); +const projectComponentKey = firstProjectModule + ? firstProjectModule.replace('../resources/js/', '@/') + : null; +const projectComponentName = projectComponentKey + ? projectComponentKey.split('/').pop().replace('.vue', '') + : null; +const kebabCase = (name) => name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); + function renderWithDeclaredComponents(args) { return { components: { RenderTemplate }, @@ -24,19 +38,28 @@ export default { /** * Screen Builder Preview and request runtime mount this renderer directly and pass * `components` exactly as stored on the screen: a list of { name, key }. + * Uses the first project component found; without one it checks a plain template. */ export const CatalogComponentsFromScreenConfig = { - args: { - contentVue: '', - handlerVue: 'return {};', - components: [ - { name: 'PtoRequest', key: '@/projects/pto/request/PtoRequest.vue' }, - ], - }, + args: projectComponentKey + ? { + contentVue: `<${projectComponentName} v-model="data" :submit="submit" />`, + handlerVue: 'return {};', + components: [{ name: projectComponentName, key: projectComponentKey }], + } + : { + contentVue: '

No project component yet

', + handlerVue: 'return {};', + components: [], + }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); - await expect(await canvas.findByRole('heading', { name: 'Request PTO' })).toBeTruthy(); - await expect(canvas.getByRole('button', { name: 'Submit request' })).toBeTruthy(); + if (!projectComponentKey) { + await expect(canvas.getByText('No project component yet')).toBeTruthy(); + return; + } + // An unresolved key would leave the literal custom element in the DOM. + await expect(canvasElement.querySelector(kebabCase(projectComponentName))).toBeNull(); }, };