@cbnventures/nova 0.38.0 → 0.40.0
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/build/package.json +1 -1
- package/build/scaffold-versions.json +10 -9
- package/build/src/api/app-store-connect.d.ts +17 -2
- package/build/src/api/app-store-connect.d.ts.map +1 -1
- package/build/src/api/app-store-connect.js +654 -171
- package/build/src/api/app-store-connect.js.map +1 -1
- package/build/src/api/docker-hub.d.ts +14 -0
- package/build/src/api/docker-hub.d.ts.map +1 -0
- package/build/src/api/docker-hub.js +275 -0
- package/build/src/api/docker-hub.js.map +1 -0
- package/build/src/api/github-runner-images.d.ts +13 -0
- package/build/src/api/github-runner-images.d.ts.map +1 -0
- package/build/src/api/github-runner-images.js +238 -0
- package/build/src/api/github-runner-images.js.map +1 -0
- package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts +2 -2
- package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint-validate.js +260 -50
- package/build/src/cli/generate/github/workflows-blueprint-validate.js.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint.d.ts +6 -4
- package/build/src/cli/generate/github/workflows-blueprint.d.ts.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint.js +632 -74
- package/build/src/cli/generate/github/workflows-blueprint.js.map +1 -1
- package/build/src/cli/generate/must-haves/agent-conventions.d.ts.map +1 -1
- package/build/src/cli/generate/must-haves/agent-conventions.js +1 -0
- package/build/src/cli/generate/must-haves/agent-conventions.js.map +1 -1
- package/build/src/cli/index.js +41 -1
- package/build/src/cli/index.js.map +1 -1
- package/build/src/cli/integration/app-store-connect.d.ts +10 -0
- package/build/src/cli/integration/app-store-connect.d.ts.map +1 -1
- package/build/src/cli/integration/app-store-connect.js +701 -80
- package/build/src/cli/integration/app-store-connect.js.map +1 -1
- package/build/src/cli/recipe/docker-hub/docker-hub-precheck.d.ts +3 -0
- package/build/src/cli/recipe/docker-hub/docker-hub-precheck.d.ts.map +1 -0
- package/build/src/cli/recipe/docker-hub/docker-hub-precheck.js +72 -0
- package/build/src/cli/recipe/docker-hub/docker-hub-precheck.js.map +1 -0
- package/build/src/cli/recipe/docker-hub/sync-identity.d.ts +5 -0
- package/build/src/cli/recipe/docker-hub/sync-identity.d.ts.map +1 -0
- package/build/src/cli/recipe/docker-hub/sync-identity.js +124 -0
- package/build/src/cli/recipe/docker-hub/sync-identity.js.map +1 -0
- package/build/src/cli/recipe/docker-hub/sync-policies.d.ts +5 -0
- package/build/src/cli/recipe/docker-hub/sync-policies.d.ts.map +1 -0
- package/build/src/cli/recipe/docker-hub/sync-policies.js +63 -0
- package/build/src/cli/recipe/docker-hub/sync-policies.js.map +1 -0
- package/build/src/cli/recipe/index.d.ts.map +1 -1
- package/build/src/cli/recipe/index.js +12 -0
- package/build/src/cli/recipe/index.js.map +1 -1
- package/build/src/cli/recipe/nova-config/normalize-order.js +3 -3
- package/build/src/cli/recipe/nova-config/normalize-order.js.map +1 -1
- package/build/src/cli/scaffold/package/pfsense.d.ts +3 -0
- package/build/src/cli/scaffold/package/pfsense.d.ts.map +1 -1
- package/build/src/cli/scaffold/package/pfsense.js +140 -6
- package/build/src/cli/scaffold/package/pfsense.js.map +1 -1
- package/build/src/cli/scaffold/tool/serverless.d.ts +2 -0
- package/build/src/cli/scaffold/tool/serverless.d.ts.map +1 -1
- package/build/src/cli/scaffold/tool/serverless.js +35 -1
- package/build/src/cli/scaffold/tool/serverless.js.map +1 -1
- package/build/src/cli/utility/changelog.d.ts +7 -0
- package/build/src/cli/utility/changelog.d.ts.map +1 -1
- package/build/src/cli/utility/changelog.js +800 -7
- package/build/src/cli/utility/changelog.js.map +1 -1
- package/build/src/cli/utility/configure.d.ts +4 -1
- package/build/src/cli/utility/configure.d.ts.map +1 -1
- package/build/src/cli/utility/configure.js +396 -24
- package/build/src/cli/utility/configure.js.map +1 -1
- package/build/src/lib/docker-packaging.d.ts +1 -0
- package/build/src/lib/docker-packaging.d.ts.map +1 -1
- package/build/src/lib/docker-packaging.js +39 -2
- package/build/src/lib/docker-packaging.js.map +1 -1
- package/build/src/lib/env-namespace.d.ts.map +1 -1
- package/build/src/lib/env-namespace.js +2 -1
- package/build/src/lib/env-namespace.js.map +1 -1
- package/build/src/lib/item.d.ts +2 -1
- package/build/src/lib/item.d.ts.map +1 -1
- package/build/src/lib/item.js +23 -0
- package/build/src/lib/item.js.map +1 -1
- package/build/src/lib/nova-config-order.d.ts.map +1 -1
- package/build/src/lib/nova-config-order.js +35 -1
- package/build/src/lib/nova-config-order.js.map +1 -1
- package/build/src/lib/nova-config.d.ts +1 -0
- package/build/src/lib/nova-config.d.ts.map +1 -1
- package/build/src/lib/nova-config.js +178 -3
- package/build/src/lib/nova-config.js.map +1 -1
- package/build/src/lib/regex.d.ts +16 -0
- package/build/src/lib/regex.d.ts.map +1 -1
- package/build/src/lib/regex.js +16 -0
- package/build/src/lib/regex.js.map +1 -1
- package/build/src/lib/scaffold.d.ts +3 -3
- package/build/src/lib/scaffold.d.ts.map +1 -1
- package/build/src/lib/scaffold.js +111 -8
- package/build/src/lib/scaffold.js.map +1 -1
- package/build/src/lib/schema.d.ts +34 -0
- package/build/src/lib/schema.d.ts.map +1 -1
- package/build/src/lib/schema.js +31 -0
- package/build/src/lib/schema.js.map +1 -1
- package/build/src/lib/workflow-templates.d.ts +4 -1
- package/build/src/lib/workflow-templates.d.ts.map +1 -1
- package/build/src/lib/workflow-templates.js +46 -16
- package/build/src/lib/workflow-templates.js.map +1 -1
- package/build/src/types/api/app-store-connect.d.ts +476 -33
- package/build/src/types/api/docker-hub.d.ts +237 -0
- package/build/src/types/api/github-runner-images.d.ts +199 -0
- package/build/src/types/cli/generate/github/workflows-blueprint-validate.d.ts +79 -17
- package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +131 -9
- package/build/src/types/cli/index.d.ts +2 -0
- package/build/src/types/cli/integration/app-store-connect.d.ts +470 -6
- package/build/src/types/cli/recipe/docker-hub/docker-hub-precheck.d.ts +78 -0
- package/build/src/types/cli/recipe/docker-hub/sync-identity.d.ts +80 -0
- package/build/src/types/cli/recipe/docker-hub/sync-policies.d.ts +57 -0
- package/build/src/types/cli/recipe/index.d.ts +3 -1
- package/build/src/types/cli/scaffold/package/pfsense.d.ts +83 -0
- package/build/src/types/cli/scaffold/tool/serverless.d.ts +30 -0
- package/build/src/types/cli/utility/changelog.d.ts +327 -1
- package/build/src/types/cli/utility/configure.d.ts +199 -4
- package/build/src/types/lib/docker-packaging.d.ts +25 -1
- package/build/src/types/lib/env-namespace.d.ts +4 -1
- package/build/src/types/lib/item.d.ts +11 -0
- package/build/src/types/lib/nova-config-order.d.ts +34 -1
- package/build/src/types/lib/nova-config.d.ts +100 -0
- package/build/src/types/lib/regex.d.ts +91 -0
- package/build/src/types/lib/scaffold.d.ts +48 -4
- package/build/src/types/lib/workflow-templates.d.ts +26 -0
- package/build/src/types/shared.d.ts +353 -3
- package/build/src/types/tests/api/app-store-connect.test.d.ts +162 -0
- package/build/src/types/tests/api/docker-hub.test.d.ts +84 -0
- package/build/src/types/tests/api/github-runner-images.test.d.ts +113 -0
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-generate.test.d.ts +19 -0
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-parity.test.d.ts +0 -9
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-publish-parity.test.d.ts +108 -25
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-validate.test.d.ts +139 -30
- package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +45 -0
- package/build/src/types/tests/cli/generate/github/workflows-version-contract.test.d.ts +2 -2
- package/build/src/types/tests/cli/generate/must-haves/agent-conventions.test.d.ts +2 -0
- package/build/src/types/tests/cli/integration/app-store-connect.test.d.ts +876 -0
- package/build/src/types/tests/cli/recipe/nova-config/normalize-order.test.d.ts +4 -0
- package/build/src/types/tests/cli/scaffold/tool/serverless.test.d.ts +21 -0
- package/build/src/types/tests/cli/utility/changelog-android.test.d.ts +14 -0
- package/build/src/types/tests/cli/utility/changelog-apple.test.d.ts +21 -0
- package/build/src/types/tests/cli/utility/changelog-fold.test.d.ts +350 -0
- package/build/src/types/tests/cli/utility/changelog.test.d.ts +50 -0
- package/build/src/types/tests/cli/utility/configure.test.d.ts +90 -0
- package/build/src/types/tests/lib/nova-config.test.d.ts +29 -1
- package/build/src/types/tests/lib/scaffold.test.d.ts +59 -2
- package/build/src/types/tests/scaffold-output-contract.test.d.ts +136 -0
- package/build/templates/generators/must-haves/agent-conventions/AGENTS.md +1 -0
- package/build/templates/generators/must-haves/agent-conventions/CLAUDE.md +1 -0
- package/build/templates/generators/must-haves/agent-conventions/conventions/nova.md +6 -0
- package/build/templates/generators/must-haves/agent-conventions/conventions/pfsense.md +311 -0
- package/build/templates/scaffold/app/android/package.json +1 -1
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-ios-1024.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-128.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-128@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-16.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-16@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-256.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-256@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-32.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-32@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-512.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-512@2x.png +0 -0
- package/build/templates/scaffold/app/apple/package.json +1 -1
- package/build/templates/scaffold/app/astro/package.json +1 -1
- package/build/templates/scaffold/app/discord-bot/package.json +1 -1
- package/build/templates/scaffold/app/express/package.json +1 -1
- package/build/templates/scaffold/app/nextjs/package.json +1 -1
- package/build/templates/scaffold/app/vite/package.json +1 -1
- package/build/templates/scaffold/docs/docusaurus/package.json +2 -2
- package/build/templates/scaffold/package/github-action/package.json +1 -1
- package/build/templates/scaffold/package/homebridge/package.json +1 -1
- package/build/templates/scaffold/package/pfsense/package.json +2 -2
- package/build/templates/scaffold/package/pfsense/port/Makefile.template +16 -1
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/FileLock.php +93 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/PackagePaths.php +40 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/UpdateManager.php +1667 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].inc +161 -13
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].xml +37 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/sbin/[__WORKSPACE_NAME__] +203 -8
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/share/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]/logo.svg +12 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/share/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]/release-signing.pub +9 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/www/[__WORKSPACE_NAME__]-about.php +437 -0
- package/build/templates/scaffold/package/pfsense/port/pkg-plist +6 -0
- package/build/templates/scaffold/package/pfsense/scripts/build-package.sh +61 -0
- package/build/templates/scaffold/package/pfsense/scripts/check-package.mjs +114 -1
- package/build/templates/scaffold/package/pfsense/scripts/regex.mjs +10 -0
- package/build/templates/scaffold/package/pfsense/scripts/stage-package.mjs +48 -2
- package/build/templates/scaffold/package/pfsense/tests/updates.php +695 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/drawable/ic_launcher_background.xml +1 -1
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/docker-image/common/Dockerfile +7 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/package.json +1 -1
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/index.test.d.ts +40 -2
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/landing-page.d.ts +23 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.test.ts +119 -4
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.ts +25 -3
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/landing-page.ts +278 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.test.ts +121 -6
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.ts +49 -12
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/package.json +3 -1
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/function/landing-page.ts +278 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.d.ts +17 -2
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.test.d.ts +40 -2
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/function/landing-page.d.ts +23 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/tsconfig.functions.json +3 -1
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/vercel.json +7 -1
- package/package.json +1 -1
- package/build/templates/scaffold/package/pfsense-root/.github/workflows/pfsense-[__WORKSPACE_NAME__].yml +0 -62
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# pfSense Conventions
|
|
2
|
+
|
|
3
|
+
Applies to pfSense package WebGUI pages (`/usr/local/www/*.php` and the package's `pkg_edit.php` XML). Build every page out of pfSense's own pieces, the way pfSense's own pages are built. When this file doesn't cover something, open the closest official page on a pfSense install (`/usr/local/www/`) and copy its markup. Don't invent a layout.
|
|
4
|
+
|
|
5
|
+
Reference pages used below, from pfSense CE 2.9.0:
|
|
6
|
+
- **Lists and edit pages:** `firewall_aliases.php`, `firewall_aliases_edit.php`, `services_unbound.php`, `services_unbound_host_edit.php`, `system_gateways.php`
|
|
7
|
+
- **Settings pages:** `services_unbound_advanced.php`, `system_advanced_admin.php`
|
|
8
|
+
- **Search and filter panels:** `pkg_mgr.php`, `status_logs_common.inc`, `diag_tables.php`
|
|
9
|
+
- **Status pages:** `status_services.php`, `status_dhcp_leases.php`
|
|
10
|
+
- **Framework:** `classes/Form.class.php`, `classes/Form/*.class.php`, `guiconfig.inc`, `head.inc`, `css/pfSense.css`, `js/pfSenseHelpers.js`
|
|
11
|
+
|
|
12
|
+
## Spacing Model
|
|
13
|
+
|
|
14
|
+
pfSense sets `.panel-body { padding: 0px; }` (`pfSense.css`), which cancels Bootstrap's 15px. Anything placed directly in `.panel` or `.panel-body` touches the panel edge. The padding comes from the elements pfSense puts inside, so `.panel-body` may only contain:
|
|
15
|
+
|
|
16
|
+
| Child of `.panel-body` | Padding comes from |
|
|
17
|
+
|--------------------------------------------------------------|------------------------------------------------------------------------|
|
|
18
|
+
| `.form-group` rows (from `Form_Section`, or the same markup) | `.form-group { padding: 7px 5px 5px 5px }` plus the `col-sm-*` gutters |
|
|
19
|
+
| `.table-responsive > table.table` (or `table.table`) | `.table > tbody > tr > td { padding: 6px 4px 6px 10px }` |
|
|
20
|
+
| an alert from `print_info_box()` | Bootstrap's `.alert { padding: 15px }` |
|
|
21
|
+
| `ul.list-group > li.list-group-item` | Bootstrap's `.list-group-item { padding: 10px 15px }` |
|
|
22
|
+
|
|
23
|
+
`.content { padding: 10px }` exists, but only dashboard widgets use it. Don't use it on pages.
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<!-- BAD: text and a button flush against the panel edge -->
|
|
27
|
+
<div class="panel-body">
|
|
28
|
+
<p>Search catalog names.</p>
|
|
29
|
+
<button class="btn btn-primary">Open Catalog</button>
|
|
30
|
+
</div>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```php
|
|
34
|
+
// GOOD: the same content as a Form API row, which renders a padded .form-group
|
|
35
|
+
$form = new Form(false);
|
|
36
|
+
$section = new Form_Section('Add from Catalog');
|
|
37
|
+
|
|
38
|
+
$button = new Form_Button('open_catalog', gettext('Open Catalog'), null, 'fa-solid fa-search');
|
|
39
|
+
$button->addClass('btn-primary btn-sm');
|
|
40
|
+
|
|
41
|
+
$section->addInput(new Form_StaticText('Catalog', $button))->setHelp('Search catalog names.');
|
|
42
|
+
$form->add($section);
|
|
43
|
+
|
|
44
|
+
print($form);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Prefer the Form API for anything inside a panel. A hand-written `.form-group` row is padded too, but its `.control-label` is only right-aligned inside a `.form-horizontal` ancestor, which the Form API adds. pfSense's own hand-written search panels (`pkg_mgr.php`, `diag_arp.php`) have no such ancestor, so their labels are left-aligned, unlike Form API rows.
|
|
48
|
+
|
|
49
|
+
Don't add `<style>` blocks or inline styles for spacing. pfSense uses inline styles only for `display: none` before JavaScript runs, cell wrapping or no-wrap, cursor hints and data-driven widths.
|
|
50
|
+
|
|
51
|
+
A package widget with no pfSense counterpart, such as a card grid, may ship its own stylesheet. It must:
|
|
52
|
+
- scope every rule to a package class
|
|
53
|
+
- sit inside a padded child from the table above, such as a `.form-group` row
|
|
54
|
+
- never restyle pfSense's own classes
|
|
55
|
+
|
|
56
|
+
## Page Skeleton
|
|
57
|
+
|
|
58
|
+
```php
|
|
59
|
+
$pgtitle = array(gettext('Services'), gettext('Example'), gettext('Lists'));
|
|
60
|
+
$pglinks = array('', '/example-lists.php', '@self');
|
|
61
|
+
$shortcut_section = 'example';
|
|
62
|
+
|
|
63
|
+
include('head.inc');
|
|
64
|
+
|
|
65
|
+
if ($input_errors) {
|
|
66
|
+
print_input_errors($input_errors);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if ($savemsg) {
|
|
70
|
+
print_info_box($savemsg, 'success');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
display_top_tabs($tab_array);
|
|
74
|
+
|
|
75
|
+
// Panels, forms, action buttons, help.
|
|
76
|
+
|
|
77
|
+
include('foot.inc');
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- **Breadcrumbs:** `$pgtitle` is the crumb trail. In `$pglinks`, `""` means no link and `"@self"` links to the current page. On edit pages, link the middle crumbs back to the list page.
|
|
81
|
+
- **Messages and tabs:** messages come before `display_top_tabs()`. The tab array holds `array(label, active, url)` entries.
|
|
82
|
+
- **Help link:** `head.inc` adds the `?` icon. Don't write one.
|
|
83
|
+
- **Scripts:** queue page JavaScript in `events.push(function () { … });`. `foot.inc` runs it after jQuery and the helpers load.
|
|
84
|
+
|
|
85
|
+
## Forms
|
|
86
|
+
|
|
87
|
+
Build every settings and edit form with the Form API. Don't hand-write form panels.
|
|
88
|
+
|
|
89
|
+
```php
|
|
90
|
+
$form = new Form(); // Adds the Save button (btn-primary, fa-save) below the last panel.
|
|
91
|
+
|
|
92
|
+
$section = new Form_Section('General Options');
|
|
93
|
+
|
|
94
|
+
$section->addInput(new Form_Checkbox(
|
|
95
|
+
'enable',
|
|
96
|
+
'Enable',
|
|
97
|
+
'Enable the service',
|
|
98
|
+
$pconfig['enable'],
|
|
99
|
+
));
|
|
100
|
+
|
|
101
|
+
$section->addInput(new Form_Input(
|
|
102
|
+
'port',
|
|
103
|
+
'Listen Port',
|
|
104
|
+
'number',
|
|
105
|
+
$pconfig['port'],
|
|
106
|
+
))->setHelp('The port used for answering queries.');
|
|
107
|
+
|
|
108
|
+
$form->add($section);
|
|
109
|
+
$form->addGlobal(new Form_Input('id', null, 'hidden', $id));
|
|
110
|
+
|
|
111
|
+
print($form);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Structure**
|
|
115
|
+
- Each `Form_Section` renders as `panel panel-default` with a `panel-heading` and `panel-body` full of `.form-group` rows.
|
|
116
|
+
- Labels are `col-sm-2 control-label`, and inputs share `col-sm-10`.
|
|
117
|
+
- `new Form(false)` has no Save button. Use it for search, filter and selector forms.
|
|
118
|
+
- Globals (hidden inputs and extra buttons) render below the last panel, outside it.
|
|
119
|
+
|
|
120
|
+
**Text and help**
|
|
121
|
+
- **Field help:** `->setHelp()` on the input, or on the `Form_Group` for help under the whole row.
|
|
122
|
+
- **A paragraph inside a section:** `new Form_StaticText('', '<span class="help-block">…</span>')`.
|
|
123
|
+
- **A read-only value in a settings section:** `Form_StaticText($title, $html)`. The `.col-sm-10` padding-top lines it up with the label.
|
|
124
|
+
|
|
125
|
+
**Fields**
|
|
126
|
+
- **Required fields:** start the title with `*`.
|
|
127
|
+
- **Several inputs on one row:** use a `Form_Group` with `->setWidth()` on each input. The column widths plus the label's 2 add up to 12.
|
|
128
|
+
- **Repeatable rows:** use a `Form_Group` with class `repeatable`, a `btn-warning` `fa-trash-can` Delete button per row, and a global `btn-success addbtn` `fa-plus` add button.
|
|
129
|
+
|
|
130
|
+
## Lists, Tables and Edit Pages
|
|
131
|
+
|
|
132
|
+
A list page shows a table panel, then the Add button. Add and the row's pencil open a separate `*_edit.php` page built with the Form API. Saving returns to the list.
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<div class="panel panel-default">
|
|
136
|
+
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Block Lists')?></h2></div>
|
|
137
|
+
<div class="panel-body">
|
|
138
|
+
<div class="table-responsive">
|
|
139
|
+
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
|
|
140
|
+
<thead>
|
|
141
|
+
<tr>
|
|
142
|
+
<th><?=gettext('Name')?></th>
|
|
143
|
+
<th data-sortable="false"><?=gettext('Actions')?></th>
|
|
144
|
+
</tr>
|
|
145
|
+
</thead>
|
|
146
|
+
<tbody>
|
|
147
|
+
<tr class="disabled"> <!-- Disabled items only. -->
|
|
148
|
+
<td><?=htmlspecialchars($name)?></td>
|
|
149
|
+
<td>
|
|
150
|
+
<a class="fa-solid fa-pencil" title="<?=gettext('Edit list')?>" href="example-lists_edit.php?id=<?=$id?>"></a>
|
|
151
|
+
<a class="fa-regular fa-square-check" title="<?=gettext('Enable list')?>" href="?act=toggle&id=<?=$id?>" usepost></a>
|
|
152
|
+
<a class="fa-solid fa-trash-can" title="<?=gettext('Delete list')?>" href="?act=del&id=<?=$id?>" usepost></a>
|
|
153
|
+
</td>
|
|
154
|
+
</tr>
|
|
155
|
+
</tbody>
|
|
156
|
+
</table>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<nav class="action-buttons">
|
|
162
|
+
<a href="example-lists_edit.php" role="button" class="btn btn-success btn-sm">
|
|
163
|
+
<i class="fa-solid fa-plus icon-embed-btn"></i>
|
|
164
|
+
<?=gettext('Add')?>
|
|
165
|
+
</a>
|
|
166
|
+
</nav>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Table markup**
|
|
170
|
+
- **Classes:** tables always carry `table table-striped table-hover table-condensed`.
|
|
171
|
+
- **Sorting:** add `sortable-theme-bootstrap` and `data-sortable` to sort, and give icon and Actions headers `data-sortable="false"`.
|
|
172
|
+
- **Double-click to edit:** `table-rowdblclickedit` clicks the row's first `.fa-pencil`, so only add it when every row has one.
|
|
173
|
+
- **Disabled items:** the row gets `<tr class="disabled">`.
|
|
174
|
+
|
|
175
|
+
**Row actions**
|
|
176
|
+
- **Markup:** row actions are bare icon anchors with a `title`. The title is the tooltip and the confirm text.
|
|
177
|
+
- **POST:** every state-changing link (delete, enable, disable) has `usepost`, which turns it into a POST with the CSRF token. Edit and copy links stay plain GETs.
|
|
178
|
+
- **Confirm:** `fa-trash-can` with `usepost` confirms by itself. Other actions that need a confirm add `do-confirm`, and actions with their own confirm add `no-confirm`.
|
|
179
|
+
- **Enable and disable icons:** a disabled item shows `fa-regular fa-square-check` (Enable), and an enabled item shows `fa-solid fa-ban` (Disable).
|
|
180
|
+
|
|
181
|
+
**Empty states and layout**
|
|
182
|
+
- **Empty state:** in a table, a `<tr><td colspan="N">No … are configured.</td></tr>` row. With no table, `print_info_box(gettext('No …'), 'warning', false)` in place of the panel, as `diag_tables.php` does. An info box inside a panel body keeps the alert's 20px bottom margin and leaves a blank strip under it. Never show an empty panel.
|
|
183
|
+
- **Action buttons:** they go in `<nav class="action-buttons">` right after the panel closes, never inside it.
|
|
184
|
+
- **Page-wide settings:** these live on the list page as a Form API section below the tables, with one Save.
|
|
185
|
+
|
|
186
|
+
## Buttons and Icons
|
|
187
|
+
|
|
188
|
+
`.icon-embed-btn` forces the icon to `color: white`. Only use it on a coloured button. On `btn-default` or a bare `.btn` the icon is invisible.
|
|
189
|
+
|
|
190
|
+
```html
|
|
191
|
+
<!-- BAD: white icon on a white button -->
|
|
192
|
+
<button class="btn btn-default"><i class="fa-solid fa-arrows-rotate icon-embed-btn"></i>Refresh</button>
|
|
193
|
+
|
|
194
|
+
<!-- GOOD -->
|
|
195
|
+
<button class="btn btn-info btn-sm"><i class="fa-solid fa-arrows-rotate icon-embed-btn"></i>Refresh</button>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Form_Button traps**
|
|
199
|
+
- `new Form_Button($name, $title, null, $icon)` adds no colour class, so always chain `->addClass('btn-…')`.
|
|
200
|
+
- Never pass both a link and an icon: the link form adds `btn-default`, so the icon is white on white.
|
|
201
|
+
- `btn-default` is only for buttons without an icon.
|
|
202
|
+
|
|
203
|
+
| Class | Use for |
|
|
204
|
+
|---------------|-------------------------------------------------------------|
|
|
205
|
+
| `btn-primary` | Save, Search, Import, Export |
|
|
206
|
+
| `btn-success` | Add, Install, Apply Changes, Apply Filter, Update |
|
|
207
|
+
| `btn-info` | Clear, Display Advanced, view switches, Refresh |
|
|
208
|
+
| `btn-warning` | Delete a repeatable row inside a form |
|
|
209
|
+
| `btn-danger` | Destructive actions on data, such as clearing a whole table |
|
|
210
|
+
|
|
211
|
+
| Purpose | FontAwesome 6 icon |
|
|
212
|
+
|-----------------------|--------------------------------|
|
|
213
|
+
| Add | `fa-solid fa-plus` |
|
|
214
|
+
| Edit | `fa-solid fa-pencil` |
|
|
215
|
+
| Delete | `fa-solid fa-trash-can` |
|
|
216
|
+
| Copy | `fa-regular fa-clone` |
|
|
217
|
+
| Save | `fa-solid fa-save` |
|
|
218
|
+
| Search | `fa-solid fa-search` |
|
|
219
|
+
| Clear | `fa-solid fa-undo` |
|
|
220
|
+
| Refresh or update | `fa-solid fa-arrows-rotate` |
|
|
221
|
+
| Filter | `fa-solid fa-filter` |
|
|
222
|
+
| Advanced | `fa-solid fa-cog` |
|
|
223
|
+
| Enable (row action) | `fa-regular fa-square-check` |
|
|
224
|
+
| Disable (row action) | `fa-solid fa-ban` |
|
|
225
|
+
| Locked or managed row | `fa-solid fa-lock text-danger` |
|
|
226
|
+
|
|
227
|
+
Use FontAwesome 6 names with a style prefix (`fa-solid`, `fa-regular`). Never use the bare `fa` class or FontAwesome 4 names.
|
|
228
|
+
|
|
229
|
+
## Search, Filters and Selectors
|
|
230
|
+
|
|
231
|
+
pfSense has no on/off switch widget and no page that combines a selector, a search box and a group filter. Build those from the patterns below.
|
|
232
|
+
|
|
233
|
+
**Server-side filter (preferred):** `new Form(false)` with a `Form_Section` and one `Form_Group('')`, from `status_logs_common.inc`. Each field's `setHelp()` is its label. Put the button inside a `Form_StaticText` so it sits on the same row.
|
|
234
|
+
|
|
235
|
+
```php
|
|
236
|
+
$form = new Form(false);
|
|
237
|
+
$section = new Form_Section('Search');
|
|
238
|
+
|
|
239
|
+
$group = new Form_Group('');
|
|
240
|
+
$group->add(new Form_Input('q', null, 'text', $query))->setWidth(6)->setHelp('Name or description');
|
|
241
|
+
|
|
242
|
+
$button = new Form_Button('search', gettext('Search'), null, 'fa-solid fa-search');
|
|
243
|
+
$button->addClass('btn-primary btn-sm');
|
|
244
|
+
|
|
245
|
+
$group->add(new Form_StaticText('', $button));
|
|
246
|
+
$section->add($group);
|
|
247
|
+
$form->add($section);
|
|
248
|
+
|
|
249
|
+
print($form);
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Selector that reloads the page:** `Form(false)` + a `Form_Section` + a `Form_Group` holding a `Form_Select` (from `diag_tables.php`). JavaScript submits on `change`, and an action button can share the group.
|
|
253
|
+
|
|
254
|
+
**Client-side search panel:** copy the `pkg_mgr.php` block exactly. It is a `.form-group` with a `col-sm-2` label, a `col-sm-5` input, a `col-sm-2` select, and a `col-sm-3` column holding Search (`btn-primary`, `fa-search`) and Clear (`btn-info`, `fa-undo`). Help goes in `col-sm-10 col-sm-offset-2`.
|
|
255
|
+
|
|
256
|
+
**On/off choices in a list:** use the row enable/disable icons, or `Form_Checkbox` fields in a form.
|
|
257
|
+
|
|
258
|
+
## Help Text
|
|
259
|
+
|
|
260
|
+
| Kind | Where |
|
|
261
|
+
|-----------------------------------|------------------------------------------------------------------------------------------------------------|
|
|
262
|
+
| Field help | `->setHelp()` under the field |
|
|
263
|
+
| A paragraph inside a form section | `Form_StaticText('', '<span class="help-block">…</span>')` |
|
|
264
|
+
| A short note under a table panel | `<span class="help-block">` between the panel and its `action-buttons`, outside both |
|
|
265
|
+
| Longer page help | `<div><div class="infoblock">` + `print_info_box($text, 'info', false)` + `</div></div>` below the content |
|
|
266
|
+
|
|
267
|
+
The `infoblock` stays hidden behind an (i) icon that `pfSenseHelpers.js` adds. Add `blockopen` to show it open. Info boxes used as help pass `false` as the third argument, so they have no close button.
|
|
268
|
+
|
|
269
|
+
## Dependent Fields
|
|
270
|
+
|
|
271
|
+
Hide the rows that don't apply instead of showing every field. Run the check once on load and again on every change.
|
|
272
|
+
|
|
273
|
+
```js
|
|
274
|
+
events.push(function () {
|
|
275
|
+
function updateScope() {
|
|
276
|
+
var everyone = $('#everyone').prop('checked');
|
|
277
|
+
|
|
278
|
+
hideInput('networks', everyone);
|
|
279
|
+
hideInput('devices', everyone);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
updateScope();
|
|
283
|
+
$('#everyone').click(updateScope);
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
A multi-select `Form_Select` (`$allowMultiple = true`) appends `[]` to both its name and its id, so `hideInput('lists', …)` finds nothing. Escape the brackets:
|
|
288
|
+
|
|
289
|
+
```js
|
|
290
|
+
hideInput('lists\\[\\]', anyList); // BAD without the escapes: hideInput('lists', anyList) hides nothing.
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Helpers from `pfSenseHelpers.js`:
|
|
294
|
+
- `hideInput`, `hideCheckbox` and `hideSelect` hide one field's whole row.
|
|
295
|
+
- `hideGroupInput` hides one input inside a multi-input row.
|
|
296
|
+
- `hideClass` hides everything with a class set in PHP through `->addClass()`.
|
|
297
|
+
- `disableInput` disables a field without hiding it.
|
|
298
|
+
|
|
299
|
+
## Checklist
|
|
300
|
+
|
|
301
|
+
- Nothing sits directly in `.panel` or `.panel-body`. Every child is a `.form-group` row, a table, an info box or a list group.
|
|
302
|
+
- Every settings and edit form is built with the Form API. No form panels are written by hand.
|
|
303
|
+
- Page order: `$pgtitle`/`$pglinks`, then `head.inc`, messages, `display_top_tabs()`, content, then `foot.inc`.
|
|
304
|
+
- List pages: a table panel, then `<nav class="action-buttons">` Add, with Add and Edit opening a `*_edit.php` page.
|
|
305
|
+
- Tables use the standard classes. Disabled rows use `tr.disabled`. Empty tables show a `colspan` row.
|
|
306
|
+
- Row actions are titled icon anchors, with `usepost` on every state change.
|
|
307
|
+
- `icon-embed-btn` only appears on coloured buttons, and every icon `Form_Button` gets a colour class.
|
|
308
|
+
- Icons use FontAwesome 6 names with a style prefix.
|
|
309
|
+
- Help goes in `setHelp()`, a `help-block` or an `infoblock`, never as bare text in a panel.
|
|
310
|
+
- Dependent fields hide with `pfSenseHelpers.js` inside `events.push`.
|
|
311
|
+
- No `<style>` blocks or inline styles for spacing.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"node": "[__SCAFFOLD_VERSION_NODE_ENGINE__]"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@cbnventures/nova": "0.
|
|
27
|
+
"@cbnventures/nova": "0.40.0",
|
|
28
28
|
"next": "[__SCAFFOLD_VERSION_NEXT__]",
|
|
29
29
|
"react": "[__SCAFFOLD_VERSION_REACT__]",
|
|
30
30
|
"react-dom": "[__SCAFFOLD_VERSION_REACT_DOM__]"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"node": "[__SCAFFOLD_VERSION_NODE_ENGINE__]"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@cbnventures/docusaurus-preset-nova": "0.
|
|
31
|
-
"@cbnventures/nova": "0.
|
|
30
|
+
"@cbnventures/docusaurus-preset-nova": "0.40.0",
|
|
31
|
+
"@cbnventures/nova": "0.40.0",
|
|
32
32
|
"@docusaurus/core": "[__SCAFFOLD_VERSION_DOCUSAURUS__]",
|
|
33
33
|
"react": "[__SCAFFOLD_VERSION_REACT__]",
|
|
34
34
|
"react-dom": "[__SCAFFOLD_VERSION_REACT_DOM__]"
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"clean:build": "shx rm -rf ./build"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": "[
|
|
29
|
+
"node": "[__SCAFFOLD_VERSION_NODE_ENGINE__]"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cbnventures/nova": "0.
|
|
32
|
+
"@cbnventures/nova": "0.40.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "[__SCAFFOLD_VERSION_TYPES_NODE_24__]",
|
|
@@ -5,8 +5,9 @@ MASTER_SITES= # empty
|
|
|
5
5
|
DISTFILES= # empty
|
|
6
6
|
EXTRACT_ONLY= # empty
|
|
7
7
|
|
|
8
|
-
MAINTAINER?=
|
|
8
|
+
MAINTAINER?= [__PROJECT_AUTHOR_EMAIL__]
|
|
9
9
|
COMMENT= [__WORKSPACE_TITLE__] package for pfSense
|
|
10
|
+
WWW= [__PROJECT_HOMEPAGE__]
|
|
10
11
|
|
|
11
12
|
LICENSE= MIT
|
|
12
13
|
|
|
@@ -22,16 +23,30 @@ do-extract:
|
|
|
22
23
|
|
|
23
24
|
do-install:
|
|
24
25
|
${MKDIR} ${STAGEDIR}${PREFIX}/pkg
|
|
26
|
+
${MKDIR} ${STAGEDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__]
|
|
25
27
|
${MKDIR} ${STAGEDIR}${PREFIX}/sbin
|
|
28
|
+
${MKDIR} ${STAGEDIR}${PREFIX}/www
|
|
26
29
|
${MKDIR} ${STAGEDIR}${DATADIR}
|
|
27
30
|
${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__].inc \
|
|
28
31
|
${STAGEDIR}${PREFIX}/pkg
|
|
29
32
|
${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__].xml \
|
|
30
33
|
${STAGEDIR}${PREFIX}/pkg
|
|
34
|
+
${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__]/FileLock.php \
|
|
35
|
+
${STAGEDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__]
|
|
36
|
+
${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__]/PackagePaths.php \
|
|
37
|
+
${STAGEDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__]
|
|
38
|
+
${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__]/UpdateManager.php \
|
|
39
|
+
${STAGEDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__]
|
|
31
40
|
${INSTALL_SCRIPT} ${FILESDIR}${PREFIX}/sbin/[__WORKSPACE_NAME__] \
|
|
32
41
|
${STAGEDIR}${PREFIX}/sbin
|
|
42
|
+
${INSTALL_DATA} ${FILESDIR}${PREFIX}/www/[__WORKSPACE_NAME__]-about.php \
|
|
43
|
+
${STAGEDIR}${PREFIX}/www
|
|
33
44
|
${INSTALL_DATA} ${FILESDIR}${DATADIR}/info.xml \
|
|
34
45
|
${STAGEDIR}${DATADIR}
|
|
46
|
+
${INSTALL_DATA} ${FILESDIR}${DATADIR}/logo.svg \
|
|
47
|
+
${STAGEDIR}${DATADIR}
|
|
48
|
+
${INSTALL_DATA} ${FILESDIR}${DATADIR}/release-signing.pub \
|
|
49
|
+
${STAGEDIR}${DATADIR}
|
|
35
50
|
@${REINPLACE_CMD} -i '' -e "s|%%PKGVERSION%%|${PKGVERSION}|" \
|
|
36
51
|
${STAGEDIR}${PREFIX}/pkg/[__WORKSPACE_NAME__].xml \
|
|
37
52
|
${STAGEDIR}${DATADIR}/info.xml
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace PfSense\[__WORKSPACE_IDENTIFIER__]\Runtime;
|
|
6
|
+
|
|
7
|
+
use RuntimeException;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Coordinates package runs with a non-blocking filesystem lock.
|
|
11
|
+
*
|
|
12
|
+
* The open descriptor owns the lock for the process lifetime. A second scheduled
|
|
13
|
+
* or manual run exits without reading state or starting an update.
|
|
14
|
+
*
|
|
15
|
+
* @since UNRELEASED
|
|
16
|
+
*/
|
|
17
|
+
final class FileLock
|
|
18
|
+
{
|
|
19
|
+
/** @var mixed Open lock-file handle while this instance owns the lock. @since UNRELEASED */
|
|
20
|
+
private mixed $handle = null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates a lock coordinator for one package-owned path.
|
|
24
|
+
*
|
|
25
|
+
* @param string $path - Lock file path.
|
|
26
|
+
*
|
|
27
|
+
* @since UNRELEASED
|
|
28
|
+
*/
|
|
29
|
+
public function __construct(private readonly string $path)
|
|
30
|
+
{
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Releases an owned lock when the instance leaves scope. @since UNRELEASED */
|
|
34
|
+
public function __destruct()
|
|
35
|
+
{
|
|
36
|
+
$this->release();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Attempts to acquire the package lock without waiting.
|
|
41
|
+
*
|
|
42
|
+
* @return bool
|
|
43
|
+
*
|
|
44
|
+
* @throws RuntimeException When the lock file cannot be opened or protected.
|
|
45
|
+
*
|
|
46
|
+
* @since UNRELEASED
|
|
47
|
+
*/
|
|
48
|
+
public function acquire(): bool
|
|
49
|
+
{
|
|
50
|
+
if (is_resource($this->handle)) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
$handle = fopen($this->path, 'c');
|
|
55
|
+
|
|
56
|
+
if ($handle === false) {
|
|
57
|
+
throw new RuntimeException(gettext('The package lock is unavailable.'));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (chmod($this->path, 0600) === false) {
|
|
61
|
+
fclose($handle);
|
|
62
|
+
|
|
63
|
+
throw new RuntimeException(gettext('The package lock is unavailable.'));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (flock($handle, LOCK_EX | LOCK_NB) === false) {
|
|
67
|
+
fclose($handle);
|
|
68
|
+
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ftruncate($handle, 0);
|
|
73
|
+
fwrite($handle, (string) getmypid() . PHP_EOL);
|
|
74
|
+
fflush($handle);
|
|
75
|
+
|
|
76
|
+
$this->handle = $handle;
|
|
77
|
+
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Releases the current lock and closes its descriptor. @since UNRELEASED */
|
|
82
|
+
public function release(): void
|
|
83
|
+
{
|
|
84
|
+
if (!is_resource($this->handle)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
flock($this->handle, LOCK_UN);
|
|
89
|
+
fclose($this->handle);
|
|
90
|
+
|
|
91
|
+
$this->handle = null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace PfSense\[__WORKSPACE_IDENTIFIER__]\Runtime;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Package-owned filesystem and configuration locations.
|
|
9
|
+
*
|
|
10
|
+
* Persistent update state lives beside the pfSense configuration in "/cf/conf"
|
|
11
|
+
* so it survives reboots when "/var" is a RAM disk. Only the lock is transient.
|
|
12
|
+
*
|
|
13
|
+
* @since UNRELEASED
|
|
14
|
+
*/
|
|
15
|
+
final class PackagePaths
|
|
16
|
+
{
|
|
17
|
+
/** Persistent package data directory. @since UNRELEASED */
|
|
18
|
+
public const DATA_DIRECTORY = '/cf/conf/[__WORKSPACE_NAME__]';
|
|
19
|
+
|
|
20
|
+
/** Latest-release metadata from GitHub. @since UNRELEASED */
|
|
21
|
+
public const UPDATES_FILE = self::DATA_DIRECTORY . '/updates.json';
|
|
22
|
+
|
|
23
|
+
/** Background self-update progress shown on the About tab. @since UNRELEASED */
|
|
24
|
+
public const UPDATE_STATUS_FILE = self::DATA_DIRECTORY . '/update-status.json';
|
|
25
|
+
|
|
26
|
+
/** Single-run lock shared by scheduled, update, and WebGUI runs. @since UNRELEASED */
|
|
27
|
+
public const LOCK_FILE = '/var/run/[__WORKSPACE_NAME__].lock';
|
|
28
|
+
|
|
29
|
+
/** Package command run by cron and the WebGUI. @since UNRELEASED */
|
|
30
|
+
public const COMMAND = '/usr/local/sbin/[__WORKSPACE_NAME__]';
|
|
31
|
+
|
|
32
|
+
/** Package command used by the independent update-check cron entry. @since UNRELEASED */
|
|
33
|
+
public const UPDATE_CHECK_COMMAND = self::COMMAND . ' --check-updates';
|
|
34
|
+
|
|
35
|
+
/** Package command launched in the background by the About tab. @since UNRELEASED */
|
|
36
|
+
public const SELF_UPDATE_COMMAND = self::COMMAND . ' --self-update';
|
|
37
|
+
|
|
38
|
+
/** Stable randomized update-check schedule in the pfSense configuration. @since UNRELEASED */
|
|
39
|
+
public const UPDATE_SCHEDULE_PATH = 'installedpackages/[__PFSENSE_CONFIG_NAME__]/update_schedule';
|
|
40
|
+
}
|