@form8ion/github-workflows-core 5.1.0 → 5.3.0

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 CHANGED
@@ -54,13 +54,17 @@ import {
54
54
  scaffoldNodeSetupStep,
55
55
  scaffoldDependencyInstallationStep,
56
56
  scaffoldVerificationStep,
57
- writeWorkflowFile
57
+ loadWorkflowFile,
58
+ writeWorkflowFile,
59
+ workflowFileExists
58
60
  } from '@form8ion/github-workflows-core';
59
61
  ```
60
62
 
61
63
  #### Execute
62
64
 
63
65
  ```javascript
66
+ const projectRoot = process.cwd();
67
+
64
68
  (async () => {
65
69
  scaffoldCheckoutStep();
66
70
 
@@ -70,7 +74,11 @@ import {
70
74
 
71
75
  scaffoldVerificationStep();
72
76
 
73
- await writeWorkflowFile({projectRoot: process.cwd(), name: 'workflow-name', config: {}});
77
+ if (await workflowFileExists({projectRoot, name: 'existing-workflow-name'})) {
78
+ await loadWorkflowFile({projectRoot, name: 'existing-workflow-name'});
79
+ }
80
+
81
+ await writeWorkflowFile({projectRoot, name: 'workflow-name', config: {}});
74
82
  })();
75
83
  ```
76
84
 
package/example.js CHANGED
@@ -6,14 +6,21 @@ import {
6
6
  scaffoldNodeSetupStep,
7
7
  scaffoldDependencyInstallationStep,
8
8
  scaffoldVerificationStep,
9
- writeWorkflowFile
9
+ loadWorkflowFile,
10
+ writeWorkflowFile,
11
+ workflowFileExists
10
12
  } from './lib/index.js';
11
13
 
12
- // remark-usage-ignore-next
13
- stubbedFs({node_modules: stubbedFs.load('node_modules'), '.github': {workflows: {}}});
14
+ // remark-usage-ignore-next 4
15
+ stubbedFs({
16
+ node_modules: stubbedFs.load('node_modules'),
17
+ '.github': {workflows: {'existing-workflow-name.yml': 'foo: bar'}}
18
+ });
14
19
 
15
20
  // #### Execute
16
21
 
22
+ const projectRoot = process.cwd();
23
+
17
24
  (async () => {
18
25
  scaffoldCheckoutStep();
19
26
 
@@ -23,5 +30,9 @@ stubbedFs({node_modules: stubbedFs.load('node_modules'), '.github': {workflows:
23
30
 
24
31
  scaffoldVerificationStep();
25
32
 
26
- await writeWorkflowFile({projectRoot: process.cwd(), name: 'workflow-name', config: {}});
33
+ if (await workflowFileExists({projectRoot, name: 'existing-workflow-name'})) {
34
+ await loadWorkflowFile({projectRoot, name: 'existing-workflow-name'});
35
+ }
36
+
37
+ await writeWorkflowFile({projectRoot, name: 'workflow-name', config: {}});
27
38
  })();
package/lib/index.js CHANGED
@@ -30,13 +30,23 @@ function checkout() {
30
30
  return {uses: 'actions/checkout@v4.1.7'};
31
31
  }
32
32
 
33
- function write ({projectRoot, name, config}) {
33
+ function existenceChecker ({projectRoot, name}) {
34
+ return core.fileExists(`${projectRoot}/.github/workflows/${name}.yml`);
35
+ }
36
+
37
+ function loader ({projectRoot, name}) {
38
+ return core.loadConfigFile({path: `${projectRoot}/.github/workflows`, name, format: core.fileTypes.YAML});
39
+ }
40
+
41
+ function writer ({projectRoot, name, config}) {
34
42
  return core.writeConfigFile({path: `${projectRoot}/.github/workflows`, name, config, format: core.fileTypes.YAML});
35
43
  }
36
44
 
45
+ exports.loadWorkflowFile = loader;
37
46
  exports.scaffoldCheckoutStep = checkout;
38
47
  exports.scaffoldDependencyInstallationStep = installDependencies;
39
48
  exports.scaffoldNodeSetupStep = setupNode;
40
49
  exports.scaffoldVerificationStep = executeVerification;
41
- exports.writeWorkflowFile = write;
50
+ exports.workflowFileExists = existenceChecker;
51
+ exports.writeWorkflowFile = writer;
42
52
  //# 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/write.js"],"sourcesContent":["export function setupNode({versionDeterminedBy}) {\n return {\n name: 'Setup node',\n uses: 'actions/setup-node@v4.0.3',\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: 'corepack npm audit signatures'}\n ];\n}\n\nexport function checkout() {\n return {uses: 'actions/checkout@v4.1.7'};\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"],"names":["writeConfigFile","fileTypes"],"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,KAAK;AAClB,KAAK;AACL,GAAG,CAAC;AACJ,CAAC;AACD;AACO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC3B,CAAC;AACD;AACO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO;AACT,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC;AAC9B,IAAI,CAAC,GAAG,EAAE,+BAA+B,CAAC;AAC1C,GAAG,CAAC;AACJ,CAAC;AACD;AACO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;AAC3C;;ACxBe,cAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;AACtD,EAAE,OAAOA,oBAAe,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAEC,cAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3G;;;;;;;;"}
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"],"sourcesContent":["export function setupNode({versionDeterminedBy}) {\n return {\n name: 'Setup node',\n uses: 'actions/setup-node@v4.0.3',\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: 'corepack npm audit signatures'}\n ];\n}\n\nexport function checkout() {\n return {uses: 'actions/checkout@v4.1.7'};\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"],"names":["fileExists","loadConfigFile","fileTypes","writeConfigFile"],"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;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1
+ import { fileExists, loadConfigFile, fileTypes, writeConfigFile } from '@form8ion/core';
2
2
 
3
3
  function setupNode({versionDeterminedBy}) {
4
4
  return {
@@ -28,9 +28,17 @@ function checkout() {
28
28
  return {uses: 'actions/checkout@v4.1.7'};
29
29
  }
30
30
 
31
- function write ({projectRoot, name, config}) {
31
+ function existenceChecker ({projectRoot, name}) {
32
+ return fileExists(`${projectRoot}/.github/workflows/${name}.yml`);
33
+ }
34
+
35
+ function loader ({projectRoot, name}) {
36
+ return loadConfigFile({path: `${projectRoot}/.github/workflows`, name, format: fileTypes.YAML});
37
+ }
38
+
39
+ function writer ({projectRoot, name, config}) {
32
40
  return writeConfigFile({path: `${projectRoot}/.github/workflows`, name, config, format: fileTypes.YAML});
33
41
  }
34
42
 
35
- export { checkout as scaffoldCheckoutStep, installDependencies as scaffoldDependencyInstallationStep, setupNode as scaffoldNodeSetupStep, executeVerification as scaffoldVerificationStep, write as writeWorkflowFile };
43
+ export { loader as loadWorkflowFile, checkout as scaffoldCheckoutStep, installDependencies as scaffoldDependencyInstallationStep, setupNode as scaffoldNodeSetupStep, executeVerification as scaffoldVerificationStep, existenceChecker as workflowFileExists, writer as writeWorkflowFile };
36
44
  //# sourceMappingURL=index.mjs.map
package/lib/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/steps/scaffolders.js","../src/workflow-file/write.js"],"sourcesContent":["export function setupNode({versionDeterminedBy}) {\n return {\n name: 'Setup node',\n uses: 'actions/setup-node@v4.0.3',\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: 'corepack npm audit signatures'}\n ];\n}\n\nexport function checkout() {\n return {uses: 'actions/checkout@v4.1.7'};\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"],"names":[],"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,KAAK;AAClB,KAAK;AACL,GAAG,CAAC;AACJ,CAAC;AACD;AACO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC3B,CAAC;AACD;AACO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO;AACT,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC;AAC9B,IAAI,CAAC,GAAG,EAAE,+BAA+B,CAAC;AAC1C,GAAG,CAAC;AACJ,CAAC;AACD;AACO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;AAC3C;;ACxBe,cAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;AACtD,EAAE,OAAO,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3G;;;;"}
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"],"sourcesContent":["export function setupNode({versionDeterminedBy}) {\n return {\n name: 'Setup node',\n uses: 'actions/setup-node@v4.0.3',\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: 'corepack npm audit signatures'}\n ];\n}\n\nexport function checkout() {\n return {uses: 'actions/checkout@v4.1.7'};\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"],"names":[],"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,KAAK;AAClB,KAAK;AACL,GAAG,CAAC;AACJ,CAAC;AACD;AACO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC3B,CAAC;AACD;AACO,SAAS,mBAAmB,GAAG;AACtC,EAAE,OAAO;AACT,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC;AAC9B,IAAI,CAAC,GAAG,EAAE,+BAA+B,CAAC;AAC1C,GAAG,CAAC;AACJ,CAAC;AACD;AACO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;AAC3C;;ACxBe,yBAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE;AAC9C,EAAE,OAAO,UAAU,CAAC,CAAC,EAAE,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE;;ACFe,eAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE;AAC9C,EAAE,OAAO,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAClG;;ACFe,eAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;AACtD,EAAE,OAAO,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3G;;;;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
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.1.0",
5
+ "version": "5.3.0",
6
6
  "type": "commonjs",
7
7
  "engines": {
8
8
  "node": "^18.17 || >=20.6.1"
@@ -90,6 +90,6 @@
90
90
  "vitest": "2.0.5"
91
91
  },
92
92
  "dependencies": {
93
- "@form8ion/core": "^4.6.1"
93
+ "@form8ion/core": "^4.7.1"
94
94
  }
95
95
  }