@form8ion/github-workflows-core 5.7.1 → 6.0.0-beta.1

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/lib/index.js CHANGED
@@ -1,7 +1,5 @@
1
- 'use strict';
2
-
3
- var core = require('@form8ion/core');
4
- var node_fs = require('node:fs');
1
+ import { fileExists, loadConfigFile, fileTypes, writeConfigFile, directoryExists } from '@form8ion/core';
2
+ import { promises } from 'node:fs';
5
3
 
6
4
  function setupNode({versionDeterminedBy}) {
7
5
  return {
@@ -33,26 +31,26 @@ function checkout() {
33
31
  }
34
32
 
35
33
  function existenceChecker ({projectRoot, name}) {
36
- return core.fileExists(`${projectRoot}/.github/workflows/${name}.yml`);
34
+ return fileExists(`${projectRoot}/.github/workflows/${name}.yml`);
37
35
  }
38
36
 
39
37
  function loader ({projectRoot, name}) {
40
- return core.loadConfigFile({path: `${projectRoot}/.github/workflows`, name, format: core.fileTypes.YAML});
38
+ return loadConfigFile({path: `${projectRoot}/.github/workflows`, name, format: fileTypes.YAML});
41
39
  }
42
40
 
43
41
  function writer ({projectRoot, name, config}) {
44
- return core.writeConfigFile({path: `${projectRoot}/.github/workflows`, name, config, format: core.fileTypes.YAML});
42
+ return writeConfigFile({path: `${projectRoot}/.github/workflows`, name, config, format: fileTypes.YAML});
45
43
  }
46
44
 
47
45
  function renamer ({projectRoot, oldName, newName}) {
48
- return node_fs.promises.rename(
46
+ return promises.rename(
49
47
  `${projectRoot}/.github/workflows/${oldName}.yml`,
50
48
  `${projectRoot}/.github/workflows/${newName}.yml`
51
49
  );
52
50
  }
53
51
 
54
52
  function tester ({projectRoot}) {
55
- return core.directoryExists(`${projectRoot}/.github/workflows`);
53
+ return directoryExists(`${projectRoot}/.github/workflows`);
56
54
  }
57
55
 
58
56
  function removeActionFromSteps(steps, actionName) {
@@ -65,20 +63,11 @@ function removeActionFromJobs(jobs, actionName) {
65
63
  jobName,
66
64
  {
67
65
  ...job,
68
- .../* job.steps && */{steps: removeActionFromSteps(job.steps, actionName)}
66
+ ...job.steps && {steps: removeActionFromSteps(job.steps, actionName)}
69
67
  }
70
68
  ]))
71
69
  );
72
70
  }
73
71
 
