mochi/.forgejo/actions/update-flake-lock/dist/index.js.map
2024-08-16 17:05:46 -05:00

1 line
No EOL
4.9 KiB
Text

{"version":3,"sources":["../src/nix.ts","../src/index.ts"],"sourcesContent":["// Build the Nix args out of inputs from the Actions environment\nexport function makeNixCommandArgs(\n nixOptions: string[],\n flakeInputs: string[],\n commitMessage: string,\n): string[] {\n const flakeInputFlags = flakeInputs.flatMap((input) => [\n \"--update-input\",\n input,\n ]);\n\n // NOTE(cole-h): In Nix versions 2.23.0 and later, `commit-lockfile-summary` became an alias to\n // the setting `commit-lock-file-summary` (https://github.com/NixOS/nix/pull/10691), and Nix does\n // not treat aliases the same as their \"real\" setting by requiring setting aliases to be\n // configured via `--option <alias name> <option value>`\n // (https://github.com/NixOS/nix/issues/10989).\n // So, we go the long way so that we can support versions both before and after Nix 2.23.0.\n const lockfileSummaryFlags = [\n \"--option\",\n \"commit-lockfile-summary\",\n commitMessage,\n ];\n\n const updateLockMechanism = flakeInputFlags.length === 0 ? \"update\" : \"lock\";\n\n return nixOptions\n .concat([\"flake\", updateLockMechanism])\n .concat(flakeInputFlags)\n .concat([\"--commit-lock-file\"])\n .concat(lockfileSummaryFlags);\n}\n","import { makeNixCommandArgs } from \"./nix.js\";\nimport * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\nclass UpdateFlakeLockAction extends DetSysAction {\n private commitMessage: string;\n private nixOptions: string[];\n private flakeInputs: string[];\n private pathToFlakeDir: string | null;\n\n constructor() {\n super({\n name: \"update-flake-lock\",\n fetchStyle: \"universal\",\n requireNix: \"fail\",\n });\n\n this.commitMessage = inputs.getString(\"commit-msg\");\n this.flakeInputs = inputs.getArrayOfStrings(\"inputs\", \"space\");\n this.nixOptions = inputs.getArrayOfStrings(\"nix-options\", \"space\");\n this.pathToFlakeDir = inputs.getStringOrNull(\"path-to-flake-dir\");\n }\n\n async main(): Promise<void> {\n await this.update();\n }\n\n // No post phase\n async post(): Promise<void> {}\n\n async update(): Promise<void> {\n // Nix command of this form:\n // nix ${maybe nix options} flake ${\"update\" or \"lock\"} ${maybe --update-input flags} --commit-lock-file --commit-lockfile-summary ${commit message}\n // Example commands:\n // nix --extra-substituters https://example.com flake lock --update-input nixpkgs --commit-lock-file --commit-lockfile-summary \"updated flake.lock\"\n // nix flake update --commit-lock-file --commit-lockfile-summary \"updated flake.lock\"\n const nixCommandArgs: string[] = makeNixCommandArgs(\n this.nixOptions,\n this.flakeInputs,\n this.commitMessage,\n );\n\n actionsCore.debug(\n JSON.stringify({\n options: this.nixOptions,\n inputs: this.flakeInputs,\n message: this.commitMessage,\n args: nixCommandArgs,\n }),\n );\n\n const execOptions: actionsExec.ExecOptions = {\n cwd: this.pathToFlakeDir !== null ? this.pathToFlakeDir : undefined,\n };\n\n const exitCode = await actionsExec.exec(\"nix\", nixCommandArgs, execOptions);\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`flake.lock file was successfully updated`);\n }\n }\n}\n\nfunction main(): void {\n new UpdateFlakeLockAction().execute();\n}\n\nmain();\n"],"mappings":";AACO,SAAS,mBACd,YACA,aACA,eACU;AACV,QAAM,kBAAkB,YAAY,QAAQ,CAAC,UAAU;AAAA,IACrD;AAAA,IACA;AAAA,EACF,CAAC;AAQD,QAAM,uBAAuB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,sBAAsB,gBAAgB,WAAW,IAAI,WAAW;AAEtE,SAAO,WACJ,OAAO,CAAC,SAAS,mBAAmB,CAAC,EACrC,OAAO,eAAe,EACtB,OAAO,CAAC,oBAAoB,CAAC,EAC7B,OAAO,oBAAoB;AAChC;;;AC7BA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,SAAS,cAAc,cAA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