update-flake-lock/dist/index.js.map

1 line
4.1 KiB
Text
Raw Normal View History

2024-04-26 16:55:19 +02:00
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { ActionOptions, IdsToolbox, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\nclass UpdateFlakeLockAction {\n idslib: IdsToolbox;\n private nixOptions: string;\n private targets: string[];\n private commitMessage: string;\n private pathToFlakeDir: string | null;\n\n constructor() {\n const options: ActionOptions = {\n name: \"update-flake-lock\",\n fetchStyle: \"universal\",\n requireNix: \"fail\",\n };\n\n this.idslib = new IdsToolbox(options);\n\n this.nixOptions = inputs.getString(\"nix-options\");\n this.targets = inputs.getString(\"inputs\").split(\" \");\n this.commitMessage = inputs.getString(\"commit-msg\");\n this.pathToFlakeDir = inputs.getStringOrNull(\"path-to-flake-dir\");\n }\n\n async update(): Promise<void> {\n const nixOptions: string[] = this.nixOptions.split(\",\");\n const inputFlags: string[] =\n this.targets.length > 0\n ? this.targets.map((input) => `--update-input ${input}`)\n : [];\n\n if (this.pathToFlakeDir !== null) {\n const returnCode = await actionsExec.exec(\"cd\", [this.pathToFlakeDir]);\n if (returnCode !== 0) {\n this.idslib.recordEvent(EVENT_EXECUTION_FAILURE, {\n returnCode,\n });\n actionsCore.setFailed(\n `Error when trying to cd into flake directory ${this.pathToFlakeDir}. Make sure the check that the directory exists.`,\n );\n }\n }\n\n // Nix command of this form:\n // nix ${nix options} flake lock ${input flags} --commit-lock-file --commit-lock-file-summary ${commit message}\n // Example command:\n // nix --extra-substituters https://example.com flake lock --update-input nixpkgs --commit-lock-file --commit-lock-file-summary\n const nixCommandArgs: string[] = nixOptions\n .concat([\"flake\", \"lock\"])\n .concat(inputFlags.length > 0 ? inputFlags : [])\n .concat([\n \"--commit-lock-file\",\n \"--commit-lock-file-summary\",\n this.commitMessage,\n ]);\n\n actionsCore.debug(`running nix command:\\nnix ${nixCommandArgs.join(\" \")}`);\n\n const exitCode = await actionsExec.exec(\"nix\", nixCommandArgs);\n\n if (exitCode !== 0) {\n this.idslib.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 const updateFlakeLock = new UpdateFlakeLockAction();\n\n updateFlakeLock.idslib.onMain(async () => {\n await updateFlakeLock.update();\n });\n\n updateFlakeLock.idslib.execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,SAAwB,YAAY,cAAc;AAElD,IAAM,0BAA0B;AAEhC,IAAM,wBAAN,MAA4B;AAAA,EAO1B,cAAc;AACZ,UAAM,UAAyB;AAAA,MAC7B,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,YAAY;AAAA,IACd;AAEA,SAAK,SAAS,IAAI,WAAW,OAAO;AAEpC,SAAK,aAAa,OAAO,UAAU,aAAa;AAChD,SAAK,UAAU,OAAO,UAAU,QAAQ,EAAE,MAAM,GAAG;AACnD,SAAK,gBAAgB,OAAO,UAAU,YAAY;AAClD,SAAK,iBAAiB,OAAO,gBAAgB,mBAAmB;AAAA,EAClE;AAAA,EAEA,MAAM,SAAwB;AAC5B,UAAM,aAAuB,KAAK,WAAW,MAAM,GAAG;AACtD,UAAM,aACJ,KAAK,QAAQ,SAAS,IAClB,KAAK,QAAQ,IAAI,CAAC,UAAU,kBAAkB,KAAK,EAAE,IACrD,CAAC;AAEP,QAAI,KAAK,mBAAmB,MAAM;AAChC,YAAM,aAAa,MAAkB,iBAAK,MAAM,CAAC,KAAK,cAAc,CAAC;AACrE,UAAI,eAAe,GAAG;AACpB,aAAK,OAAO,YAAY,yBAAyB;AAAA,UAC/C;AAAA,QACF,CAAC;AACD,QAAY;AAAA,UACV,gDAAgD,KAAK,cAAc;AAAA,QACrE;AAA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