@github-actions-workflow-ts/cli 2.3.0 → 2.4.0-beta.2
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 +20 -1
- package/dist/commands/build.d.ts +60 -5
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +176 -14
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/types/build.d.ts +57 -0
- package/dist/commands/types/build.d.ts.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -77,7 +77,26 @@ This will generate `.github/workflows/example-filename.yml` from your TypeScript
|
|
|
77
77
|
|
|
78
78
|
## Configuration
|
|
79
79
|
|
|
80
|
-
Create a
|
|
80
|
+
Create a config file in your project root to customize generation. Both TypeScript (`wac.config.ts`) and JSON (`wac.config.json`) formats are supported. TypeScript config takes precedence if both exist.
|
|
81
|
+
|
|
82
|
+
### TypeScript Config (Recommended)
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// wac.config.ts
|
|
86
|
+
import type { WacConfig } from '@github-actions-workflow-ts/cli'
|
|
87
|
+
|
|
88
|
+
const config: WacConfig = {
|
|
89
|
+
refs: false,
|
|
90
|
+
headerText: [
|
|
91
|
+
'# Auto-generated from <source-file-path>',
|
|
92
|
+
'# Do not edit this file directly',
|
|
93
|
+
],
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default config
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### JSON Config
|
|
81
100
|
|
|
82
101
|
```json
|
|
83
102
|
{
|
package/dist/commands/build.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { type Workflow } from '@github-actions-workflow-ts/lib';
|
|
2
2
|
import type { WacConfig } from './types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Default output path for workflow files.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_OUTPUT_PATH: string;
|
|
7
|
+
/**
|
|
8
|
+
* Finds the project root directory by looking for markers like .git or package.json.
|
|
9
|
+
* Walks up the directory tree from the current working directory.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} [startDir] - The directory to start searching from. Defaults to cwd.
|
|
12
|
+
* @returns {string} - The project root directory, or cwd if no markers found.
|
|
13
|
+
*/
|
|
14
|
+
export declare const findProjectRoot: (startDir?: string) => string;
|
|
3
15
|
/**
|
|
4
16
|
* Comment indicating the file should not be modified.
|
|
5
17
|
* @type {string}
|
|
@@ -13,10 +25,49 @@ export declare const DEFAULT_HEADER_TEXT: string[];
|
|
|
13
25
|
*/
|
|
14
26
|
export declare const relativePath: (p: string) => string;
|
|
15
27
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
28
|
+
* Resolves the root directory for output paths.
|
|
29
|
+
* Priority: config.rootDir > auto-detected project root > cwd
|
|
30
|
+
*
|
|
31
|
+
* @param {WacConfig} config - The configuration object.
|
|
32
|
+
* @returns {string} - The resolved root directory (absolute path).
|
|
33
|
+
*/
|
|
34
|
+
export declare const resolveRootDir: (config: WacConfig) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the output path for a workflow file.
|
|
37
|
+
*
|
|
38
|
+
* Priority order:
|
|
39
|
+
* 1. workflow.outputPath (if set on the Workflow instance)
|
|
40
|
+
* 2. config.outputPaths.workflows.overrides (first matching pattern)
|
|
41
|
+
* 3. config.outputPaths.workflows.default
|
|
42
|
+
* 4. DEFAULT_OUTPUT_PATH (.github/workflows)
|
|
43
|
+
*
|
|
44
|
+
* Output paths are resolved relative to the root directory (see resolveRootDir).
|
|
45
|
+
*
|
|
46
|
+
* @param {Workflow} workflow - The workflow instance.
|
|
47
|
+
* @param {string} workflowFilePath - The source file path (e.g., "my-workflow.wac.ts").
|
|
48
|
+
* @param {WacConfig} config - The configuration object.
|
|
49
|
+
* @param {string} rootDir - The root directory for resolving output paths.
|
|
50
|
+
* @returns {string} - The resolved output directory path (absolute).
|
|
51
|
+
*/
|
|
52
|
+
export declare const resolveOutputPath: (workflow: Workflow, workflowFilePath: string, config: WacConfig, rootDir: string) => string;
|
|
53
|
+
/**
|
|
54
|
+
* Supported config file names in order of priority.
|
|
55
|
+
* TypeScript config takes precedence over JSON config.
|
|
56
|
+
*/
|
|
57
|
+
export declare const CONFIG_FILE_NAMES: readonly ["wac.config.ts", "wac.config.json"];
|
|
58
|
+
/**
|
|
59
|
+
* Returns the config file (synchronous version for JSON only)
|
|
60
|
+
* @returns {WacConfig | undefined} - The config file as an object
|
|
61
|
+
* @deprecated Use getConfigAsync for TypeScript config support
|
|
18
62
|
*/
|
|
19
63
|
export declare const getConfig: () => WacConfig | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the config file, supporting both TypeScript and JSON formats.
|
|
66
|
+
* Priority: wac.config.ts > wac.config.json
|
|
67
|
+
*
|
|
68
|
+
* @returns {Promise<WacConfig | undefined>} - The config file as an object
|
|
69
|
+
*/
|
|
70
|
+
export declare const getConfigAsync: () => Promise<WacConfig | undefined>;
|
|
20
71
|
/**
|
|
21
72
|
* Retrieves the file paths of all workflow files in the project.
|
|
22
73
|
*
|
|
@@ -37,13 +88,17 @@ export declare const importWorkflowFile: (filePath: string) => Promise<Record<st
|
|
|
37
88
|
* @param {Record<string, Workflow>} workflowJSON - The workflow data in JSON format.
|
|
38
89
|
* @param {string} workflowFilePath - The path to the workflow file.
|
|
39
90
|
* @param {WacConfig} config - Command line arguments.
|
|
91
|
+
* @param {string} rootDir - The root directory for resolving output paths.
|
|
92
|
+
* @param {Set<string>} [createdDirectories] - Optional set to track directories that have been created.
|
|
40
93
|
* @returns {number} - The number of workflows written.
|
|
41
94
|
*/
|
|
42
|
-
export declare const writeWorkflowJSONToYamlFiles: (workflowJSON: Record<string, Workflow>, workflowFilePath: string, config: WacConfig) => number;
|
|
95
|
+
export declare const writeWorkflowJSONToYamlFiles: (workflowJSON: Record<string, Workflow>, workflowFilePath: string, config: WacConfig, rootDir: string, createdDirectories?: Set<string>) => number;
|
|
43
96
|
/**
|
|
44
|
-
* Creates the
|
|
97
|
+
* Creates the workflow output directory if it doesn't exist.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} [outputPath] - Optional output path. Defaults to DEFAULT_OUTPUT_PATH.
|
|
45
100
|
*/
|
|
46
|
-
export declare const createWorkflowDirectory: () => void;
|
|
101
|
+
export declare const createWorkflowDirectory: (outputPath?: string) => void;
|
|
47
102
|
/**
|
|
48
103
|
* Generates workflow files based on the provided command line arguments.
|
|
49
104
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGjD;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAoC,CAAA;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,KAAG,MAgCnD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,UAK/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,MACR,CAAA;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,KAAG,MAQlD,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,EAClB,kBAAkB,MAAM,EACxB,QAAQ,SAAS,EACjB,SAAS,MAAM,KACd,MAwCF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,+CAAgD,CAAA;AAE9E;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAO,SAAS,GAAG,SAgBxC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAa,OAAO,CAAC,SAAS,GAAG,SAAS,CAiCpE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAO,MAAM,EAAE,GAAG,SA2BlD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,KACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAQlC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,GACvC,cAAc,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EACtC,kBAAkB,MAAM,EACxB,QAAQ,SAAS,EACjB,SAAS,MAAM,EACf,qBAAqB,GAAG,CAAC,MAAM,CAAC,KAC/B,MA8CF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAY,MAA4B,KACvC,IASF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,IAAI,CAsCd,CAAA"}
|
package/dist/commands/build.js
CHANGED
|
@@ -3,9 +3,49 @@ import * as fs from 'fs';
|
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import * as jsYaml from 'js-yaml';
|
|
5
5
|
import fg from 'fast-glob';
|
|
6
|
+
import micromatch from 'micromatch';
|
|
6
7
|
import { pathToFileURL } from 'url';
|
|
7
8
|
import { Context } from '@github-actions-workflow-ts/lib';
|
|
8
9
|
import { ConsoleDiagnosticsReporter } from './diagnostics.js';
|
|
10
|
+
/**
|
|
11
|
+
* Default output path for workflow files.
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_OUTPUT_PATH = path.join('.github', 'workflows');
|
|
14
|
+
/**
|
|
15
|
+
* Finds the project root directory by looking for markers like .git or package.json.
|
|
16
|
+
* Walks up the directory tree from the current working directory.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} [startDir] - The directory to start searching from. Defaults to cwd.
|
|
19
|
+
* @returns {string} - The project root directory, or cwd if no markers found.
|
|
20
|
+
*/
|
|
21
|
+
export const findProjectRoot = (startDir) => {
|
|
22
|
+
let currentDir = startDir || process.cwd();
|
|
23
|
+
const root = path.parse(currentDir).root;
|
|
24
|
+
while (currentDir !== root) {
|
|
25
|
+
// Check for .git directory (most reliable indicator of project root)
|
|
26
|
+
if (fs.existsSync(path.join(currentDir, '.git'))) {
|
|
27
|
+
return currentDir;
|
|
28
|
+
}
|
|
29
|
+
// Check for package.json as fallback (could be in a workspace package)
|
|
30
|
+
// Only use if it has workspaces defined (indicating it's the root)
|
|
31
|
+
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
32
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
33
|
+
try {
|
|
34
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
35
|
+
// If it has workspaces, it's likely the monorepo root
|
|
36
|
+
if (packageJson.workspaces) {
|
|
37
|
+
return currentDir;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Ignore parse errors
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
currentDir = path.dirname(currentDir);
|
|
45
|
+
}
|
|
46
|
+
// No project root found, return cwd
|
|
47
|
+
return process.cwd();
|
|
48
|
+
};
|
|
9
49
|
/**
|
|
10
50
|
* Comment indicating the file should not be modified.
|
|
11
51
|
* @type {string}
|
|
@@ -24,17 +64,120 @@ export const DEFAULT_HEADER_TEXT = [
|
|
|
24
64
|
*/
|
|
25
65
|
export const relativePath = (p) => path.relative(process.cwd(), p);
|
|
26
66
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
67
|
+
* Resolves the root directory for output paths.
|
|
68
|
+
* Priority: config.rootDir > auto-detected project root > cwd
|
|
69
|
+
*
|
|
70
|
+
* @param {WacConfig} config - The configuration object.
|
|
71
|
+
* @returns {string} - The resolved root directory (absolute path).
|
|
72
|
+
*/
|
|
73
|
+
export const resolveRootDir = (config) => {
|
|
74
|
+
if (config.rootDir) {
|
|
75
|
+
// If rootDir is relative, resolve it from cwd
|
|
76
|
+
return path.resolve(process.cwd(), config.rootDir);
|
|
77
|
+
}
|
|
78
|
+
// Auto-detect project root
|
|
79
|
+
return findProjectRoot();
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Resolves the output path for a workflow file.
|
|
83
|
+
*
|
|
84
|
+
* Priority order:
|
|
85
|
+
* 1. workflow.outputPath (if set on the Workflow instance)
|
|
86
|
+
* 2. config.outputPaths.workflows.overrides (first matching pattern)
|
|
87
|
+
* 3. config.outputPaths.workflows.default
|
|
88
|
+
* 4. DEFAULT_OUTPUT_PATH (.github/workflows)
|
|
89
|
+
*
|
|
90
|
+
* Output paths are resolved relative to the root directory (see resolveRootDir).
|
|
91
|
+
*
|
|
92
|
+
* @param {Workflow} workflow - The workflow instance.
|
|
93
|
+
* @param {string} workflowFilePath - The source file path (e.g., "my-workflow.wac.ts").
|
|
94
|
+
* @param {WacConfig} config - The configuration object.
|
|
95
|
+
* @param {string} rootDir - The root directory for resolving output paths.
|
|
96
|
+
* @returns {string} - The resolved output directory path (absolute).
|
|
97
|
+
*/
|
|
98
|
+
export const resolveOutputPath = (workflow, workflowFilePath, config, rootDir) => {
|
|
99
|
+
let outputPath;
|
|
100
|
+
// 1. Check workflow-level outputPath (highest priority)
|
|
101
|
+
if (workflow.outputPath) {
|
|
102
|
+
outputPath = workflow.outputPath;
|
|
103
|
+
}
|
|
104
|
+
// 2. Check config overrides
|
|
105
|
+
else {
|
|
106
|
+
const outputPathsConfig = config.outputPaths?.workflows;
|
|
107
|
+
if (outputPathsConfig?.overrides) {
|
|
108
|
+
const filename = path.basename(workflowFilePath);
|
|
109
|
+
let matched = false;
|
|
110
|
+
for (const override of outputPathsConfig.overrides) {
|
|
111
|
+
// Match against both the full relative path and just the filename
|
|
112
|
+
// This allows patterns like "packages/app-a/**/*.wac.ts" or "deploy.wac.ts"
|
|
113
|
+
if (micromatch.isMatch(workflowFilePath, override.match) ||
|
|
114
|
+
micromatch.isMatch(filename, override.match)) {
|
|
115
|
+
outputPath = override.path;
|
|
116
|
+
matched = true;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!matched) {
|
|
121
|
+
// 3. Check config default
|
|
122
|
+
outputPath = outputPathsConfig?.default || DEFAULT_OUTPUT_PATH;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// 3. Check config default
|
|
127
|
+
outputPath = outputPathsConfig?.default || DEFAULT_OUTPUT_PATH;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Resolve relative paths from rootDir, absolute paths stay as-is
|
|
131
|
+
if (path.isAbsolute(outputPath)) {
|
|
132
|
+
return outputPath;
|
|
133
|
+
}
|
|
134
|
+
return path.join(rootDir, outputPath);
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Supported config file names in order of priority.
|
|
138
|
+
* TypeScript config takes precedence over JSON config.
|
|
139
|
+
*/
|
|
140
|
+
export const CONFIG_FILE_NAMES = ['wac.config.ts', 'wac.config.json'];
|
|
141
|
+
/**
|
|
142
|
+
* Returns the config file (synchronous version for JSON only)
|
|
143
|
+
* @returns {WacConfig | undefined} - The config file as an object
|
|
144
|
+
* @deprecated Use getConfigAsync for TypeScript config support
|
|
29
145
|
*/
|
|
30
146
|
export const getConfig = () => {
|
|
31
|
-
const
|
|
32
|
-
if (!fs.existsSync(
|
|
147
|
+
const jsonConfigPath = path.join(process.cwd(), 'wac.config.json');
|
|
148
|
+
if (!fs.existsSync(jsonConfigPath)) {
|
|
33
149
|
console.log('[github-actions-workflow-ts] No config (wac.config.json) file found in root dir. Using default config.');
|
|
34
150
|
return undefined;
|
|
35
151
|
}
|
|
36
152
|
console.log('[github-actions-workflow-ts] wac.config.json config file found in root dir');
|
|
37
|
-
return JSON.parse(fs.readFileSync(
|
|
153
|
+
return JSON.parse(fs.readFileSync(jsonConfigPath, 'utf-8'));
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Returns the config file, supporting both TypeScript and JSON formats.
|
|
157
|
+
* Priority: wac.config.ts > wac.config.json
|
|
158
|
+
*
|
|
159
|
+
* @returns {Promise<WacConfig | undefined>} - The config file as an object
|
|
160
|
+
*/
|
|
161
|
+
export const getConfigAsync = async () => {
|
|
162
|
+
const cwd = process.cwd();
|
|
163
|
+
// Check for TypeScript config first (higher priority)
|
|
164
|
+
const tsConfigPath = path.join(cwd, 'wac.config.ts');
|
|
165
|
+
if (fs.existsSync(tsConfigPath)) {
|
|
166
|
+
console.log('[github-actions-workflow-ts] wac.config.ts config file found in root dir');
|
|
167
|
+
const absolutePath = path.resolve(tsConfigPath);
|
|
168
|
+
const fileUrl = pathToFileURL(absolutePath).href;
|
|
169
|
+
const module = await import(fileUrl);
|
|
170
|
+
// Support both default export and named 'config' export
|
|
171
|
+
return module.default || module.config;
|
|
172
|
+
}
|
|
173
|
+
// Fall back to JSON config
|
|
174
|
+
const jsonConfigPath = path.join(cwd, 'wac.config.json');
|
|
175
|
+
if (fs.existsSync(jsonConfigPath)) {
|
|
176
|
+
console.log('[github-actions-workflow-ts] wac.config.json config file found in root dir');
|
|
177
|
+
return JSON.parse(fs.readFileSync(jsonConfigPath, 'utf-8'));
|
|
178
|
+
}
|
|
179
|
+
console.log('[github-actions-workflow-ts] No config file found in root dir. Using default config.');
|
|
180
|
+
return undefined;
|
|
38
181
|
};
|
|
39
182
|
/**
|
|
40
183
|
* Retrieves the file paths of all workflow files in the project.
|
|
@@ -45,6 +188,7 @@ export const getWorkflowFilePaths = () => {
|
|
|
45
188
|
const workflowFilesPaths = fg.sync(fg.convertPathToPattern(process.cwd()) + '/**/*.wac.ts', {
|
|
46
189
|
onlyFiles: true,
|
|
47
190
|
dot: true,
|
|
191
|
+
ignore: ['**/node_modules/**'],
|
|
48
192
|
});
|
|
49
193
|
if (!workflowFilesPaths || !workflowFilesPaths.length) {
|
|
50
194
|
console.log('[github-actions-workflow-ts] No workflow files found. Please create at least one *.wac.ts file in your project');
|
|
@@ -76,9 +220,11 @@ export const importWorkflowFile = async (filePath) => {
|
|
|
76
220
|
* @param {Record<string, Workflow>} workflowJSON - The workflow data in JSON format.
|
|
77
221
|
* @param {string} workflowFilePath - The path to the workflow file.
|
|
78
222
|
* @param {WacConfig} config - Command line arguments.
|
|
223
|
+
* @param {string} rootDir - The root directory for resolving output paths.
|
|
224
|
+
* @param {Set<string>} [createdDirectories] - Optional set to track directories that have been created.
|
|
79
225
|
* @returns {number} - The number of workflows written.
|
|
80
226
|
*/
|
|
81
|
-
export const writeWorkflowJSONToYamlFiles = (workflowJSON, workflowFilePath, config) => {
|
|
227
|
+
export const writeWorkflowJSONToYamlFiles = (workflowJSON, workflowFilePath, config, rootDir, createdDirectories) => {
|
|
82
228
|
let workflowCount = 0;
|
|
83
229
|
for (const workflowName in workflowJSON) {
|
|
84
230
|
const workflow = workflowJSON[workflowName];
|
|
@@ -90,7 +236,14 @@ export const writeWorkflowJSONToYamlFiles = (workflowJSON, workflowFilePath, con
|
|
|
90
236
|
noRefs: !config.refs,
|
|
91
237
|
...(config.dumpOptions || {}),
|
|
92
238
|
});
|
|
93
|
-
|
|
239
|
+
// Resolve the output path for this workflow
|
|
240
|
+
const outputDir = resolveOutputPath(workflow, workflowFilePath, config, rootDir);
|
|
241
|
+
// Create directory if not already created
|
|
242
|
+
if (createdDirectories && !createdDirectories.has(outputDir)) {
|
|
243
|
+
createWorkflowDirectory(outputDir);
|
|
244
|
+
createdDirectories.add(outputDir);
|
|
245
|
+
}
|
|
246
|
+
const yamlWorkflowPath = path.join(outputDir, `${workflow.filename}.yml`);
|
|
94
247
|
console.log(`[github-actions-workflow-ts] Writing to ${relativePath(yamlWorkflowPath)}:`);
|
|
95
248
|
const headerText = (config.headerText || DEFAULT_HEADER_TEXT)
|
|
96
249
|
.join('\n')
|
|
@@ -101,12 +254,14 @@ export const writeWorkflowJSONToYamlFiles = (workflowJSON, workflowFilePath, con
|
|
|
101
254
|
return workflowCount;
|
|
102
255
|
};
|
|
103
256
|
/**
|
|
104
|
-
* Creates the
|
|
257
|
+
* Creates the workflow output directory if it doesn't exist.
|
|
258
|
+
*
|
|
259
|
+
* @param {string} [outputPath] - Optional output path. Defaults to DEFAULT_OUTPUT_PATH.
|
|
105
260
|
*/
|
|
106
|
-
export const createWorkflowDirectory = () => {
|
|
107
|
-
const workflowsDir = relativePath(
|
|
261
|
+
export const createWorkflowDirectory = (outputPath = DEFAULT_OUTPUT_PATH) => {
|
|
262
|
+
const workflowsDir = relativePath(outputPath);
|
|
108
263
|
if (!fs.existsSync(workflowsDir)) {
|
|
109
|
-
console.log(
|
|
264
|
+
console.log(`[github-actions-workflow-ts] ${workflowsDir} directory not found. Creating it.`);
|
|
110
265
|
fs.mkdirSync(workflowsDir, { recursive: true });
|
|
111
266
|
}
|
|
112
267
|
};
|
|
@@ -117,10 +272,17 @@ export const createWorkflowDirectory = () => {
|
|
|
117
272
|
* @returns {Promise<void>} - A promise that resolves when the generation is completed.
|
|
118
273
|
*/
|
|
119
274
|
export const generateWorkflowFiles = async (argv) => {
|
|
120
|
-
const config =
|
|
275
|
+
const config = (await getConfigAsync()) || {};
|
|
121
276
|
const workflowFilePaths = getWorkflowFilePaths() || [];
|
|
122
277
|
let workflowCount = 0;
|
|
123
|
-
|
|
278
|
+
// Resolve the root directory for output paths
|
|
279
|
+
const rootDir = resolveRootDir(config);
|
|
280
|
+
const cwd = process.cwd();
|
|
281
|
+
if (rootDir !== cwd) {
|
|
282
|
+
console.log(`[github-actions-workflow-ts] Using project root: ${rootDir}`);
|
|
283
|
+
}
|
|
284
|
+
// Track created directories to avoid duplicate creation attempts
|
|
285
|
+
const createdDirectories = new Set();
|
|
124
286
|
Context.__internalSetGlobalContext({
|
|
125
287
|
diagnostics: new ConsoleDiagnosticsReporter(),
|
|
126
288
|
diagnosticRules: config.diagnostics?.rules,
|
|
@@ -130,7 +292,7 @@ export const generateWorkflowFiles = async (argv) => {
|
|
|
130
292
|
workflowCount += writeWorkflowJSONToYamlFiles(workflows, relativePath(filePath), {
|
|
131
293
|
...argv,
|
|
132
294
|
...config,
|
|
133
|
-
});
|
|
295
|
+
}, rootDir, createdDirectories);
|
|
134
296
|
}
|
|
135
297
|
console.log(`[github-actions-workflow-ts] Successfully generated ${workflowCount} workflow file(s)`);
|
|
136
298
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,MAAM,WAAW,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,OAAO,EAAiB,MAAM,iCAAiC,CAAA;AAExE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,mDAAmD;IACnD,wEAAwE;IACxE,sCAAsC;IACtC,mDAAmD;CACpD,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAU,EAAE,CAChD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAA;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAA0B,EAAE;IACnD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAA;IAElE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QACnC,OAAO,CAAC,GAAG,CACT,wGAAwG,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IAErB,8CAA8C;IAC9C,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IACtC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAEzB,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,oDAAoD,OAAO,EAAE,CAAC,CAAA;IAC5E,CAAC;IAED,iEAAiE;IACjE,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAU,CAAA;IAE5C,OAAO,CAAC,0BAA0B,CAAC;QACjC,WAAW,EAAE,IAAI,0BAA0B,EAAE;QAC7C,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK;KAC3C,CAAC,CAAA;IAEF,KAAK,MAAM,QAAQ,IAAI,iBAAiB,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACpD,aAAa,IAAI,4BAA4B,CAC3C,SAAS,EACT,YAAY,CAAC,QAAQ,CAAC,EACtB;YACE,GAAG,IAAI;YACP,GAAG,MAAM;SACG,EACd,OAAO,EACP,kBAAkB,CACnB,CAAA;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CACT,uDAAuD,aAAa,mBAAmB,CACxF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -25,6 +25,46 @@ export type DiagnosticsConfig = {
|
|
|
25
25
|
*/
|
|
26
26
|
rules?: Record<string, DiagnosticRuleConfig>;
|
|
27
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Override rule for output paths.
|
|
30
|
+
* Allows specifying custom output directories for specific workflow files.
|
|
31
|
+
*/
|
|
32
|
+
export type OutputPathOverride = {
|
|
33
|
+
/**
|
|
34
|
+
* Pattern to match against workflow source files.
|
|
35
|
+
* Supports both filename patterns and full path patterns.
|
|
36
|
+
* Examples:
|
|
37
|
+
* - Filename: "app-a-deploy.wac.ts", "*-release.wac.ts"
|
|
38
|
+
* - Full path: "packages/app-a/**.wac.ts", "src/workflows/*.wac.ts"
|
|
39
|
+
*/
|
|
40
|
+
match: string;
|
|
41
|
+
/**
|
|
42
|
+
* Output directory path for matching workflow files.
|
|
43
|
+
* Can be relative or absolute.
|
|
44
|
+
*/
|
|
45
|
+
path: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Configuration for custom output paths.
|
|
49
|
+
* Allows workflows to be written to different directories.
|
|
50
|
+
*/
|
|
51
|
+
export type OutputPathsConfig = {
|
|
52
|
+
/**
|
|
53
|
+
* Configuration for workflow file output paths.
|
|
54
|
+
*/
|
|
55
|
+
workflows?: {
|
|
56
|
+
/**
|
|
57
|
+
* Default output directory for workflow files.
|
|
58
|
+
* Defaults to ".github/workflows" if not specified.
|
|
59
|
+
*/
|
|
60
|
+
default?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Override rules for specific workflow files.
|
|
63
|
+
* Checked in order; first match wins.
|
|
64
|
+
*/
|
|
65
|
+
overrides?: OutputPathOverride[];
|
|
66
|
+
};
|
|
67
|
+
};
|
|
28
68
|
export type WacConfig = {
|
|
29
69
|
refs?: boolean;
|
|
30
70
|
headerText?: string[];
|
|
@@ -33,5 +73,22 @@ export type WacConfig = {
|
|
|
33
73
|
* Configuration for diagnostics/warnings emitted during build.
|
|
34
74
|
*/
|
|
35
75
|
diagnostics?: DiagnosticsConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Configuration for custom output paths.
|
|
78
|
+
* Allows workflows to be written to different directories based on filename patterns.
|
|
79
|
+
*/
|
|
80
|
+
outputPaths?: OutputPathsConfig;
|
|
81
|
+
/**
|
|
82
|
+
* Root directory for resolving output paths.
|
|
83
|
+
* If not specified, automatically detected by finding the nearest .git directory
|
|
84
|
+
* or package.json with workspaces.
|
|
85
|
+
*
|
|
86
|
+
* This is useful when running gwf from a subdirectory (e.g., scripts/) but
|
|
87
|
+
* wanting output paths to be relative to the project root.
|
|
88
|
+
*
|
|
89
|
+
* @example "../../" - Go up two directories from cwd
|
|
90
|
+
* @example "/absolute/path/to/project" - Use an absolute path
|
|
91
|
+
*/
|
|
92
|
+
rootDir?: string;
|
|
36
93
|
};
|
|
37
94
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/types/build.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC5B,kBAAkB,GAClB;IACE,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAA;AAEL;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/types/build.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC5B,kBAAkB,GAClB;IACE,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAA;AAEL;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;CAC7C,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE;QACV;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB;;;WAGG;QACH,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAA;KACjC,CAAA;CACF,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github-actions-workflow-ts/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-beta.2",
|
|
4
4
|
"description": "CLI to generate GitHub Actions YAML from TypeScript workflow files",
|
|
5
5
|
"author": "Emmanuel N Kyeyune",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,13 +32,15 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"fast-glob": "^3.3.2",
|
|
34
34
|
"js-yaml": "^4.1.0",
|
|
35
|
+
"micromatch": "^4.0.8",
|
|
35
36
|
"tsx": "^4.19.3",
|
|
36
37
|
"yargs": "^17.7.2",
|
|
37
|
-
"@github-actions-workflow-ts/lib": "2.
|
|
38
|
+
"@github-actions-workflow-ts/lib": "2.4.0-beta.2"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@jest/globals": "^29.7.0",
|
|
41
42
|
"@types/js-yaml": "^4.0.9",
|
|
43
|
+
"@types/micromatch": "^4.0.10",
|
|
42
44
|
"@types/node": "^22.10.1",
|
|
43
45
|
"@types/yargs": "^17.0.33",
|
|
44
46
|
"typescript": "^5.7.2"
|