@gtkx/cli 1.6.0 → 2.0.0-beta.10
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/README.md +47 -44
- package/bin/gtkx-dev-runner.js +5 -1
- package/bin/gtkx.js +5 -1
- package/dist/builder.d.ts +1 -0
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +44 -12
- package/dist/builder.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -2
- package/dist/cli.js.map +1 -1
- package/dist/codegen/config-dependencies.d.ts +3 -0
- package/dist/codegen/config-dependencies.d.ts.map +1 -0
- package/dist/codegen/config-dependencies.js +355 -0
- package/dist/codegen/config-dependencies.js.map +1 -0
- package/dist/codegen/freshness.d.ts.map +1 -1
- package/dist/codegen/freshness.js +49 -16
- package/dist/codegen/freshness.js.map +1 -1
- package/dist/codegen/reference.d.ts.map +1 -1
- package/dist/codegen/reference.js +2 -7
- package/dist/codegen/reference.js.map +1 -1
- package/dist/codegen/report.d.ts.map +1 -1
- package/dist/codegen/report.js +5 -16
- package/dist/codegen/report.js.map +1 -1
- package/dist/codegen/run-codegen.d.ts +9 -8
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +60 -113
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/codegen/store-resolver.d.ts +3 -2
- package/dist/codegen/store-resolver.d.ts.map +1 -1
- package/dist/codegen/store-resolver.js +14 -20
- package/dist/codegen/store-resolver.js.map +1 -1
- package/dist/commands/build.d.ts +5 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +83 -10
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/cleanup.d.ts +9 -0
- package/dist/commands/cleanup.d.ts.map +1 -0
- package/dist/commands/cleanup.js +42 -0
- package/dist/commands/cleanup.js.map +1 -0
- package/dist/commands/codegen.d.ts +1 -0
- package/dist/commands/codegen.d.ts.map +1 -1
- package/dist/commands/codegen.js +6 -5
- package/dist/commands/codegen.js.map +1 -1
- package/dist/commands/deploy.d.ts +5 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +10 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +9 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +31 -4
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +6 -15
- package/dist/commands/docs.js.map +1 -1
- package/dist/deploy/depends.d.ts.map +1 -1
- package/dist/deploy/depends.js +24 -2
- package/dist/deploy/depends.js.map +1 -1
- package/dist/deploy/download.d.ts +7 -3
- package/dist/deploy/download.d.ts.map +1 -1
- package/dist/deploy/download.js +19 -20
- package/dist/deploy/download.js.map +1 -1
- package/dist/deploy/freedesktop/copyright.d.ts.map +1 -1
- package/dist/deploy/freedesktop/copyright.js +2 -13
- package/dist/deploy/freedesktop/copyright.js.map +1 -1
- package/dist/deploy/freedesktop/metainfo.d.ts.map +1 -1
- package/dist/deploy/freedesktop/metainfo.js +41 -2
- package/dist/deploy/freedesktop/metainfo.js.map +1 -1
- package/dist/deploy/freedesktop/validate.d.ts.map +1 -1
- package/dist/deploy/freedesktop/validate.js +58 -14
- package/dist/deploy/freedesktop/validate.js.map +1 -1
- package/dist/deploy/freedesktop/xml.d.ts.map +1 -1
- package/dist/deploy/freedesktop/xml.js +21 -25
- package/dist/deploy/freedesktop/xml.js.map +1 -1
- package/dist/deploy/native-addon.d.ts +5 -0
- package/dist/deploy/native-addon.d.ts.map +1 -0
- package/dist/deploy/native-addon.js +134 -0
- package/dist/deploy/native-addon.js.map +1 -0
- package/dist/deploy/nfpm/config.d.ts +3 -2
- package/dist/deploy/nfpm/config.d.ts.map +1 -1
- package/dist/deploy/nfpm/config.js +7 -4
- package/dist/deploy/nfpm/config.js.map +1 -1
- package/dist/deploy/nfpm/contents.d.ts.map +1 -1
- package/dist/deploy/nfpm/contents.js +8 -0
- package/dist/deploy/nfpm/contents.js.map +1 -1
- package/dist/deploy/node-runtime/download.js +2 -2
- package/dist/deploy/node-runtime/download.js.map +1 -1
- package/dist/deploy/node-runtime/elf.d.ts +4 -1
- package/dist/deploy/node-runtime/elf.d.ts.map +1 -1
- package/dist/deploy/node-runtime/elf.js +34 -5
- package/dist/deploy/node-runtime/elf.js.map +1 -1
- package/dist/deploy/node-runtime/guard.d.ts.map +1 -1
- package/dist/deploy/node-runtime/guard.js +7 -14
- package/dist/deploy/node-runtime/guard.js.map +1 -1
- package/dist/deploy/node-runtime/index.d.ts +3 -1
- package/dist/deploy/node-runtime/index.d.ts.map +1 -1
- package/dist/deploy/node-runtime/index.js +103 -10
- package/dist/deploy/node-runtime/index.js.map +1 -1
- package/dist/deploy/node-runtime/license.d.ts.map +1 -1
- package/dist/deploy/node-runtime/license.js +2 -9
- package/dist/deploy/node-runtime/license.js.map +1 -1
- package/dist/deploy/node-runtime/sonames.d.ts +5 -0
- package/dist/deploy/node-runtime/sonames.d.ts.map +1 -0
- package/dist/deploy/node-runtime/sonames.js +13 -0
- package/dist/deploy/node-runtime/sonames.js.map +1 -0
- package/dist/deploy/notices/node-runtime.js +2 -2
- package/dist/deploy/notices/node-runtime.js.map +1 -1
- package/dist/deploy/notices/packages.d.ts.map +1 -1
- package/dist/deploy/notices/packages.js +3 -10
- package/dist/deploy/notices/packages.js.map +1 -1
- package/dist/deploy/payload/copy-tree.d.ts.map +1 -1
- package/dist/deploy/payload/copy-tree.js +3 -3
- package/dist/deploy/payload/copy-tree.js.map +1 -1
- package/dist/deploy/payload/launcher.d.ts.map +1 -1
- package/dist/deploy/payload/launcher.js +14 -1
- package/dist/deploy/payload/launcher.js.map +1 -1
- package/dist/deploy/payload/stage.d.ts +2 -1
- package/dist/deploy/payload/stage.d.ts.map +1 -1
- package/dist/deploy/payload/stage.js +47 -8
- package/dist/deploy/payload/stage.js.map +1 -1
- package/dist/deploy/run-deploy.d.ts +2 -0
- package/dist/deploy/run-deploy.d.ts.map +1 -1
- package/dist/deploy/run-deploy.js +197 -52
- package/dist/deploy/run-deploy.js.map +1 -1
- package/dist/deploy/settings/arch.d.ts +9 -3
- package/dist/deploy/settings/arch.d.ts.map +1 -1
- package/dist/deploy/settings/arch.js +27 -6
- package/dist/deploy/settings/arch.js.map +1 -1
- package/dist/deploy/settings/build-manifest.d.ts +6 -1
- package/dist/deploy/settings/build-manifest.d.ts.map +1 -1
- package/dist/deploy/settings/build-manifest.js +17 -17
- package/dist/deploy/settings/build-manifest.js.map +1 -1
- package/dist/deploy/settings/extra-files.d.ts +1 -1
- package/dist/deploy/settings/extra-files.d.ts.map +1 -1
- package/dist/deploy/settings/extra-files.js +25 -3
- package/dist/deploy/settings/extra-files.js.map +1 -1
- package/dist/deploy/settings/index.d.ts +3 -1
- package/dist/deploy/settings/index.d.ts.map +1 -1
- package/dist/deploy/settings/index.js +4 -2
- package/dist/deploy/settings/index.js.map +1 -1
- package/dist/deploy/settings/libraries.d.ts.map +1 -1
- package/dist/deploy/settings/libraries.js +3 -19
- package/dist/deploy/settings/libraries.js.map +1 -1
- package/dist/deploy/settings/paths.d.ts +4 -3
- package/dist/deploy/settings/paths.d.ts.map +1 -1
- package/dist/deploy/settings/paths.js +118 -19
- package/dist/deploy/settings/paths.js.map +1 -1
- package/dist/deploy/settings/screenshots.d.ts.map +1 -1
- package/dist/deploy/settings/screenshots.js +6 -31
- package/dist/deploy/settings/screenshots.js.map +1 -1
- package/dist/deploy/targets/appimage.d.ts.map +1 -1
- package/dist/deploy/targets/appimage.js +1 -0
- package/dist/deploy/targets/appimage.js.map +1 -1
- package/dist/deploy/targets/flatpak-pnpm.js +4 -4
- package/dist/deploy/targets/flatpak-pnpm.js.map +1 -1
- package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak-source.js +17 -6
- package/dist/deploy/targets/flatpak-source.js.map +1 -1
- package/dist/deploy/targets/flatpak-sources.js +1 -1
- package/dist/deploy/targets/flatpak-sources.js.map +1 -1
- package/dist/deploy/targets/flatpak.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak.js +1 -0
- package/dist/deploy/targets/flatpak.js.map +1 -1
- package/dist/deploy/targets/nfpm-target.d.ts.map +1 -1
- package/dist/deploy/targets/nfpm-target.js +13 -7
- package/dist/deploy/targets/nfpm-target.js.map +1 -1
- package/dist/deploy/types.d.ts +5 -2
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/deploy/types.js.map +1 -1
- package/dist/deploy/vendored/appimagetool.js +2 -2
- package/dist/deploy/vendored/appimagetool.js.map +1 -1
- package/dist/deploy/vendored/nfpm.js +1 -1
- package/dist/deploy/vendored/nfpm.js.map +1 -1
- package/dist/dev/catalog-writes.d.ts +8 -0
- package/dist/dev/catalog-writes.d.ts.map +1 -0
- package/dist/dev/catalog-writes.js +26 -0
- package/dist/dev/catalog-writes.js.map +1 -0
- package/dist/dev/entry-env.d.ts +2 -1
- package/dist/dev/entry-env.d.ts.map +1 -1
- package/dist/dev/entry-env.js +2 -1
- package/dist/dev/entry-env.js.map +1 -1
- package/dist/dev/font-dir.d.ts +3 -0
- package/dist/dev/font-dir.d.ts.map +1 -0
- package/dist/dev/font-dir.js +9 -0
- package/dist/dev/font-dir.js.map +1 -0
- package/dist/dev/headless.d.ts +3 -0
- package/dist/dev/headless.d.ts.map +1 -0
- package/dist/dev/headless.js +35 -0
- package/dist/dev/headless.js.map +1 -0
- package/dist/dev/runner-deps.d.ts +1 -1
- package/dist/dev/runner-deps.d.ts.map +1 -1
- package/dist/dev/runner-deps.js +12 -7
- package/dist/dev/runner-deps.js.map +1 -1
- package/dist/dev/runner-main.d.ts.map +1 -1
- package/dist/dev/runner-main.js +11 -5
- package/dist/dev/runner-main.js.map +1 -1
- package/dist/dev/runner.d.ts +2 -0
- package/dist/dev/runner.d.ts.map +1 -1
- package/dist/dev/runner.js +26 -7
- package/dist/dev/runner.js.map +1 -1
- package/dist/dev/schema-dir.d.ts +1 -1
- package/dist/dev/schema-dir.d.ts.map +1 -1
- package/dist/dev/schema-dir.js +2 -4
- package/dist/dev/schema-dir.js.map +1 -1
- package/dist/dev/supervisor.d.ts +3 -1
- package/dist/dev/supervisor.d.ts.map +1 -1
- package/dist/dev/supervisor.js +132 -29
- package/dist/dev/supervisor.js.map +1 -1
- package/dist/dev/vite-dev-server.d.ts +1 -1
- package/dist/dev/vite-dev-server.d.ts.map +1 -1
- package/dist/dev/vite-dev-server.js +14 -2
- package/dist/dev/vite-dev-server.js.map +1 -1
- package/dist/dev/watch-ignore.d.ts +3 -0
- package/dist/dev/watch-ignore.d.ts.map +1 -0
- package/dist/dev/watch-ignore.js +11 -0
- package/dist/dev/watch-ignore.js.map +1 -0
- package/dist/i18n/catalogs.d.ts +6 -2
- package/dist/i18n/catalogs.d.ts.map +1 -1
- package/dist/i18n/catalogs.js +12 -8
- package/dist/i18n/catalogs.js.map +1 -1
- package/dist/i18n/metadata-templates.d.ts.map +1 -1
- package/dist/i18n/metadata-templates.js +2 -1
- package/dist/i18n/metadata-templates.js.map +1 -1
- package/dist/i18n/source-messages.d.ts +5 -21
- package/dist/i18n/source-messages.d.ts.map +1 -1
- package/dist/i18n/source-messages.js +1037 -92
- package/dist/i18n/source-messages.js.map +1 -1
- package/dist/i18n/types.d.ts +6 -7
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/i18n/types.js +83 -96
- package/dist/i18n/types.js.map +1 -1
- package/dist/internal/agent-rules.d.ts.map +1 -1
- package/dist/internal/agent-rules.js +7 -2
- package/dist/internal/agent-rules.js.map +1 -1
- package/dist/internal/banner.d.ts +4 -2
- package/dist/internal/banner.d.ts.map +1 -1
- package/dist/internal/banner.js +19 -5
- package/dist/internal/banner.js.map +1 -1
- package/dist/internal/build-manifest.d.ts +5 -2
- package/dist/internal/build-manifest.d.ts.map +1 -1
- package/dist/internal/build-manifest.js +15 -2
- package/dist/internal/build-manifest.js.map +1 -1
- package/dist/internal/build-output.d.ts +8 -0
- package/dist/internal/build-output.d.ts.map +1 -0
- package/dist/internal/build-output.js +116 -0
- package/dist/internal/build-output.js.map +1 -0
- package/dist/internal/cache-root.d.ts +3 -0
- package/dist/internal/cache-root.d.ts.map +1 -0
- package/dist/internal/cache-root.js +9 -0
- package/dist/internal/cache-root.js.map +1 -0
- package/dist/internal/compile-cache-store.d.ts +4 -0
- package/dist/internal/compile-cache-store.d.ts.map +1 -0
- package/dist/internal/compile-cache-store.js +41 -0
- package/dist/internal/compile-cache-store.js.map +1 -0
- package/dist/internal/compile-cache.d.ts +4 -0
- package/dist/internal/compile-cache.d.ts.map +1 -0
- package/dist/internal/compile-cache.js +16 -0
- package/dist/internal/compile-cache.js.map +1 -0
- package/dist/internal/deploy-out-dir.d.ts +4 -0
- package/dist/internal/deploy-out-dir.d.ts.map +1 -0
- package/dist/internal/deploy-out-dir.js +5 -0
- package/dist/internal/deploy-out-dir.js.map +1 -0
- package/dist/internal/docs-elements.d.ts +1 -0
- package/dist/internal/docs-elements.d.ts.map +1 -1
- package/dist/internal/docs-elements.js +6 -5
- package/dist/internal/docs-elements.js.map +1 -1
- package/dist/internal/entry-arg.d.ts +4 -1
- package/dist/internal/entry-arg.d.ts.map +1 -1
- package/dist/internal/entry-arg.js +7 -1
- package/dist/internal/entry-arg.js.map +1 -1
- package/dist/internal/errors.d.ts +2 -1
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +1 -1
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/font-path.d.ts +4 -0
- package/dist/internal/font-path.d.ts.map +1 -0
- package/dist/internal/font-path.js +12 -0
- package/dist/internal/font-path.js.map +1 -0
- package/dist/internal/font-staging.d.ts +6 -0
- package/dist/internal/font-staging.d.ts.map +1 -0
- package/dist/internal/font-staging.js +94 -0
- package/dist/internal/font-staging.js.map +1 -0
- package/dist/internal/icon-path.d.ts.map +1 -1
- package/dist/internal/icon-path.js +5 -16
- package/dist/internal/icon-path.js.map +1 -1
- package/dist/internal/icon-staging.d.ts +3 -0
- package/dist/internal/icon-staging.d.ts.map +1 -0
- package/dist/internal/icon-staging.js +40 -0
- package/dist/internal/icon-staging.js.map +1 -0
- package/dist/internal/import-scan.d.ts +4 -0
- package/dist/internal/import-scan.d.ts.map +1 -0
- package/dist/internal/import-scan.js +138 -0
- package/dist/internal/import-scan.js.map +1 -0
- package/dist/internal/module-hash.d.ts +3 -0
- package/dist/internal/module-hash.d.ts.map +1 -0
- package/dist/internal/module-hash.js +19 -0
- package/dist/internal/module-hash.js.map +1 -0
- package/dist/internal/output-directory.d.ts +15 -0
- package/dist/internal/output-directory.d.ts.map +1 -0
- package/dist/internal/output-directory.js +490 -0
- package/dist/internal/output-directory.js.map +1 -0
- package/dist/internal/parent-process.d.ts +12 -0
- package/dist/internal/parent-process.d.ts.map +1 -0
- package/dist/internal/parent-process.js +74 -0
- package/dist/internal/parent-process.js.map +1 -0
- package/dist/internal/prepare-project.d.ts +3 -0
- package/dist/internal/prepare-project.d.ts.map +1 -1
- package/dist/internal/prepare-project.js +9 -3
- package/dist/internal/prepare-project.js.map +1 -1
- package/dist/internal/react-compiler-cache.d.ts +13 -0
- package/dist/internal/react-compiler-cache.d.ts.map +1 -0
- package/dist/internal/react-compiler-cache.js +182 -0
- package/dist/internal/react-compiler-cache.js.map +1 -0
- package/dist/internal/source-imports.d.ts +7 -2
- package/dist/internal/source-imports.d.ts.map +1 -1
- package/dist/internal/source-imports.js +38 -49
- package/dist/internal/source-imports.js.map +1 -1
- package/dist/internal/staging-file.d.ts +5 -0
- package/dist/internal/staging-file.d.ts.map +1 -0
- package/dist/internal/staging-file.js +35 -0
- package/dist/internal/staging-file.js.map +1 -0
- package/dist/internal/xdg-banner.d.ts +4 -0
- package/dist/internal/xdg-banner.d.ts.map +1 -0
- package/dist/internal/xdg-banner.js +11 -0
- package/dist/internal/xdg-banner.js.map +1 -0
- package/dist/internal/xdg-data-dirs.d.ts +2 -1
- package/dist/internal/xdg-data-dirs.d.ts.map +1 -1
- package/dist/internal/xdg-data-dirs.js +1 -1
- package/dist/internal/xdg-data-dirs.js.map +1 -1
- package/dist/mcp/client.js +2 -2
- package/dist/mcp/client.js.map +1 -1
- package/dist/settings/render.d.ts +0 -1
- package/dist/settings/render.d.ts.map +1 -1
- package/dist/settings/render.js +1 -11
- package/dist/settings/render.js.map +1 -1
- package/dist/settings/schema.d.ts +2 -2
- package/dist/settings/schema.d.ts.map +1 -1
- package/dist/settings/schema.js +24 -70
- package/dist/settings/schema.js.map +1 -1
- package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
- package/dist/vite-plugins/asset-extensions.js +2 -0
- package/dist/vite-plugins/asset-extensions.js.map +1 -1
- package/dist/vite-plugins/asset-imports.d.ts +1 -2
- package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
- package/dist/vite-plugins/asset-imports.js +36 -35
- package/dist/vite-plugins/asset-imports.js.map +1 -1
- package/dist/vite-plugins/asset-specifier.d.ts +5 -3
- package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
- package/dist/vite-plugins/asset-specifier.js +10 -4
- package/dist/vite-plugins/asset-specifier.js.map +1 -1
- package/dist/vite-plugins/build-manifest.d.ts +5 -1
- package/dist/vite-plugins/build-manifest.d.ts.map +1 -1
- package/dist/vite-plugins/build-manifest.js +2 -1
- package/dist/vite-plugins/build-manifest.js.map +1 -1
- package/dist/vite-plugins/built-url.d.ts.map +1 -1
- package/dist/vite-plugins/built-url.js +5 -2
- package/dist/vite-plugins/built-url.js.map +1 -1
- package/dist/vite-plugins/css.d.ts.map +1 -1
- package/dist/vite-plugins/css.js +13 -5
- package/dist/vite-plugins/css.js.map +1 -1
- package/dist/vite-plugins/ensure-store.d.ts +1 -1
- package/dist/vite-plugins/ensure-store.d.ts.map +1 -1
- package/dist/vite-plugins/ensure-store.js +2 -2
- package/dist/vite-plugins/ensure-store.js.map +1 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts +6 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts.map +1 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.js +3 -1
- package/dist/vite-plugins/fast-refresh/refresh-filter.js.map +1 -1
- package/dist/vite-plugins/fast-refresh/swc-refresh.d.ts.map +1 -1
- package/dist/vite-plugins/fast-refresh/swc-refresh.js +23 -14
- package/dist/vite-plugins/fast-refresh/swc-refresh.js.map +1 -1
- package/dist/vite-plugins/font-name.d.ts +3 -0
- package/dist/vite-plugins/font-name.d.ts.map +1 -0
- package/dist/vite-plugins/font-name.js +406 -0
- package/dist/vite-plugins/font-name.js.map +1 -0
- package/dist/vite-plugins/font-worker-env.d.ts +4 -0
- package/dist/vite-plugins/font-worker-env.d.ts.map +1 -0
- package/dist/vite-plugins/font-worker-env.js +19 -0
- package/dist/vite-plugins/font-worker-env.js.map +1 -0
- package/dist/vite-plugins/font.d.ts +4 -0
- package/dist/vite-plugins/font.d.ts.map +1 -0
- package/dist/vite-plugins/font.js +111 -0
- package/dist/vite-plugins/font.js.map +1 -0
- package/dist/vite-plugins/i18n.d.ts +11 -2
- package/dist/vite-plugins/i18n.d.ts.map +1 -1
- package/dist/vite-plugins/i18n.js +75 -8
- package/dist/vite-plugins/i18n.js.map +1 -1
- package/dist/vite-plugins/icon-worker-env.d.ts +4 -0
- package/dist/vite-plugins/icon-worker-env.d.ts.map +1 -0
- package/dist/vite-plugins/icon-worker-env.js +23 -0
- package/dist/vite-plugins/icon-worker-env.js.map +1 -0
- package/dist/vite-plugins/icons.d.ts.map +1 -1
- package/dist/vite-plugins/icons.js +4 -9
- package/dist/vite-plugins/icons.js.map +1 -1
- package/dist/vite-plugins/index.d.ts +10 -1
- package/dist/vite-plugins/index.d.ts.map +1 -1
- package/dist/vite-plugins/index.js +19 -7
- package/dist/vite-plugins/index.js.map +1 -1
- package/dist/vite-plugins/native.d.ts.map +1 -1
- package/dist/vite-plugins/native.js +0 -4
- package/dist/vite-plugins/native.js.map +1 -1
- package/dist/vite-plugins/react-compiler.d.ts.map +1 -1
- package/dist/vite-plugins/react-compiler.js +57 -18
- package/dist/vite-plugins/react-compiler.js.map +1 -1
- package/dist/vite-plugins/resource-shared.d.ts +3 -1
- package/dist/vite-plugins/resource-shared.d.ts.map +1 -1
- package/dist/vite-plugins/resource-shared.js +3 -1
- package/dist/vite-plugins/resource-shared.js.map +1 -1
- package/dist/vite-plugins/resources.d.ts.map +1 -1
- package/dist/vite-plugins/resources.js +40 -102
- package/dist/vite-plugins/resources.js.map +1 -1
- package/dist/vite-plugins/self-contained.d.ts.map +1 -1
- package/dist/vite-plugins/self-contained.js +159 -158
- package/dist/vite-plugins/self-contained.js.map +1 -1
- package/dist/vite-plugins/settings-worker-env.d.ts +1 -1
- package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
- package/dist/vite-plugins/settings-worker-env.js +5 -7
- package/dist/vite-plugins/settings-worker-env.js.map +1 -1
- package/dist/vite-plugins/settings.d.ts +1 -2
- package/dist/vite-plugins/settings.d.ts.map +1 -1
- package/dist/vite-plugins/settings.js +32 -27
- package/dist/vite-plugins/settings.js.map +1 -1
- package/dist/vite-plugins/store-links.d.ts.map +1 -1
- package/dist/vite-plugins/store-links.js +9 -5
- package/dist/vite-plugins/store-links.js.map +1 -1
- package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
- package/dist/vite-plugins/undeclared-library.js +25 -25
- package/dist/vite-plugins/undeclared-library.js.map +1 -1
- package/dist/vite-plugins/worker.d.ts.map +1 -1
- package/dist/vite-plugins/worker.js +21 -14
- package/dist/vite-plugins/worker.js.map +1 -1
- package/dist/vitest-plugin.d.ts +4 -3
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +12 -8
- package/dist/vitest-plugin.js.map +1 -1
- package/env.d.ts +9 -0
- package/package.json +28 -17
- package/src/builder.ts +45 -12
- package/src/cli.ts +15 -2
- package/src/codegen/config-dependencies.ts +470 -0
- package/src/codegen/freshness.ts +70 -17
- package/src/codegen/reference.ts +2 -8
- package/src/codegen/report.ts +5 -21
- package/src/codegen/run-codegen.ts +73 -160
- package/src/codegen/store-resolver.ts +16 -27
- package/src/commands/build.ts +13 -2
- package/src/commands/cleanup.ts +48 -0
- package/src/commands/codegen.ts +6 -5
- package/src/commands/deploy.ts +10 -2
- package/src/commands/dev.ts +45 -4
- package/src/commands/docs.ts +6 -17
- package/src/deploy/depends.ts +30 -3
- package/src/deploy/download.ts +33 -24
- package/src/deploy/freedesktop/copyright.ts +2 -14
- package/src/deploy/freedesktop/metainfo.ts +73 -21
- package/src/deploy/freedesktop/validate.ts +80 -15
- package/src/deploy/freedesktop/xml.ts +24 -32
- package/src/deploy/native-addon.ts +183 -0
- package/src/deploy/nfpm/config.ts +13 -4
- package/src/deploy/nfpm/contents.ts +8 -0
- package/src/deploy/node-runtime/download.ts +2 -2
- package/src/deploy/node-runtime/elf.ts +46 -5
- package/src/deploy/node-runtime/guard.ts +10 -14
- package/src/deploy/node-runtime/index.ts +148 -12
- package/src/deploy/node-runtime/license.ts +2 -8
- package/src/deploy/node-runtime/sonames.ts +17 -0
- package/src/deploy/notices/node-runtime.ts +2 -2
- package/src/deploy/notices/packages.ts +3 -11
- package/src/deploy/payload/copy-tree.ts +3 -4
- package/src/deploy/payload/launcher.ts +20 -1
- package/src/deploy/payload/stage.ts +78 -11
- package/src/deploy/run-deploy.ts +227 -72
- package/src/deploy/settings/arch.ts +40 -8
- package/src/deploy/settings/build-manifest.ts +30 -17
- package/src/deploy/settings/extra-files.ts +30 -4
- package/src/deploy/settings/index.ts +7 -2
- package/src/deploy/settings/libraries.ts +2 -22
- package/src/deploy/settings/paths.ts +78 -21
- package/src/deploy/settings/screenshots.ts +8 -46
- package/src/deploy/targets/appimage.ts +1 -0
- package/src/deploy/targets/flatpak-pnpm.ts +4 -4
- package/src/deploy/targets/flatpak-source.ts +19 -6
- package/src/deploy/targets/flatpak-sources.ts +1 -1
- package/src/deploy/targets/flatpak.ts +1 -0
- package/src/deploy/targets/nfpm-target.ts +14 -6
- package/src/deploy/types.ts +5 -1
- package/src/deploy/vendored/appimagetool.ts +2 -2
- package/src/deploy/vendored/nfpm.ts +1 -1
- package/src/dev/catalog-writes.ts +35 -0
- package/src/dev/entry-env.ts +2 -1
- package/src/dev/font-dir.ts +11 -0
- package/src/dev/headless.ts +40 -0
- package/src/dev/runner-deps.ts +20 -7
- package/src/dev/runner-main.ts +13 -5
- package/src/dev/runner.ts +37 -7
- package/src/dev/schema-dir.ts +2 -4
- package/src/dev/supervisor.ts +183 -32
- package/src/dev/vite-dev-server.ts +20 -2
- package/src/dev/watch-ignore.ts +16 -0
- package/src/i18n/catalogs.ts +23 -9
- package/src/i18n/metadata-templates.ts +2 -1
- package/src/i18n/source-messages.ts +1641 -262
- package/src/i18n/types.ts +97 -131
- package/src/internal/agent-rules.ts +7 -2
- package/src/internal/banner.ts +27 -6
- package/src/internal/build-manifest.ts +25 -1
- package/src/internal/build-output.ts +171 -0
- package/src/internal/cache-root.ts +12 -0
- package/src/internal/compile-cache-store.ts +50 -0
- package/src/internal/compile-cache.ts +20 -0
- package/src/internal/deploy-out-dir.ts +8 -0
- package/src/internal/docs-elements.ts +11 -5
- package/src/internal/entry-arg.ts +8 -1
- package/src/internal/errors.ts +1 -1
- package/src/internal/font-path.ts +15 -0
- package/src/internal/font-staging.ts +131 -0
- package/src/internal/icon-path.ts +6 -19
- package/src/internal/icon-staging.ts +58 -0
- package/src/internal/import-scan.ts +206 -0
- package/src/internal/module-hash.ts +22 -0
- package/src/internal/output-directory.ts +699 -0
- package/src/internal/parent-process.ts +110 -0
- package/src/internal/prepare-project.ts +11 -5
- package/src/internal/react-compiler-cache.ts +246 -0
- package/src/internal/source-imports.ts +64 -55
- package/src/internal/staging-file.ts +42 -0
- package/src/internal/xdg-banner.ts +13 -0
- package/src/internal/xdg-data-dirs.ts +1 -1
- package/src/mcp/client.ts +2 -2
- package/src/settings/render.ts +1 -13
- package/src/settings/schema.ts +23 -91
- package/src/vite-plugins/asset-extensions.ts +2 -0
- package/src/vite-plugins/asset-imports.ts +39 -45
- package/src/vite-plugins/asset-specifier.ts +17 -5
- package/src/vite-plugins/build-manifest.ts +7 -1
- package/src/vite-plugins/built-url.ts +6 -2
- package/src/vite-plugins/css.ts +16 -5
- package/src/vite-plugins/ensure-store.ts +2 -2
- package/src/vite-plugins/fast-refresh/refresh-filter.ts +10 -1
- package/src/vite-plugins/fast-refresh/swc-refresh.ts +33 -14
- package/src/vite-plugins/font-name.ts +582 -0
- package/src/vite-plugins/font-worker-env.ts +25 -0
- package/src/vite-plugins/font.ts +180 -0
- package/src/vite-plugins/i18n.ts +123 -11
- package/src/vite-plugins/icon-worker-env.ts +36 -0
- package/src/vite-plugins/icons.ts +4 -10
- package/src/vite-plugins/index.ts +36 -13
- package/src/vite-plugins/native.ts +0 -5
- package/src/vite-plugins/react-compiler.ts +83 -19
- package/src/vite-plugins/resource-shared.ts +4 -0
- package/src/vite-plugins/resources.ts +47 -144
- package/src/vite-plugins/self-contained.ts +184 -185
- package/src/vite-plugins/settings-worker-env.ts +5 -7
- package/src/vite-plugins/settings.ts +44 -33
- package/src/vite-plugins/store-links.ts +10 -5
- package/src/vite-plugins/undeclared-library.ts +30 -32
- package/src/vite-plugins/worker.ts +31 -16
- package/src/vitest-plugin.ts +12 -8
- package/dist/i18n/binding-extractor.d.ts +0 -30
- package/dist/i18n/binding-extractor.d.ts.map +0 -1
- package/dist/i18n/binding-extractor.js +0 -1324
- package/dist/i18n/binding-extractor.js.map +0 -1
- package/dist/i18n/extractor-plugin.d.ts +0 -8
- package/dist/i18n/extractor-plugin.d.ts.map +0 -1
- package/dist/i18n/extractor-plugin.js +0 -247
- package/dist/i18n/extractor-plugin.js.map +0 -1
- package/dist/internal/data-dir.d.ts +0 -4
- package/dist/internal/data-dir.d.ts.map +0 -1
- package/dist/internal/data-dir.js +0 -52
- package/dist/internal/data-dir.js.map +0 -1
- package/dist/vite-plugins/animated.d.ts +0 -5
- package/dist/vite-plugins/animated.d.ts.map +0 -1
- package/dist/vite-plugins/animated.js +0 -325
- package/dist/vite-plugins/animated.js.map +0 -1
- package/src/i18n/binding-extractor.ts +0 -1969
- package/src/i18n/extractor-plugin.ts +0 -413
- package/src/internal/data-dir.ts +0 -70
- package/src/vite-plugins/animated.ts +0 -486
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-directory.d.ts","sourceRoot":"","sources":["../../src/internal/output-directory.ts"],"names":[],"mappings":"AAmBA,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAoBpD,KAAK,0BAA0B,GAAG,UAAU,GAAG;IAC3C,MAAM,EAAE,CAAC,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrF,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,KAAK,uBAAuB,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,0BAA0B,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAiBtH,QAAA,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAkBhD,CAAC;AAklBF,QAAA,MAAM,sBAAsB,GACxB,UAAU,MAAM,EAChB,MAAM,MAAM,EACZ,YAAY,kBAAkB,KAC/B,uBAgBF,CAAC;AAEF,OAAO,EACH,KAAK,0BAA0B,EAC/B,sBAAsB,EACtB,eAAe,GAClB,CAAC"}
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readdirSync, readFileSync, realpathSync, renameSync, rmdirSync, rmSync, } from "node:fs";
|
|
2
|
+
import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
3
|
+
const hasErrorCode = (value, code) => typeof value === "object" && value !== null && "code" in value && value.code === code;
|
|
4
|
+
const readRegularFile = (path) => {
|
|
5
|
+
let descriptor = null;
|
|
6
|
+
try {
|
|
7
|
+
descriptor = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
8
|
+
if (!fstatSync(descriptor).isFile()) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return readFileSync(descriptor, "utf8");
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
finally {
|
|
17
|
+
if (descriptor !== null) {
|
|
18
|
+
closeSync(descriptor);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const openDirectoryLease = (path) => {
|
|
23
|
+
let descriptor = null;
|
|
24
|
+
try {
|
|
25
|
+
descriptor = openSync(path, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
26
|
+
const stats = fstatSync(descriptor, { bigint: true });
|
|
27
|
+
let retainedDescriptor = descriptor;
|
|
28
|
+
return {
|
|
29
|
+
identity: { device: stats.dev, inode: stats.ino },
|
|
30
|
+
path: join("/proc/self/fd", String(descriptor)),
|
|
31
|
+
release: () => {
|
|
32
|
+
if (retainedDescriptor === null) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const releasedDescriptor = retainedDescriptor;
|
|
36
|
+
retainedDescriptor = null;
|
|
37
|
+
closeSync(releasedDescriptor);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
if (descriptor !== null) {
|
|
43
|
+
closeSync(descriptor);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const readDirectoryIdentity = (path) => {
|
|
49
|
+
const lease = openDirectoryLease(path);
|
|
50
|
+
if (lease === null) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
lease.release();
|
|
54
|
+
return lease.identity;
|
|
55
|
+
};
|
|
56
|
+
const hasDirectoryIdentity = (path, expected) => {
|
|
57
|
+
const actual = readDirectoryIdentity(path);
|
|
58
|
+
return actual !== null && actual.device === expected.device && actual.inode === expected.inode;
|
|
59
|
+
};
|
|
60
|
+
const hasResolvedDirectoryIdentity = (path, expected) => {
|
|
61
|
+
try {
|
|
62
|
+
return hasDirectoryIdentity(realpathSync(path), expected);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const capturePath = (source, destination) => {
|
|
69
|
+
try {
|
|
70
|
+
renameSync(source, destination);
|
|
71
|
+
return "captured";
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (hasErrorCode(error, "ENOENT")) {
|
|
75
|
+
return "missing";
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const createQuarantineDirectory = (parent, displayParent) => {
|
|
81
|
+
const created = mkdtempSync(join(parent.path, ".gtkx-output-"));
|
|
82
|
+
const name = basename(created);
|
|
83
|
+
const entry = join(parent.path, name);
|
|
84
|
+
const lease = openDirectoryLease(entry);
|
|
85
|
+
if (lease === null) {
|
|
86
|
+
rmdirSync(entry);
|
|
87
|
+
throw new Error("Could not secure the output quarantine directory");
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
displayPath: join(displayParent, name),
|
|
91
|
+
path: lease.path,
|
|
92
|
+
release: lease.release,
|
|
93
|
+
remove: () => {
|
|
94
|
+
if (!hasDirectoryIdentity(entry, lease.identity)) {
|
|
95
|
+
throw new Error(`The output quarantine changed; retained files are in ${join(displayParent, name)}`);
|
|
96
|
+
}
|
|
97
|
+
rmdirSync(entry);
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const releaseTransactionLeases = (fresh, quarantine, parent, root) => {
|
|
102
|
+
try {
|
|
103
|
+
fresh.release();
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
try {
|
|
107
|
+
quarantine.release();
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
try {
|
|
111
|
+
parent.release();
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
root.release();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const releasePreparationLeases = (quarantine, parent, root) => {
|
|
120
|
+
try {
|
|
121
|
+
quarantine.release();
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
try {
|
|
125
|
+
parent.release();
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
root.release();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const movePath = (source, destination, operations) => {
|
|
133
|
+
renameSync(source, destination);
|
|
134
|
+
operations.push({ source, destination });
|
|
135
|
+
};
|
|
136
|
+
const moveNames = (source, destination, names, operations) => {
|
|
137
|
+
for (const name of names) {
|
|
138
|
+
movePath(join(source, name), join(destination, name), operations);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const reverseOperations = (operations) => {
|
|
142
|
+
for (const operation of operations.toReversed()) {
|
|
143
|
+
renameSync(operation.destination, operation.source);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const overlayDirectory = (source, destination, backup, operations) => {
|
|
147
|
+
for (const name of readdirSync(source)) {
|
|
148
|
+
overlayEntry({
|
|
149
|
+
source: join(source, name),
|
|
150
|
+
destination: join(destination, name),
|
|
151
|
+
backup: join(backup, name),
|
|
152
|
+
operations,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const overlayEntry = (request) => {
|
|
157
|
+
const destinationStats = lstatSync(request.destination, { throwIfNoEntry: false });
|
|
158
|
+
if (destinationStats === undefined) {
|
|
159
|
+
movePath(request.source, request.destination, request.operations);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const sourceStats = lstatSync(request.source);
|
|
163
|
+
if (sourceStats.isDirectory() && destinationStats.isDirectory()) {
|
|
164
|
+
overlayDirectory(request.source, request.destination, request.backup, request.operations);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (!sourceStats.isFile() || !destinationStats.isFile()) {
|
|
168
|
+
throw new Error("Cannot merge conflicting preserved output entries");
|
|
169
|
+
}
|
|
170
|
+
mkdirSync(dirname(request.backup), { recursive: true });
|
|
171
|
+
movePath(request.destination, request.backup, request.operations);
|
|
172
|
+
movePath(request.source, request.destination, request.operations);
|
|
173
|
+
};
|
|
174
|
+
const restoreUnexpectedOutput = (unexpected, target, quarantine, previous) => {
|
|
175
|
+
try {
|
|
176
|
+
renameSync(unexpected, target);
|
|
177
|
+
if (previous === null) {
|
|
178
|
+
quarantine.remove();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
throw new Error(`Output recovery failed; retained files are in ${quarantine.displayPath}`, { cause: error });
|
|
183
|
+
}
|
|
184
|
+
throw new Error(`Output changed during the operation; the previous output is retained in ${quarantine.displayPath}`);
|
|
185
|
+
};
|
|
186
|
+
const recoverUnsecuredPublicPath = (target, quarantine, previous, error) => {
|
|
187
|
+
const unsecured = join(quarantine.path, "unsecured");
|
|
188
|
+
const publicCapture = capturePath(target, unsecured);
|
|
189
|
+
try {
|
|
190
|
+
if (previous !== null) {
|
|
191
|
+
renameSync(previous, target);
|
|
192
|
+
}
|
|
193
|
+
else if (publicCapture === "captured") {
|
|
194
|
+
renameSync(unsecured, target);
|
|
195
|
+
}
|
|
196
|
+
if (previous === null || publicCapture === "missing") {
|
|
197
|
+
quarantine.remove();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (recoveryError) {
|
|
201
|
+
throw new AggregateError([error, recoveryError], `Could not recover the output directory; retained files are in ${quarantine.displayPath}`, { cause: recoveryError });
|
|
202
|
+
}
|
|
203
|
+
throw new Error(`Could not secure the output directory; retained files are in ${quarantine.displayPath}`, {
|
|
204
|
+
cause: error,
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
const recoverFailedCapture = (quarantine, error) => {
|
|
208
|
+
try {
|
|
209
|
+
quarantine.remove();
|
|
210
|
+
}
|
|
211
|
+
catch (recoveryError) {
|
|
212
|
+
throw new AggregateError([error, recoveryError], `Could not clean the output quarantine; retained files are in ${quarantine.displayPath}`, { cause: recoveryError });
|
|
213
|
+
}
|
|
214
|
+
throw error;
|
|
215
|
+
};
|
|
216
|
+
const rollbackOutputDirectory = (target, quarantine, previous, freshIdentity) => {
|
|
217
|
+
const failed = join(quarantine.path, "failed");
|
|
218
|
+
const freshCapture = capturePath(target, failed);
|
|
219
|
+
if (freshCapture === "captured" && !hasDirectoryIdentity(failed, freshIdentity)) {
|
|
220
|
+
restoreUnexpectedOutput(failed, target, quarantine, previous);
|
|
221
|
+
}
|
|
222
|
+
if (previous !== null) {
|
|
223
|
+
renameSync(previous, target);
|
|
224
|
+
}
|
|
225
|
+
if (freshCapture === "captured") {
|
|
226
|
+
rmSync(failed, { recursive: true, force: true, maxRetries: 5 });
|
|
227
|
+
}
|
|
228
|
+
quarantine.remove();
|
|
229
|
+
};
|
|
230
|
+
const restoreMissingFreshOutput = (target, quarantine, previous) => {
|
|
231
|
+
try {
|
|
232
|
+
if (previous !== null) {
|
|
233
|
+
renameSync(previous, target);
|
|
234
|
+
}
|
|
235
|
+
quarantine.remove();
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
throw new Error(`The fresh output disappeared; retained files are in ${quarantine.displayPath}`, {
|
|
239
|
+
cause: error,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
throw new Error("The fresh output directory disappeared before it could be committed");
|
|
243
|
+
};
|
|
244
|
+
const captureVerifiedFreshOutput = (target, quarantine, previous, freshIdentity) => {
|
|
245
|
+
const fresh = join(quarantine.path, "fresh");
|
|
246
|
+
if (capturePath(target, fresh) === "missing") {
|
|
247
|
+
restoreMissingFreshOutput(target, quarantine, previous);
|
|
248
|
+
}
|
|
249
|
+
if (!hasDirectoryIdentity(fresh, freshIdentity)) {
|
|
250
|
+
restoreUnexpectedOutput(fresh, target, quarantine, previous);
|
|
251
|
+
}
|
|
252
|
+
return fresh;
|
|
253
|
+
};
|
|
254
|
+
const recoverCommit = (request) => {
|
|
255
|
+
const { backup, error, fresh, operations, previous, quarantine, target } = request;
|
|
256
|
+
try {
|
|
257
|
+
reverseOperations(operations);
|
|
258
|
+
renameSync(previous, target);
|
|
259
|
+
rmSync(fresh, { recursive: true, force: true, maxRetries: 5 });
|
|
260
|
+
rmSync(backup, { recursive: true, force: true, maxRetries: 5 });
|
|
261
|
+
quarantine.remove();
|
|
262
|
+
}
|
|
263
|
+
catch (recoveryError) {
|
|
264
|
+
throw new AggregateError([error, recoveryError], `Could not restore the previous output; retained files are in ${quarantine.displayPath}`, { cause: recoveryError });
|
|
265
|
+
}
|
|
266
|
+
throw error;
|
|
267
|
+
};
|
|
268
|
+
const installFreshOutput = (request) => {
|
|
269
|
+
const { fresh, preservedNames, previous, quarantine, target } = request;
|
|
270
|
+
const backup = join(quarantine.path, "backup");
|
|
271
|
+
const operations = [];
|
|
272
|
+
try {
|
|
273
|
+
const oldNames = readdirSync(previous).filter((name) => !preservedNames.has(name));
|
|
274
|
+
const freshNames = readdirSync(fresh);
|
|
275
|
+
const ordinaryFreshNames = freshNames.filter((name) => !preservedNames.has(name));
|
|
276
|
+
const preservedFreshNames = freshNames.filter((name) => preservedNames.has(name));
|
|
277
|
+
mkdirSync(backup);
|
|
278
|
+
moveNames(previous, backup, oldNames, operations);
|
|
279
|
+
moveNames(fresh, previous, ordinaryFreshNames, operations);
|
|
280
|
+
for (const name of preservedFreshNames) {
|
|
281
|
+
overlayEntry({
|
|
282
|
+
source: join(fresh, name),
|
|
283
|
+
destination: join(previous, name),
|
|
284
|
+
backup: join(backup, name),
|
|
285
|
+
operations,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
renameSync(previous, target);
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
recoverCommit({ ...request, backup, operations, error });
|
|
292
|
+
}
|
|
293
|
+
rmSync(fresh, { recursive: true, force: true, maxRetries: 5 });
|
|
294
|
+
rmSync(backup, { recursive: true, force: true, maxRetries: 5 });
|
|
295
|
+
quarantine.remove();
|
|
296
|
+
};
|
|
297
|
+
const commitOutputDirectory = (request) => {
|
|
298
|
+
const { freshIdentity, preservedNames, previous, quarantine, target } = request;
|
|
299
|
+
const fresh = captureVerifiedFreshOutput(target, quarantine, previous, freshIdentity);
|
|
300
|
+
if (previous === null) {
|
|
301
|
+
renameSync(fresh, target);
|
|
302
|
+
quarantine.remove();
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
installFreshOutput({ target, quarantine, previous, fresh, preservedNames });
|
|
306
|
+
};
|
|
307
|
+
const assertFreshOutput = (path, isFresh) => {
|
|
308
|
+
if (isFresh !== undefined && !isFresh(path)) {
|
|
309
|
+
throw new Error("The build did not write to the secured output directory");
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const createOutputDirectoryTransaction = (request) => {
|
|
313
|
+
const { fresh, parent, previous, publicParent, publicPath, publicRoot, quarantine, root, target } = request;
|
|
314
|
+
let state = "prepared";
|
|
315
|
+
const commit = (preservedNames = new Set(), isFresh) => {
|
|
316
|
+
if (state !== "prepared") {
|
|
317
|
+
throw new Error("The output directory transaction has already finished");
|
|
318
|
+
}
|
|
319
|
+
if (!hasResolvedDirectoryIdentity(publicRoot, root.identity) ||
|
|
320
|
+
!hasResolvedDirectoryIdentity(publicParent, parent.identity)) {
|
|
321
|
+
throw new Error(`The output parent changed; previous output is retained in ${quarantine.displayPath}`);
|
|
322
|
+
}
|
|
323
|
+
assertFreshOutput(target, isFresh);
|
|
324
|
+
state = "retained";
|
|
325
|
+
try {
|
|
326
|
+
commitOutputDirectory({
|
|
327
|
+
target,
|
|
328
|
+
quarantine,
|
|
329
|
+
previous,
|
|
330
|
+
freshIdentity: fresh.identity,
|
|
331
|
+
preservedNames,
|
|
332
|
+
});
|
|
333
|
+
state = "committed";
|
|
334
|
+
}
|
|
335
|
+
finally {
|
|
336
|
+
releaseTransactionLeases(fresh, quarantine, parent, root);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
const rollback = () => {
|
|
340
|
+
if (state !== "prepared") {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
state = "retained";
|
|
344
|
+
try {
|
|
345
|
+
rollbackOutputDirectory(target, quarantine, previous, fresh.identity);
|
|
346
|
+
state = "rolled-back";
|
|
347
|
+
}
|
|
348
|
+
finally {
|
|
349
|
+
releaseTransactionLeases(fresh, quarantine, parent, root);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
return { path: publicPath, commit, [Symbol.dispose]: rollback };
|
|
353
|
+
};
|
|
354
|
+
const rollbackAfterError = (transaction, error) => {
|
|
355
|
+
try {
|
|
356
|
+
transaction[Symbol.dispose]();
|
|
357
|
+
}
|
|
358
|
+
catch (rollbackError) {
|
|
359
|
+
throw new AggregateError([error, rollbackError], "Could not roll back the output directory transaction", { cause: rollbackError });
|
|
360
|
+
}
|
|
361
|
+
throw error;
|
|
362
|
+
};
|
|
363
|
+
const requireFreshDirectoryLease = (resources) => {
|
|
364
|
+
const { parent, previous, quarantine, root, target } = resources;
|
|
365
|
+
const lease = openDirectoryLease(target);
|
|
366
|
+
if (lease !== null) {
|
|
367
|
+
return lease;
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
return recoverUnsecuredPublicPath(target, quarantine, previous, new Error("Could not record the fresh output directory identity"));
|
|
371
|
+
}
|
|
372
|
+
finally {
|
|
373
|
+
releasePreparationLeases(quarantine, parent, root);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
const requireDirectoryLease = (path, message) => {
|
|
377
|
+
const lease = openDirectoryLease(path);
|
|
378
|
+
if (lease === null) {
|
|
379
|
+
throw new Error(message);
|
|
380
|
+
}
|
|
381
|
+
return lease;
|
|
382
|
+
};
|
|
383
|
+
const createChildDirectoryLease = (parent, name) => {
|
|
384
|
+
const path = join(parent.path, name);
|
|
385
|
+
try {
|
|
386
|
+
mkdirSync(path);
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
if (!hasErrorCode(error, "EEXIST")) {
|
|
390
|
+
throw error;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return requireDirectoryLease(path, "Could not secure the output parent directory");
|
|
394
|
+
};
|
|
395
|
+
const openOutputParent = (root, rootPath, outputPath) => {
|
|
396
|
+
const relativeParent = relative(rootPath, dirname(outputPath));
|
|
397
|
+
if (relativeParent === ".." || isAbsolute(relativeParent) || relativeParent.startsWith(`..${sep}`)) {
|
|
398
|
+
throw new Error("The output directory must be below the project root");
|
|
399
|
+
}
|
|
400
|
+
let parent = requireDirectoryLease(`${root.path}/.`, "Could not secure the project root directory");
|
|
401
|
+
const segments = relativeParent.split(sep);
|
|
402
|
+
try {
|
|
403
|
+
for (const segment of segments) {
|
|
404
|
+
if (segment.length === 0) {
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
const child = createChildDirectoryLease(parent, segment);
|
|
408
|
+
parent.release();
|
|
409
|
+
parent = child;
|
|
410
|
+
}
|
|
411
|
+
return parent;
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
parent.release();
|
|
415
|
+
throw error;
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
const createPreparationResources = (rootPath, path) => {
|
|
419
|
+
const canonicalRoot = realpathSync(rootPath);
|
|
420
|
+
const root = requireDirectoryLease(canonicalRoot, "Could not secure the project root directory");
|
|
421
|
+
let parent;
|
|
422
|
+
try {
|
|
423
|
+
parent = openOutputParent(root, rootPath, path);
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
root.release();
|
|
427
|
+
throw error;
|
|
428
|
+
}
|
|
429
|
+
let quarantine;
|
|
430
|
+
try {
|
|
431
|
+
quarantine = createQuarantineDirectory(root, canonicalRoot);
|
|
432
|
+
}
|
|
433
|
+
catch (error) {
|
|
434
|
+
parent.release();
|
|
435
|
+
root.release();
|
|
436
|
+
throw error;
|
|
437
|
+
}
|
|
438
|
+
const target = join(parent.path, basename(path));
|
|
439
|
+
const captured = join(quarantine.path, "previous");
|
|
440
|
+
let previous = null;
|
|
441
|
+
try {
|
|
442
|
+
previous = capturePath(target, captured) === "captured" ? captured : null;
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
try {
|
|
446
|
+
recoverFailedCapture(quarantine, error);
|
|
447
|
+
}
|
|
448
|
+
finally {
|
|
449
|
+
releasePreparationLeases(quarantine, parent, root);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
try {
|
|
453
|
+
mkdirSync(target);
|
|
454
|
+
}
|
|
455
|
+
catch (error) {
|
|
456
|
+
try {
|
|
457
|
+
recoverUnsecuredPublicPath(target, quarantine, previous, error);
|
|
458
|
+
}
|
|
459
|
+
finally {
|
|
460
|
+
releasePreparationLeases(quarantine, parent, root);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
target,
|
|
465
|
+
publicPath: path,
|
|
466
|
+
publicRoot: rootPath,
|
|
467
|
+
publicParent: dirname(path),
|
|
468
|
+
parent,
|
|
469
|
+
quarantine,
|
|
470
|
+
previous,
|
|
471
|
+
root,
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
const prepareOutputDirectory = (rootPath, path, isReusable) => {
|
|
475
|
+
const resources = createPreparationResources(rootPath, path);
|
|
476
|
+
const fresh = requireFreshDirectoryLease(resources);
|
|
477
|
+
const transaction = createOutputDirectoryTransaction({ ...resources, fresh });
|
|
478
|
+
try {
|
|
479
|
+
if (resources.previous === null || isReusable(resources.previous)) {
|
|
480
|
+
return { status: "prepared", transaction };
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
catch (error) {
|
|
484
|
+
rollbackAfterError(transaction, error);
|
|
485
|
+
}
|
|
486
|
+
transaction[Symbol.dispose]();
|
|
487
|
+
return { status: "unsafe" };
|
|
488
|
+
};
|
|
489
|
+
export { prepareOutputDirectory, readRegularFile, };
|
|
490
|
+
//# sourceMappingURL=output-directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-directory.js","sourceRoot":"","sources":["../../src/internal/output-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,SAAS,EACT,MAAM,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AA0C/E,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,IAAY,EAAW,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAE1F,MAAM,eAAe,GAAG,CAAC,IAAY,EAAiB,EAAE;IACpD,IAAI,UAAU,GAAkB,IAAI,CAAC;IAErC,IAAI,CAAC;QACD,UAAU,GAAG,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;QAE9F,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;Y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AE,OAAO,CAAC,IAAI,CAAC;QAC3B,MAAM;QACN,UAAU;QACV,QAAQ;QACR,IAAI;KACP,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAC3B,QAAgB,EAChB,IAAY,EACZ,UAA8B,EACP,EAAE;IACzB,MAAM,SAAS,GAAG,0BAA0B,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,gCAAgC,CAAC,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAE9E,IAAI,CAAC;QACD,IAAI,SAAS,CAAC,QAAQ,KAAK,IAAI,IAAI,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;QAC/C,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,kBAAkB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAE9B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC,CAAC;AAEF,OAAO,EAEH,sBAAsB,EACtB,eAAe,GAClB,CAAC","sourcesContent":["import {\n closeSync,\n constants,\n fstatSync,\n lstatSync,\n mkdirSync,\n mkdtempSync,\n openSync,\n readdirSync,\n readFileSync,\n realpathSync,\n renameSync,\n rmdirSync,\n rmSync,\n} from \"node:fs\";\nimport { basename, dirname, isAbsolute, join, relative, sep } from \"node:path\";\n\ntype DirectoryIdentity = { device: bigint; inode: bigint };\ntype DirectoryLease = { identity: DirectoryIdentity; path: string; release: () => void };\ntype DirectoryValidator = (path: string) => boolean;\ntype QuarantineDirectory = { displayPath: string; path: string; remove: () => void; release: () => void };\ntype CommitOutputRequest = {\n freshIdentity: DirectoryIdentity;\n preservedNames: ReadonlySet<string>;\n previous: string | null;\n quarantine: QuarantineDirectory;\n target: string;\n};\ntype InstallFreshOutputRequest = Omit<CommitOutputRequest, \"freshIdentity\" | \"previous\"> & {\n fresh: string;\n previous: string;\n};\ntype RenameOperation = { destination: string; source: string };\ntype RecoverCommitRequest = InstallFreshOutputRequest & {\n backup: string;\n error: unknown;\n operations: RenameOperation[];\n};\ntype OverlayEntryRequest = RenameOperation & { backup: string; operations: RenameOperation[] };\ntype OutputDirectoryTransaction = Disposable & {\n commit: (preservedNames?: ReadonlySet<string>, isFresh?: DirectoryValidator) => void;\n path: string;\n};\ntype PreparedOutputDirectory = { status: \"prepared\"; transaction: OutputDirectoryTransaction } | { status: \"unsafe\" };\ntype PreparationResources = {\n parent: DirectoryLease;\n previous: string | null;\n publicParent: string;\n publicPath: string;\n publicRoot: string;\n quarantine: QuarantineDirectory;\n root: DirectoryLease;\n target: string;\n};\ntype TransactionRequest = PreparationResources & { fresh: DirectoryLease };\ntype TransactionState = \"committed\" | \"prepared\" | \"retained\" | \"rolled-back\";\n\nconst hasErrorCode = (value: unknown, code: string): boolean =>\n typeof value === \"object\" && value !== null && \"code\" in value && value.code === code;\n\nconst readRegularFile = (path: string): string | null => {\n let descriptor: number | null = null;\n\n try {\n descriptor = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);\n\n if (!fstatSync(descriptor).isFile()) {\n return null;\n }\n\n return readFileSync(descriptor, \"utf8\");\n } catch {\n return null;\n } finally {\n if (descriptor !== null) {\n closeSync(descriptor);\n }\n }\n};\n\nconst openDirectoryLease = (path: string): DirectoryLease | null => {\n let descriptor: number | null = null;\n\n try {\n descriptor = openSync(path, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);\n const stats = fstatSync(descriptor, { bigint: true });\n let retainedDescriptor: number | null = descriptor;\n\n return {\n identity: { device: stats.dev, inode: stats.ino },\n path: join(\"/proc/self/fd\", String(descriptor)),\n release: () => {\n if (retainedDescriptor === null) {\n return;\n }\n\n const releasedDescriptor = retainedDescriptor;\n retainedDescriptor = null;\n closeSync(releasedDescriptor);\n },\n };\n } catch {\n if (descriptor !== null) {\n closeSync(descriptor);\n }\n\n return null;\n }\n};\n\nconst readDirectoryIdentity = (path: string): DirectoryIdentity | null => {\n const lease = openDirectoryLease(path);\n\n if (lease === null) {\n return null;\n }\n\n lease.release();\n\n return lease.identity;\n};\n\nconst hasDirectoryIdentity = (path: string, expected: DirectoryIdentity): boolean => {\n const actual = readDirectoryIdentity(path);\n\n return actual !== null && actual.device === expected.device && actual.inode === expected.inode;\n};\n\nconst hasResolvedDirectoryIdentity = (path: string, expected: DirectoryIdentity): boolean => {\n try {\n return hasDirectoryIdentity(realpathSync(path), expected);\n } catch {\n return false;\n }\n};\n\nconst capturePath = (source: string, destination: string): \"captured\" | \"missing\" => {\n try {\n renameSync(source, destination);\n\n return \"captured\";\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\")) {\n return \"missing\";\n }\n\n throw error;\n }\n};\n\nconst createQuarantineDirectory = (parent: DirectoryLease, displayParent: string): QuarantineDirectory => {\n const created = mkdtempSync(join(parent.path, \".gtkx-output-\"));\n const name = basename(created);\n const entry = join(parent.path, name);\n const lease = openDirectoryLease(entry);\n\n if (lease === null) {\n rmdirSync(entry);\n throw new Error(\"Could not secure the output quarantine directory\");\n }\n\n return {\n displayPath: join(displayParent, name),\n path: lease.path,\n release: lease.release,\n remove: () => {\n if (!hasDirectoryIdentity(entry, lease.identity)) {\n throw new Error(`The output quarantine changed; retained files are in ${join(displayParent, name)}`);\n }\n\n rmdirSync(entry);\n },\n };\n};\n\nconst releaseTransactionLeases = (\n fresh: DirectoryLease,\n quarantine: QuarantineDirectory,\n parent: DirectoryLease,\n root: DirectoryLease,\n): void => {\n try {\n fresh.release();\n } finally {\n try {\n quarantine.release();\n } finally {\n try {\n parent.release();\n } finally {\n root.release();\n }\n }\n }\n};\n\nconst releasePreparationLeases = (\n quarantine: QuarantineDirectory,\n parent: DirectoryLease,\n root: DirectoryLease,\n): void => {\n try {\n quarantine.release();\n } finally {\n try {\n parent.release();\n } finally {\n root.release();\n }\n }\n};\n\nconst movePath = (source: string, destination: string, operations: RenameOperation[]): void => {\n renameSync(source, destination);\n operations.push({ source, destination });\n};\n\nconst moveNames = (source: string, destination: string, names: string[], operations: RenameOperation[]): void => {\n for (const name of names) {\n movePath(join(source, name), join(destination, name), operations);\n }\n};\n\nconst reverseOperations = (operations: RenameOperation[]): void => {\n for (const operation of operations.toReversed()) {\n renameSync(operation.destination, operation.source);\n }\n};\n\nconst overlayDirectory = (\n source: string,\n destination: string,\n backup: string,\n operations: RenameOperation[],\n): void => {\n for (const name of readdirSync(source)) {\n overlayEntry({\n source: join(source, name),\n destination: join(destination, name),\n backup: join(backup, name),\n operations,\n });\n }\n};\n\nconst overlayEntry = (request: OverlayEntryRequest): void => {\n const destinationStats = lstatSync(request.destination, { throwIfNoEntry: false });\n\n if (destinationStats === undefined) {\n movePath(request.source, request.destination, request.operations);\n\n return;\n }\n\n const sourceStats = lstatSync(request.source);\n\n if (sourceStats.isDirectory() && destinationStats.isDirectory()) {\n overlayDirectory(request.source, request.destination, request.backup, request.operations);\n\n return;\n }\n\n if (!sourceStats.isFile() || !destinationStats.isFile()) {\n throw new Error(\"Cannot merge conflicting preserved output entries\");\n }\n\n mkdirSync(dirname(request.backup), { recursive: true });\n movePath(request.destination, request.backup, request.operations);\n movePath(request.source, request.destination, request.operations);\n};\n\nconst restoreUnexpectedOutput = (\n unexpected: string,\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n): never => {\n try {\n renameSync(unexpected, target);\n\n if (previous === null) {\n quarantine.remove();\n }\n } catch (error) {\n throw new Error(`Output recovery failed; retained files are in ${quarantine.displayPath}`, { cause: error });\n }\n\n throw new Error(\n `Output changed during the operation; the previous output is retained in ${quarantine.displayPath}`,\n );\n};\n\nconst recoverUnsecuredPublicPath = (\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n error: unknown,\n): never => {\n const unsecured = join(quarantine.path, \"unsecured\");\n const publicCapture = capturePath(target, unsecured);\n\n try {\n if (previous !== null) {\n renameSync(previous, target);\n } else if (publicCapture === \"captured\") {\n renameSync(unsecured, target);\n }\n\n if (previous === null || publicCapture === \"missing\") {\n quarantine.remove();\n }\n } catch (recoveryError) {\n throw new AggregateError(\n [error, recoveryError],\n `Could not recover the output directory; retained files are in ${quarantine.displayPath}`,\n { cause: recoveryError },\n );\n }\n\n throw new Error(`Could not secure the output directory; retained files are in ${quarantine.displayPath}`, {\n cause: error,\n });\n};\n\nconst recoverFailedCapture = (quarantine: QuarantineDirectory, error: unknown): never => {\n try {\n quarantine.remove();\n } catch (recoveryError) {\n throw new AggregateError(\n [error, recoveryError],\n `Could not clean the output quarantine; retained files are in ${quarantine.displayPath}`,\n { cause: recoveryError },\n );\n }\n\n throw error;\n};\n\nconst rollbackOutputDirectory = (\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n freshIdentity: DirectoryIdentity,\n): void => {\n const failed = join(quarantine.path, \"failed\");\n const freshCapture = capturePath(target, failed);\n\n if (freshCapture === \"captured\" && !hasDirectoryIdentity(failed, freshIdentity)) {\n restoreUnexpectedOutput(failed, target, quarantine, previous);\n }\n\n if (previous !== null) {\n renameSync(previous, target);\n }\n\n if (freshCapture === \"captured\") {\n rmSync(failed, { recursive: true, force: true, maxRetries: 5 });\n }\n\n quarantine.remove();\n};\n\nconst restoreMissingFreshOutput = (\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n): never => {\n try {\n if (previous !== null) {\n renameSync(previous, target);\n }\n\n quarantine.remove();\n } catch (error) {\n throw new Error(`The fresh output disappeared; retained files are in ${quarantine.displayPath}`, {\n cause: error,\n });\n }\n\n throw new Error(\"The fresh output directory disappeared before it could be committed\");\n};\n\nconst captureVerifiedFreshOutput = (\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n freshIdentity: DirectoryIdentity,\n): string => {\n const fresh = join(quarantine.path, \"fresh\");\n\n if (capturePath(target, fresh) === \"missing\") {\n restoreMissingFreshOutput(target, quarantine, previous);\n }\n\n if (!hasDirectoryIdentity(fresh, freshIdentity)) {\n restoreUnexpectedOutput(fresh, target, quarantine, previous);\n }\n\n return fresh;\n};\n\nconst recoverCommit = (request: RecoverCommitRequest): never => {\n const { backup, error, fresh, operations, previous, quarantine, target } = request;\n\n try {\n reverseOperations(operations);\n renameSync(previous, target);\n rmSync(fresh, { recursive: true, force: true, maxRetries: 5 });\n rmSync(backup, { recursive: true, force: true, maxRetries: 5 });\n quarantine.remove();\n } catch (recoveryError) {\n throw new AggregateError(\n [error, recoveryError],\n `Could not restore the previous output; retained files are in ${quarantine.displayPath}`,\n { cause: recoveryError },\n );\n }\n\n throw error;\n};\n\nconst installFreshOutput = (request: InstallFreshOutputRequest): void => {\n const { fresh, preservedNames, previous, quarantine, target } = request;\n const backup = join(quarantine.path, \"backup\");\n const operations: RenameOperation[] = [];\n\n try {\n const oldNames = readdirSync(previous).filter((name) => !preservedNames.has(name));\n const freshNames = readdirSync(fresh);\n const ordinaryFreshNames = freshNames.filter((name) => !preservedNames.has(name));\n const preservedFreshNames = freshNames.filter((name) => preservedNames.has(name));\n mkdirSync(backup);\n moveNames(previous, backup, oldNames, operations);\n moveNames(fresh, previous, ordinaryFreshNames, operations);\n\n for (const name of preservedFreshNames) {\n overlayEntry({\n source: join(fresh, name),\n destination: join(previous, name),\n backup: join(backup, name),\n operations,\n });\n }\n\n renameSync(previous, target);\n } catch (error) {\n recoverCommit({ ...request, backup, operations, error });\n }\n\n rmSync(fresh, { recursive: true, force: true, maxRetries: 5 });\n rmSync(backup, { recursive: true, force: true, maxRetries: 5 });\n quarantine.remove();\n};\n\nconst commitOutputDirectory = (request: CommitOutputRequest): void => {\n const { freshIdentity, preservedNames, previous, quarantine, target } = request;\n const fresh = captureVerifiedFreshOutput(target, quarantine, previous, freshIdentity);\n\n if (previous === null) {\n renameSync(fresh, target);\n quarantine.remove();\n\n return;\n }\n\n installFreshOutput({ target, quarantine, previous, fresh, preservedNames });\n};\n\nconst assertFreshOutput = (path: string, isFresh: DirectoryValidator | undefined): void => {\n if (isFresh !== undefined && !isFresh(path)) {\n throw new Error(\"The build did not write to the secured output directory\");\n }\n};\n\nconst createOutputDirectoryTransaction = (request: TransactionRequest): OutputDirectoryTransaction => {\n const { fresh, parent, previous, publicParent, publicPath, publicRoot, quarantine, root, target } = request;\n let state: TransactionState = \"prepared\";\n\n const commit = (\n preservedNames: ReadonlySet<string> = new Set(),\n isFresh?: DirectoryValidator,\n ): void => {\n if (state !== \"prepared\") {\n throw new Error(\"The output directory transaction has already finished\");\n }\n\n if (\n !hasResolvedDirectoryIdentity(publicRoot, root.identity) ||\n !hasResolvedDirectoryIdentity(publicParent, parent.identity)\n ) {\n throw new Error(`The output parent changed; previous output is retained in ${quarantine.displayPath}`);\n }\n\n assertFreshOutput(target, isFresh);\n state = \"retained\";\n\n try {\n commitOutputDirectory({\n target,\n quarantine,\n previous,\n freshIdentity: fresh.identity,\n preservedNames,\n });\n state = \"committed\";\n } finally {\n releaseTransactionLeases(fresh, quarantine, parent, root);\n }\n };\n\n const rollback = (): void => {\n if (state !== \"prepared\") {\n return;\n }\n\n state = \"retained\";\n\n try {\n rollbackOutputDirectory(target, quarantine, previous, fresh.identity);\n state = \"rolled-back\";\n } finally {\n releaseTransactionLeases(fresh, quarantine, parent, root);\n }\n };\n\n return { path: publicPath, commit, [Symbol.dispose]: rollback };\n};\n\nconst rollbackAfterError = (transaction: OutputDirectoryTransaction, error: unknown): never => {\n try {\n transaction[Symbol.dispose]();\n } catch (rollbackError) {\n throw new AggregateError(\n [error, rollbackError],\n \"Could not roll back the output directory transaction\",\n { cause: rollbackError },\n );\n }\n\n throw error;\n};\n\nconst requireFreshDirectoryLease = (resources: PreparationResources): DirectoryLease => {\n const { parent, previous, quarantine, root, target } = resources;\n const lease = openDirectoryLease(target);\n\n if (lease !== null) {\n return lease;\n }\n\n try {\n return recoverUnsecuredPublicPath(\n target,\n quarantine,\n previous,\n new Error(\"Could not record the fresh output directory identity\"),\n );\n } finally {\n releasePreparationLeases(quarantine, parent, root);\n }\n};\n\nconst requireDirectoryLease = (path: string, message: string): DirectoryLease => {\n const lease = openDirectoryLease(path);\n\n if (lease === null) {\n throw new Error(message);\n }\n\n return lease;\n};\n\nconst createChildDirectoryLease = (parent: DirectoryLease, name: string): DirectoryLease => {\n const path = join(parent.path, name);\n\n try {\n mkdirSync(path);\n } catch (error) {\n if (!hasErrorCode(error, \"EEXIST\")) {\n throw error;\n }\n }\n\n return requireDirectoryLease(path, \"Could not secure the output parent directory\");\n};\n\nconst openOutputParent = (root: DirectoryLease, rootPath: string, outputPath: string): DirectoryLease => {\n const relativeParent = relative(rootPath, dirname(outputPath));\n\n if (relativeParent === \"..\" || isAbsolute(relativeParent) || relativeParent.startsWith(`..${sep}`)) {\n throw new Error(\"The output directory must be below the project root\");\n }\n\n let parent = requireDirectoryLease(`${root.path}/.`, \"Could not secure the project root directory\");\n const segments = relativeParent.split(sep);\n\n try {\n for (const segment of segments) {\n if (segment.length === 0) {\n continue;\n }\n\n const child = createChildDirectoryLease(parent, segment);\n parent.release();\n parent = child;\n }\n\n return parent;\n } catch (error) {\n parent.release();\n throw error;\n }\n};\n\nconst createPreparationResources = (rootPath: string, path: string): PreparationResources => {\n const canonicalRoot = realpathSync(rootPath);\n const root = requireDirectoryLease(canonicalRoot, \"Could not secure the project root directory\");\n let parent: DirectoryLease;\n\n try {\n parent = openOutputParent(root, rootPath, path);\n } catch (error) {\n root.release();\n throw error;\n }\n\n let quarantine: QuarantineDirectory;\n\n try {\n quarantine = createQuarantineDirectory(root, canonicalRoot);\n } catch (error) {\n parent.release();\n root.release();\n throw error;\n }\n\n const target = join(parent.path, basename(path));\n const captured = join(quarantine.path, \"previous\");\n let previous: string | null = null;\n\n try {\n previous = capturePath(target, captured) === \"captured\" ? captured : null;\n } catch (error) {\n try {\n recoverFailedCapture(quarantine, error);\n } finally {\n releasePreparationLeases(quarantine, parent, root);\n }\n }\n\n try {\n mkdirSync(target);\n } catch (error) {\n try {\n recoverUnsecuredPublicPath(target, quarantine, previous, error);\n } finally {\n releasePreparationLeases(quarantine, parent, root);\n }\n }\n\n return {\n target,\n publicPath: path,\n publicRoot: rootPath,\n publicParent: dirname(path),\n parent,\n quarantine,\n previous,\n root,\n };\n};\n\nconst prepareOutputDirectory = (\n rootPath: string,\n path: string,\n isReusable: DirectoryValidator,\n): PreparedOutputDirectory => {\n const resources = createPreparationResources(rootPath, path);\n const fresh = requireFreshDirectoryLease(resources);\n const transaction = createOutputDirectoryTransaction({ ...resources, fresh });\n\n try {\n if (resources.previous === null || isReusable(resources.previous)) {\n return { status: \"prepared\", transaction };\n }\n } catch (error) {\n rollbackAfterError(transaction, error);\n }\n\n transaction[Symbol.dispose]();\n\n return { status: \"unsafe\" };\n};\n\nexport {\n type OutputDirectoryTransaction,\n prepareOutputDirectory,\n readRegularFile,\n};\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type ProcessIdentity = {
|
|
2
|
+
pid: number;
|
|
3
|
+
parentId: number;
|
|
4
|
+
processGroupId: number;
|
|
5
|
+
startTime: string;
|
|
6
|
+
state: string;
|
|
7
|
+
};
|
|
8
|
+
type ProcessGroupOwner = Pick<ProcessIdentity, "pid" | "startTime">;
|
|
9
|
+
declare const initialParentId: number;
|
|
10
|
+
declare const getInitialProcessGroupOwner: () => ProcessGroupOwner | undefined;
|
|
11
|
+
export { getInitialProcessGroupOwner, initialParentId };
|
|
12
|
+
//# sourceMappingURL=parent-process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parent-process.d.ts","sourceRoot":"","sources":["../../src/internal/parent-process.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,iBAAiB,GAAG,IAAI,CAAC,eAAe,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC;AAIpE,QAAA,MAAM,eAAe,QAAe,CAAC;AAuFrC,QAAA,MAAM,2BAA2B,QAAO,iBAAiB,GAAG,SAM3D,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
const initialParentId = process.ppid;
|
|
3
|
+
const STOPPED_PROCESS_STATES = new Set(["Z", "X", "x"]);
|
|
4
|
+
const processIdentity = (pid) => {
|
|
5
|
+
const stat = readFileSync(`/proc/${String(pid)}/stat`, "utf8");
|
|
6
|
+
const fields = stat.slice(stat.lastIndexOf(") ") + 2).split(" ");
|
|
7
|
+
const state = fields[0];
|
|
8
|
+
const parentId = Number(fields[1]);
|
|
9
|
+
const processGroupId = Number(fields[2]);
|
|
10
|
+
const startTime = fields[19];
|
|
11
|
+
if (state === undefined ||
|
|
12
|
+
startTime === undefined ||
|
|
13
|
+
!Number.isSafeInteger(parentId) ||
|
|
14
|
+
!Number.isSafeInteger(processGroupId)) {
|
|
15
|
+
throw new Error(`Failed to identify process ${String(pid)}`);
|
|
16
|
+
}
|
|
17
|
+
return { pid, parentId, processGroupId, startTime, state };
|
|
18
|
+
};
|
|
19
|
+
const ancestorFor = (process, ancestorId) => {
|
|
20
|
+
let current = process;
|
|
21
|
+
while (current.parentId > 1) {
|
|
22
|
+
const parent = processIdentity(current.parentId);
|
|
23
|
+
if (parent.pid === ancestorId) {
|
|
24
|
+
return parent;
|
|
25
|
+
}
|
|
26
|
+
current = parent;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|
|
30
|
+
const processGroupOwner = (process) => {
|
|
31
|
+
if (process.processGroupId !== process.pid || STOPPED_PROCESS_STATES.has(process.state)) {
|
|
32
|
+
throw new Error(`Failed to identify process group ${String(process.pid)}`);
|
|
33
|
+
}
|
|
34
|
+
return { pid: process.pid, startTime: process.startTime };
|
|
35
|
+
};
|
|
36
|
+
const processGroupOwnerFor = (process) => {
|
|
37
|
+
if (process.processGroupId === process.pid) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const groupLeader = processGroupOwner(processIdentity(process.processGroupId));
|
|
41
|
+
const owner = ancestorFor(process, groupLeader.pid);
|
|
42
|
+
if (owner !== undefined) {
|
|
43
|
+
return groupLeader;
|
|
44
|
+
}
|
|
45
|
+
const currentGroupLeader = processGroupOwner(processIdentity(groupLeader.pid));
|
|
46
|
+
if (currentGroupLeader.startTime !== groupLeader.startTime) {
|
|
47
|
+
throw new Error(`Failed to identify process group ${String(groupLeader.pid)}`);
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
};
|
|
51
|
+
const captureProcessGroupOwner = () => {
|
|
52
|
+
try {
|
|
53
|
+
const initialProcess = processIdentity(process.pid);
|
|
54
|
+
if (initialProcess.parentId !== initialParentId) {
|
|
55
|
+
throw new Error("The process that launched GTKX exited during startup");
|
|
56
|
+
}
|
|
57
|
+
return { isCaptured: true, owner: processGroupOwnerFor(initialProcess) };
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
return {
|
|
61
|
+
isCaptured: false,
|
|
62
|
+
error: error instanceof Error ? error : new Error("Failed to identify the process that launched GTKX"),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const capturedProcessGroupOwner = captureProcessGroupOwner();
|
|
67
|
+
const getInitialProcessGroupOwner = () => {
|
|
68
|
+
if (!capturedProcessGroupOwner.isCaptured) {
|
|
69
|
+
throw capturedProcessGroupOwner.error;
|
|
70
|
+
}
|
|
71
|
+
return capturedProcessGroupOwner.owner;
|
|
72
|
+
};
|
|
73
|
+
export { getInitialProcessGroupOwner, initialParentId };
|
|
74
|
+
//# sourceMappingURL=parent-process.js.map
|