74
- exports.loadWorkflowFile = loader;
75
- exports.removeActionFromJobs = removeActionFromJobs;
76
- exports.renameWorkflowFile = renamer;
77
- exports.scaffoldCheckoutStep = checkout;
78
- exports.scaffoldDependencyInstallationStep = installDependencies;
79
- exports.scaffoldNodeSetupStep = setupNode;
80
- exports.scaffoldVerificationStep = executeVerification;
81
- exports.test = tester;
82
- exports.workflowFileExists = existenceChecker;
83
- exports.writeWorkflowFile = writer;
72
+ export { loader as loadWorkflowFile, removeActionFromJobs, renamer as renameWorkflowFile, checkout as scaffoldCheckoutStep, installDependencies as scaffoldDependencyInstallationStep, setupNode as scaffoldNodeSetupStep, executeVerification as scaffoldVerificationStep, tester as test, existenceChecker as workflowFileExists, writer as writeWorkflowFile };
84
73
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/steps/scaffolders.js","../src/workflow-file/existence-checker.js","../src/workflow-file/loader.js","../src/workflow-file/writer.js","../src/workflow-file/renamer.js","../src/tester.js","../src/steps/remover.js","../src/jobs/remover.js"],"sourcesContent":["export function setupNode({versionDeterminedBy}) {\n return {\n name: 'Setup node',\n uses: 'actions/setup-node@v6.1.0',\n with: {\n ...'nvmrc' === versionDeterminedBy && {'node-version-file': '.nvmrc'},\n // eslint-disable-next-line no-template-curly-in-string\n ...'matrix' === versionDeterminedBy && {'node-version': '${{ matrix.node }}'},\n cache: 'npm'\n }\n };\n}\n\nexport function executeVerification() {\n return {run: 'npm test'};\n}\n\nexport function installDependencies() {\n return [\n {run: 'npm clean-install'},\n {run: 'npm install --global corepack@latest'},\n {run: 'corepack npm audit signatures'}\n ];\n}\n\nexport function checkout() {\n return {uses: 'actions/checkout@v6.0.1'};\n}\n","import {fileExists} from '@form8ion/core';\n\nexport default function ({projectRoot, name}) {\n return fileExists(`${projectRoot}/.github/workflows/${name}.yml`);\n}\n","import {fileTypes, loadConfigFile} from '@form8ion/core';\n\nexport default function ({projectRoot, name}) {\n return loadConfigFile({path: `${projectRoot}/.github/workflows`, name, format: fileTypes.YAML});\n}\n","import {fileTypes, writeConfigFile} from '@form8ion/core';\n\nexport default function ({projectRoot, name, config}) {\n return writeConfigFile({path: `${projectRoot}/.github/workflows`, name, config, format: fileTypes.YAML});\n}\n","import {promises as fs} from 'node:fs';\n\nexport default function ({projectRoot, oldName, newName}) {\n return fs.rename(\n `${projectRoot}/.github/workflows/${oldName}.yml`,\n `${projectRoot}/.github/workflows/${newName}.yml`\n );\n}\n","import {directoryExists} from '@form8ion/core';\n\nexport default function ({projectRoot}) {\n return directoryExists(`${projectRoot}/.github/workflows`);\n}\n","export function removeActionFromSteps(steps, actionName) {\n return steps.filter(step => !step.uses?.includes(actionName));\n}\n","import {removeActionFromSteps} from '../steps/remover.js';\n\nexport function removeActionFromJobs(jobs, actionName) {\n return Object.fromEntries(\n Object.entries(jobs).map(([jobName, job]) => ([\n jobName,\n {\n ...job,\n .../* job.steps && */{steps: removeActionFromSteps(job.steps, actionName)}\n }\n ]))\n );\n}\n"],"names":["fileExists","loadConfigFile","fileTypes","writeConfigFile","fs","directoryExists"],"mappings":";;;;;AAAO,SAAS,SAAS,CAAC,CAAC,mBAAmB,CAAC,EAAE;AACjD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,YAAY;AACtB,IAAI,IAAI,EAAE,2BAA2B;AACrC,IAAI,IAAI,EAAE;AACV,MAAM,GAAG,OAAO,KAAK,mBAAmB,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC;AAC3E;AACA,MAAM,GAAG,QAAQ,KAAK,mBAAmB,IAAI,CAAC,cAAc,EAAE,oBAAoB,CAAC;AACnF,MAAM,KAAK,EAAE;AACb;AACA,GAAG;AACH;;AAEO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO,CAAC,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EAAE;AACxC,EAAE,OAAOC,oBAAe,CAAC,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;AAC5D;;ACJO,SAAS,qBAAqB,CAAC,KAAK,EAAE,UAAU,EAAE;AACzD,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC/D;;ACAO,SAAS,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE;AACvD,EAAE,OAAO,MAAM,CAAC,WAAW;AAC3B,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM;AAClD,MAAM,OAAO;AACb,MAAM;AACN,QAAQ,GAAG,GAAG;AACd,QAAQ,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC;AAClF;AACA,KAAK,CAAC;AACN,GAAG;AACH;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/steps/scaffolders.js","../src/workflow-file/existence-checker.js","../src/workflow-file/loader.js","../src/workflow-file/writer.js","../src/workflow-file/renamer.js","../src/tester.js","../src/steps/remover.js","../src/jobs/remover.js"],"sourcesContent":["export function setupNode({versionDeterminedBy}) {\n return {\n name: 'Setup node',\n uses: 'actions/setup-node@v6.1.0',\n with: {\n ...'nvmrc' === versionDeterminedBy && {'node-version-file': '.nvmrc'},\n // eslint-disable-next-line no-template-curly-in-string\n ...'matrix' === versionDeterminedBy && {'node-version': '${{ matrix.node }}'},\n cache: 'npm'\n }\n };\n}\n\nexport function executeVerification() {\n return {run: 'npm test'};\n}\n\nexport function installDependencies() {\n return [\n {run: 'npm clean-install'},\n {run: 'npm install --global corepack@latest'},\n {run: 'corepack npm audit signatures'}\n ];\n}\n\nexport function checkout() {\n return {uses: 'actions/checkout@v6.0.1'};\n}\n","import {fileExists} from '@form8ion/core';\n\nexport default function ({projectRoot, name}) {\n return fileExists(`${projectRoot}/.github/workflows/${name}.yml`);\n}\n","import {fileTypes, loadConfigFile} from '@form8ion/core';\n\nexport default function ({projectRoot, name}) {\n return loadConfigFile({path: `${projectRoot}/.github/workflows`, name, format: fileTypes.YAML});\n}\n","import {fileTypes, writeConfigFile} from '@form8ion/core';\n\nexport default function ({projectRoot, name, config}) {\n return writeConfigFile({path: `${projectRoot}/.github/workflows`, name, config, format: fileTypes.YAML});\n}\n","import {promises as fs} from 'node:fs';\n\nexport default function ({projectRoot, oldName, newName}) {\n return fs.rename(\n `${projectRoot}/.github/workflows/${oldName}.yml`,\n `${projectRoot}/.github/workflows/${newName}.yml`\n );\n}\n","import {directoryExists} from '@form8ion/core';\n\nexport default function ({projectRoot}) {\n return directoryExists(`${projectRoot}/.github/workflows`);\n}\n","export function removeActionFromSteps(steps, actionName) {\n return steps.filter(step => !step.uses?.includes(actionName));\n}\n","import {removeActionFromSteps} from '../steps/remover.js';\n\nexport function removeActionFromJobs(jobs, actionName) {\n return Object.fromEntries(\n Object.entries(jobs).map(([jobName, job]) => ([\n jobName,\n {\n ...job,\n ...job.steps && {steps: removeActionFromSteps(job.steps, actionName)}\n }\n ]))\n );\n}\n"],"names":["fs"],"mappings":";;;AAAO,SAAS,SAAS,CAAC,CAAC,mBAAmB,CAAC,EAAE;AACjD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,YAAY;AACtB,IAAI,IAAI,EAAE,2BAA2B;AACrC,IAAI,IAAI,EAAE;AACV,MAAM,GAAG,OAAO,KAAK,mBAAmB,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC;AAC3E;AACA,MAAM,GAAG,QAAQ,KAAK,mBAAmB,IAAI,CAAC,cAAc,EAAE,oBAAoB,CAAC;AACnF,MAAM,KAAK,EAAE;AACb;AACA,GAAG;AACH;;AAEO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CA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,CAAC,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC;AAC5D;;ACJO,SAAS,qBAAqB,CAAC,KAAK,EAAE,UAAU,EAAE;AACzD,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC/D;;ACAO,SAAS,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE;AACvD,EAAE,OAAO,MAAM,CAAC,WAAW;AAC3B,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM;AAClD,MAAM,OAAO;AACb,MAAM;AACN,QAAQ,GAAG,GAAG;AACd,QAAQ,GAAG,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC;AAC5E;AACA,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "name": "@form8ion/github-workflows-core",
3
3
  "description": "core functionality for form8ion plugins that manage github workflows",
4
4
  "license": "MIT",
5
- "version": "5.7.1",
6
- "type": "commonjs",
5
+ "version": "6.0.0-beta.1",
6
+ "type": "module",
7
7
  "engines": {
8
8
  "node": "^18.17 || >=20.6.1"
9
9
  },
@@ -12,12 +12,8 @@
12
12
  "bugs": "https://github.com/form8ion/github-workflows-core/issues",
13
13
  "homepage": "https://npm.im/@form8ion/github-workflows-core",
14
14
  "runkitExampleFilename": "./example.js",
15
- "exports": {
16
- "require": "./lib/index.js",
17
- "import": "./lib/index.mjs"
18
- },
15
+ "exports": "./lib/index.js",
19
16
  "main": "lib/index.js",
20
- "module": "lib/index.mjs",
21
17
  "sideEffects": false,
22
18
  "scripts": {
23
19
  "pretest": "run-s build",
@@ -25,7 +21,7 @@
25
21
  "pretest:integration:base": "run-s build",
26
22
  "lint:gherkin": "gherkin-lint",
27
23
  "test:integration": "run-s 'test:integration:base -- --profile noWip'",
28
- "test:integration:base": "NODE_OPTIONS=--enable-source-maps DEBUG=any cucumber-js test/integration --profile base",
24
+ "test:integration:base": "NODE_OPTIONS=--enable-source-maps DEBUG=any cucumber-js test/integration",
29
25
  "test:integration:debug": "DEBUG=test run-s test:integration",
30
26
  "test:integration:wip": "run-s 'test:integration:base -- --profile wip'",
31
27
  "test:integration:wip:debug": "DEBUG=test run-s 'test:integration:wip'",
@@ -64,16 +60,13 @@
64
60
  "@form8ion/core": "^4.7.1"
65
61
  },
66
62
  "devDependencies": {
67
- "@babel/register": "7.28.3",
68
63
  "@cucumber/cucumber": "11.3.0",
69
- "@form8ion/babel-preset": "1.6.150",
70
64
  "@form8ion/commitlint-config": "2.0.8",
71
65
  "@form8ion/eslint-config": "7.0.13",
72
66
  "@form8ion/eslint-config-cucumber": "1.4.1",
73
67
  "@form8ion/eslint-config-mocha": "3.0.6",
74
68
  "@form8ion/eslint-config-vitest": "1.0.0",
75
69
  "@form8ion/remark-lint-preset": "6.0.7",
76
- "@rollup/plugin-babel": "6.1.0",
77
70
  "@travi/any": "3.1.3",
78
71
  "ban-sensitive-files": "1.10.11",
79
72
  "c8": "10.1.3",
@@ -6,7 +6,7 @@ export function removeActionFromJobs(jobs, actionName) {
6
6
  jobName,
7
7
  {
8
8
  ...job,
9
- .../* job.steps && */{steps: removeActionFromSteps(job.steps, actionName)}
9
+ ...job.steps && {steps: removeActionFromSteps(job.steps, actionName)}
10
10
  }
11
11
  ]))
12
12
  );
@@ -1,4 +1,4 @@
1
- import {describe, it, expect, vi} from 'vitest';
1
+ import {describe, it, expect, vi, beforeEach} from 'vitest';
2
2
  import {when} from 'vitest-when';
3
3
  import any from '@travi/any';
4
4
  import zip from 'lodash.zip';
@@ -9,18 +9,33 @@ import {removeActionFromJobs} from './remover.js';
9
9
  vi.mock('../steps/remover.js');
10
10
 
11
11
  describe('jobs-level remover', () => {
12
+ const actionName = any.word();
12
13
  const anySteps = () => any.listOf(any.simpleObject);
14
+ const jobNames = any.listOf(any.word);
15
+ const jobs = jobNames.map(() => ({...any.simpleObject(), steps: anySteps()}));
16
+ const updatedJobs = jobs.map(job => ({...job, steps: anySteps()}));
13
17
 
14
- it('should remove an action by name from an indexed list of jobs', async () => {
15
- const actionName = any.word();
16
- const jobNames = any.listOf(any.word);
17
- const jobs = jobNames.map(() => ({...any.simpleObject(), steps: anySteps()}));
18
- const updatedJobs = jobs.map(job => ({...job, steps: anySteps()}));
18
+ beforeEach(() => {
19
19
  zip(jobs, updatedJobs).forEach(([job, updatedJob]) => {
20
20
  when(removeActionFromSteps).calledWith(job.steps, actionName).thenReturn(updatedJob.steps);
21
21
  });
22
+ when(removeActionFromSteps).calledWith(undefined, actionName).thenThrow(new Error());
23
+ });
22
24
 
25
+ it('should remove an action by name from an indexed list of jobs', async () => {
23
26
  expect(removeActionFromJobs(Object.fromEntries(zip(jobNames, jobs)), actionName))
24
27
  .toEqual(Object.fromEntries(zip(jobNames, updatedJobs)));
25
28
  });
29
+
30
+ it('should not process `steps` for jobs defined as reusable workflows', async () => {
31
+ const reusableWorkflowJobName = 'reusable-workflow';
32
+ const reusableWorkflowJobDefinition = any.simpleObject();
33
+
34
+ expect(removeActionFromJobs(
35
+ Object.fromEntries(zip([...jobNames, reusableWorkflowJobName], [...jobs, reusableWorkflowJobDefinition])),
36
+ actionName
37
+ )).toEqual(
38
+ Object.fromEntries(zip([...jobNames, reusableWorkflowJobName], [...updatedJobs, reusableWorkflowJobDefinition]))
39
+ );
40
+ });
26
41
  });
package/lib/index.mjs DELETED
@@ -1,73 +0,0 @@
1
- import { fileExists, loadConfigFile, fileTypes, writeConfigFile, directoryExists } from '@form8ion/core';
2
- import { promises } from 'node:fs';
3
-
4
- function setupNode({versionDeterminedBy}) {
5
- return {
6
- name: 'Setup node',
7
- uses: 'actions/setup-node@v6.1.0',
8
- with: {
9
- ...'nvmrc' === versionDeterminedBy && {'node-version-file': '.nvmrc'},
10
- // eslint-disable-next-line no-template-curly-in-string
11
- ...'matrix' === versionDeterminedBy && {'node-version': '${{ matrix.node }}'},
12
- cache: 'npm'
13
- }
14
- };
15
- }
16
-
17
- function executeVerification() {
18
- return {run: 'npm test'};
19
- }
20
-
21
- function installDependencies() {
22
- return [
23
- {run: 'npm clean-install'},
24
- {run: 'npm install --global corepack@latest'},
25
- {run: 'corepack npm audit signatures'}
26
- ];
27
- }
28
-
29
- function checkout() {
30
- return {uses: 'actions/checkout@v6.0.1'};
31
- }
32
-
33
- function existenceChecker ({projectRoot, name}) {
34
- return fileExists(`${projectRoot}/.github/workflows/${name}.yml`);
35
- }
36
-
37
- function loader ({projectRoot, name}) {
38
- return loadConfigFile({path: `${projectRoot}/.github/workflows`, name, format: fileTypes.YAML});
39
- }
40
-
41
- function writer ({projectRoot, name, config}) {
42
- return writeConfigFile({path: `${projectRoot}/.github/workflows`, name, config, format: fileTypes.YAML});
43
- }
44
-
45
- function renamer ({projectRoot, oldName, newName}) {
46
- return promises.rename(
47
- `${projectRoot}/.github/workflows/${oldName}.yml`,
48
- `${projectRoot}/.github/workflows/${newName}.yml`
49
- );
50
- }
51
-
52
- function tester ({projectRoot}) {
53
- return directoryExists(`${projectRoot}/.github/workflows`);
54
- }
55
-
56
- function removeActionFromSteps(steps, actionName) {
57
- return steps.filter(step => !step.uses?.includes(actionName));
58
- }
59
-
60
- function removeActionFromJobs(jobs, actionName) {
61
- return Object.fromEntries(
62
- Object.entries(jobs).map(([jobName, job]) => ([
63
- jobName,
64
- {
65
- ...job,
66
- .../* job.steps && */{steps: removeActionFromSteps(job.steps, actionName)}
67
- }
68
- ]))
69
- );
70
- }
71
-
72
- export { loader as loadWorkflowFile, removeActionFromJobs, renamer as renameWorkflowFile, checkout as scaffoldCheckoutStep, installDependencies as scaffoldDependencyInstallationStep, setupNode as scaffoldNodeSetupStep, executeVerification as scaffoldVerificationStep, tester as test, existenceChecker as workflowFileExists, writer as writeWorkflowFile };
73
- //# sourceMappingURL=index.mjs.map
package/lib/index.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/steps/scaffolders.js","../src/workflow-file/existence-checker.js","../src/workflow-file/loader.js","../src/workflow-file/writer.js","../src/workflow-file/renamer.js","../src/tester.js","../src/steps/remover.js","../src/jobs/remover.js"],"sourcesContent":["export function setupNode({versionDeterminedBy}) {\n return {\n name: 'Setup node',\n uses: 'actions/setup-node@v6.1.0',\n with: {\n ...'nvmrc' === versionDeterminedBy && {'node-version-file': '.nvmrc'},\n // eslint-disable-next-line no-template-curly-in-string\n ...'matrix' === versionDeterminedBy && {'node-version': '${{ matrix.node }}'},\n cache: 'npm'\n }\n };\n}\n\nexport function executeVerification() {\n return {run: 'npm test'};\n}\n\nexport function installDependencies() {\n return [\n {run: 'npm clean-install'},\n {run: 'npm install --global corepack@latest'},\n {run: 'corepack npm audit signatures'}\n ];\n}\n\nexport function checkout() {\n return {uses: 'actions/checkout@v6.0.1'};\n}\n","import {fileExists} from '@form8ion/core';\n\nexport default function ({projectRoot, name}) {\n return fileExists(`${projectRoot}/.github/workflows/${name}.yml`);\n}\n","import {fileTypes, loadConfigFile} from '@form8ion/core';\n\nexport default function ({projectRoot, name}) {\n return loadConfigFile({path: `${projectRoot}/.github/workflows`, name, format: fileTypes.YAML});\n}\n","import {fileTypes, writeConfigFile} from '@form8ion/core';\n\nexport default function ({projectRoot, name, config}) {\n return writeConfigFile({path: `${projectRoot}/.github/workflows`, name, config, format: fileTypes.YAML});\n}\n","import {promises as fs} from 'node:fs';\n\nexport default function ({projectRoot, oldName, newName}) {\n return fs.rename(\n `${projectRoot}/.github/workflows/${oldName}.yml`,\n `${projectRoot}/.github/workflows/${newName}.yml`\n );\n}\n","import {directoryExists} from '@form8ion/core';\n\nexport default function ({projectRoot}) {\n return directoryExists(`${projectRoot}/.github/workflows`);\n}\n","export function removeActionFromSteps(steps, actionName) {\n return steps.filter(step => !step.uses?.includes(actionName));\n}\n","import {removeActionFromSteps} from '../steps/remover.js';\n\nexport function removeActionFromJobs(jobs, actionName) {\n return Object.fromEntries(\n Object.entries(jobs).map(([jobName, job]) => ([\n jobName,\n {\n ...job,\n .../* job.steps && */{steps: removeActionFromSteps(job.steps, actionName)}\n }\n ]))\n );\n}\n"],"names":["fs"],"mappings":";;;AAAO,SAAS,SAAS,CAAC,CAAC,mBAAmB,CAAC,EAAE;AACjD,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,YAAY;AACtB,IAAI,IAAI,EAAE,2BAA2B;AACrC,IAAI,IAAI,EAAE;AACV,MAAM,GAAG,OAAO,KAAK,mBAAmB,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC;AAC3E;AACA,MAAM,GAAG,QAAQ,KAAK,mBAAmB,IAAI,CAAC,cAAc,EAAE,oBAAoB,CAAC;AACnF,MAAM,KAAK,EAAE;AACb;AACA,GAAG;AACH;;AAEO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC;AAC1B;;AAEO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO;AACT,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC;AAC9B,IAAI,CAAC,GAAG,EAAE,sCAAsC,CAAC;AACjD,IAAI,CAAC,GAAG,EAAE,+BAA+B;AACzC,GAAG;AACH;;AAEO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,IAAI,EAAE,yBAAyB,CAAC;AAC1C;;ACzBe,yBAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE;AAC9C,EAAE,OAAO,UAAU,CAAC,CAAC,EAAE,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AACnE;;ACFe,eAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE;AAC9C,EAAE,OAAO,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,EA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