@@ -19,6 +19,7 @@ import * as Sink from "effect/Sink";
1919import * as Schema from "effect/Schema" ;
2020import * as Stream from "effect/Stream" ;
2121import { ChildProcess , ChildProcessSpawner } from "effect/process" ;
22+ import { fromYaml } from "@t3tools/shared/schemaYaml" ;
2223
2324import {
2425 buildDesktopBundles ,
@@ -1430,6 +1431,57 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
14301431 ) ,
14311432 ) ;
14321433
1434+ it . effect ( "never runs an untrusted macOS bundle" , ( ) =>
1435+ Effect . scoped (
1436+ Effect . gen ( function * ( ) {
1437+ const fs = yield * FileSystem . FileSystem ;
1438+ const path = yield * Path . Path ;
1439+ const marker = path . join ( yield * fs . makeTempDirectoryScoped ( ) , "ran" ) ;
1440+ const fixture = yield * makePackagedAppFixture ( {
1441+ serverEntrySource : `import { writeFileSync } from "node:fs";\nwriteFileSync(${ JSON . stringify ( marker ) } , "");\n` ,
1442+ } ) ;
1443+ yield * validateMacPackagedPayload ( { stageDistDir : fixture . stageDistDir } ) ;
1444+ assert . isFalse ( yield * fs . exists ( marker ) ) ;
1445+ } ) ,
1446+ ) . pipe (
1447+ Effect . provide (
1448+ ConfigProvider . layer (
1449+ ConfigProvider . fromEnv ( { env : { T3CODE_DESKTOP_UNTRUSTED_BUNDLE : "true" } } ) ,
1450+ ) ,
1451+ ) ,
1452+ ) ,
1453+ ) ;
1454+
1455+ it . effect ( "packages the macOS preview's PR bundle as untrusted" , ( ) =>
1456+ Effect . gen ( function * ( ) {
1457+ const fs = yield * FileSystem . FileSystem ;
1458+ const path = yield * Path . Path ;
1459+ const workflow = yield * fs . readFileString (
1460+ yield * path . fromFileUrl (
1461+ new URL ( "../.github/workflows/desktop-macos-preview-publish.yml" , import . meta. url ) ,
1462+ ) ,
1463+ ) ;
1464+ const { jobs } = yield * Schema . decodeEffect (
1465+ fromYaml (
1466+ Schema . Struct ( {
1467+ jobs : Schema . Record (
1468+ Schema . String ,
1469+ Schema . Struct ( {
1470+ uses : Schema . optional ( Schema . String ) ,
1471+ with : Schema . optional ( Schema . Record ( Schema . String , Schema . Unknown ) ) ,
1472+ } ) ,
1473+ ) ,
1474+ } ) ,
1475+ ) ,
1476+ ) ( workflow ) ;
1477+ const packaging = Object . values ( jobs ) . filter (
1478+ ( job ) => job . uses === "./.github/workflows/release-desktop.yml" ,
1479+ ) ;
1480+ assert . isNotEmpty ( packaging ) ;
1481+ for ( const job of packaging ) assert . strictEqual ( job . with ?. untrusted_bundle , true ) ;
1482+ } ) ,
1483+ ) ;
1484+
14331485 it . effect ( "rejects a macOS stage without a packaged app" , ( ) =>
14341486 Effect . scoped (
14351487 Effect . gen ( function * ( ) {
0 commit comments