@github-actions-workflow-ts/cli 2.0.1 → 2.2.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/dist/commands/build.d.ts +36 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +183 -2
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/types/build.d.ts +8 -0
- package/dist/commands/types/build.d.ts.map +1 -1
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +2 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/version-warning.d.ts +67 -0
- package/dist/validation/version-warning.d.ts.map +1 -0
- package/dist/validation/version-warning.js +132 -0
- package/dist/validation/version-warning.js.map +1 -0
- package/package.json +2 -2
package/dist/commands/build.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { Workflow } from '@github-actions-workflow-ts/lib';
|
|
2
2
|
import type { WacConfig } from './types/index.js';
|
|
3
|
+
import { type VersionWarning, type ActionVersionRegistry } from '../validation/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Strip internal metadata properties (prefixed with _) from workflow object.
|
|
6
|
+
* This removes properties like _sourceVersion and _defaultUses that are used
|
|
7
|
+
* for validation but shouldn't appear in the final YAML.
|
|
8
|
+
*/
|
|
9
|
+
export declare const stripInternalMetadata: (obj: any) => any;
|
|
3
10
|
/**
|
|
4
11
|
* Comment indicating the file should not be modified.
|
|
5
|
-
* @type {string}
|
|
6
12
|
*/
|
|
7
13
|
export declare const DEFAULT_HEADER_TEXT: string[];
|
|
8
14
|
/**
|
|
@@ -40,6 +46,35 @@ export declare const importWorkflowFile: (filePath: string) => Promise<Record<st
|
|
|
40
46
|
* @returns {number} - The number of workflows written.
|
|
41
47
|
*/
|
|
42
48
|
export declare const writeWorkflowJSONToYamlFiles: (workflowJSON: Record<string, Workflow>, workflowFilePath: string, config: WacConfig) => number;
|
|
49
|
+
/**
|
|
50
|
+
* Information about an action step including its uses string and source version if available.
|
|
51
|
+
*/
|
|
52
|
+
export interface ActionStepInfo {
|
|
53
|
+
uses: string;
|
|
54
|
+
sourceVersion?: string;
|
|
55
|
+
defaultUses?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Extract all 'uses' values from a workflow's steps, along with source version info if available.
|
|
59
|
+
*/
|
|
60
|
+
export declare const extractUsesFromWorkflow: (workflow: any) => ActionStepInfo[];
|
|
61
|
+
/**
|
|
62
|
+
* Build a registry of action source versions from an imported workflow module.
|
|
63
|
+
* Scans the module for SourceVersion exports that were re-exported from the actions package.
|
|
64
|
+
* Maps action patterns (e.g., 'actions/checkout@v6') to their source versions (e.g., 'v6.2.0').
|
|
65
|
+
*/
|
|
66
|
+
export declare const buildActionVersionRegistryFromModule: (workflowModule: any) => ActionVersionRegistry;
|
|
67
|
+
/**
|
|
68
|
+
* Build a registry of action source versions from the actions package.
|
|
69
|
+
* Maps action patterns (e.g., 'actions/checkout@v6') to their source versions (e.g., 'v6.2.0').
|
|
70
|
+
*/
|
|
71
|
+
export declare const buildActionVersionRegistry: () => Promise<ActionVersionRegistry>;
|
|
72
|
+
/**
|
|
73
|
+
* Validate action versions in a workflow against known source versions.
|
|
74
|
+
* Uses source version info embedded in the step by typed action classes,
|
|
75
|
+
* falling back to a registry lookup if not available.
|
|
76
|
+
*/
|
|
77
|
+
export declare const validateWorkflowVersions: (workflow: any, registry: ActionVersionRegistry) => VersionWarning[];
|
|
43
78
|
/**
|
|
44
79
|
* Creates the .github/workflows directory if it doesn't exist.
|
|
45
80
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":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0B,QAC3B,OAAO,CAAC,qBAAqB,CAgDtC,CAAA;AAEH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAEnC,UAAU,GAAG,EACb,UAAU,qBAAqB,KAC9B,cAAc,EA6BhB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAO,IAS1C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,IAAI,CA+Cd,CAAA"}
|
package/dist/commands/build.js
CHANGED
|
@@ -4,9 +4,32 @@ import * as path from 'path';
|
|
|
4
4
|
import * as jsYaml from 'js-yaml';
|
|
5
5
|
import fg from 'fast-glob';
|
|
6
6
|
import { pathToFileURL } from 'url';
|
|
7
|
+
import { validateActionVersion, logVersionWarnings, getActionPattern, } from '../validation/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Strip internal metadata properties (prefixed with _) from workflow object.
|
|
10
|
+
* This removes properties like _sourceVersion and _defaultUses that are used
|
|
11
|
+
* for validation but shouldn't appear in the final YAML.
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
export const stripInternalMetadata = (obj) => {
|
|
15
|
+
if (obj === null || typeof obj !== 'object') {
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(obj)) {
|
|
19
|
+
return obj.map(stripInternalMetadata);
|
|
20
|
+
}
|
|
21
|
+
const result = {};
|
|
22
|
+
for (const key in obj) {
|
|
23
|
+
// Skip properties starting with underscore
|
|
24
|
+
if (key.startsWith('_')) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
result[key] = stripInternalMetadata(obj[key]);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
7
31
|
/**
|
|
8
32
|
* Comment indicating the file should not be modified.
|
|
9
|
-
* @type {string}
|
|
10
33
|
*/
|
|
11
34
|
export const DEFAULT_HEADER_TEXT = [
|
|
12
35
|
'# ------------DO-NOT-MODIFY-THIS-FILE------------',
|
|
@@ -84,7 +107,9 @@ export const writeWorkflowJSONToYamlFiles = (workflowJSON, workflowFilePath, con
|
|
|
84
107
|
if (!workflow || !workflow.workflow || !workflow.filename) {
|
|
85
108
|
continue;
|
|
86
109
|
}
|
|
87
|
-
|
|
110
|
+
// Strip internal metadata properties before YAML serialization
|
|
111
|
+
const cleanedWorkflow = stripInternalMetadata(workflow.workflow);
|
|
112
|
+
const workflowYaml = jsYaml.dump(cleanedWorkflow, {
|
|
88
113
|
noRefs: !config.refs,
|
|
89
114
|
...(config.dumpOptions || {}),
|
|
90
115
|
});
|
|
@@ -98,6 +123,142 @@ export const writeWorkflowJSONToYamlFiles = (workflowJSON, workflowFilePath, con
|
|
|
98
123
|
}
|
|
99
124
|
return workflowCount;
|
|
100
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Extract all 'uses' values from a workflow's steps, along with source version info if available.
|
|
128
|
+
*/
|
|
129
|
+
export const extractUsesFromWorkflow = (
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
+
workflow) => {
|
|
132
|
+
const actions = [];
|
|
133
|
+
if (!workflow?.jobs)
|
|
134
|
+
return actions;
|
|
135
|
+
for (const jobName in workflow.jobs) {
|
|
136
|
+
const job = workflow.jobs[jobName];
|
|
137
|
+
if (!job?.steps || !Array.isArray(job.steps))
|
|
138
|
+
continue;
|
|
139
|
+
for (const step of job.steps) {
|
|
140
|
+
if (step?.uses && typeof step.uses === 'string') {
|
|
141
|
+
actions.push({
|
|
142
|
+
uses: step.uses,
|
|
143
|
+
sourceVersion: step._sourceVersion,
|
|
144
|
+
defaultUses: step._defaultUses,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return actions;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Build a registry of action source versions from an imported workflow module.
|
|
153
|
+
* Scans the module for SourceVersion exports that were re-exported from the actions package.
|
|
154
|
+
* Maps action patterns (e.g., 'actions/checkout@v6') to their source versions (e.g., 'v6.2.0').
|
|
155
|
+
*/
|
|
156
|
+
export const buildActionVersionRegistryFromModule = (
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
|
+
workflowModule) => {
|
|
159
|
+
const registry = new Map();
|
|
160
|
+
// The workflow module may have imported action classes from @github-actions-workflow-ts/actions
|
|
161
|
+
// We need to find any SourceVersion constants that were imported alongside them
|
|
162
|
+
// This is tricky because we don't have direct access to the actions package exports
|
|
163
|
+
// Instead, scan for any exported values that look like SourceVersion constants
|
|
164
|
+
for (const key in workflowModule) {
|
|
165
|
+
if (key.endsWith('SourceVersion')) {
|
|
166
|
+
const value = workflowModule[key];
|
|
167
|
+
if (typeof value === 'string') {
|
|
168
|
+
const className = key.replace('SourceVersion', '');
|
|
169
|
+
const actionClass = workflowModule[className];
|
|
170
|
+
if (typeof actionClass === 'function') {
|
|
171
|
+
try {
|
|
172
|
+
const instance = new actionClass();
|
|
173
|
+
if (instance.step?.uses) {
|
|
174
|
+
registry.set(instance.step.uses, value);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// Skip if constructor fails
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return registry;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Build a registry of action source versions from the actions package.
|
|
188
|
+
* Maps action patterns (e.g., 'actions/checkout@v6') to their source versions (e.g., 'v6.2.0').
|
|
189
|
+
*/
|
|
190
|
+
export const buildActionVersionRegistry = async () => {
|
|
191
|
+
const registry = new Map();
|
|
192
|
+
try {
|
|
193
|
+
// Try to import the actions package dynamically
|
|
194
|
+
// Using a variable to prevent static analysis from failing the build
|
|
195
|
+
const packageName = '@github-actions-workflow-ts/actions';
|
|
196
|
+
const actionsModule = (await import(packageName));
|
|
197
|
+
// Look for exports ending in 'SourceVersion' and their corresponding action metadata
|
|
198
|
+
for (const key in actionsModule) {
|
|
199
|
+
if (key.endsWith('SourceVersion')) {
|
|
200
|
+
const value = actionsModule[key];
|
|
201
|
+
if (typeof value === 'string') {
|
|
202
|
+
// The key format is like 'ActionsCheckoutV6SourceVersion'
|
|
203
|
+
// We need to map this to 'actions/checkout@v6'
|
|
204
|
+
const className = key.replace('SourceVersion', '');
|
|
205
|
+
// Try to find the corresponding class and get its default uses value
|
|
206
|
+
const actionClass = actionsModule[className];
|
|
207
|
+
if (typeof actionClass === 'function' &&
|
|
208
|
+
'prototype' in actionClass) {
|
|
209
|
+
try {
|
|
210
|
+
// Create a temporary instance to get the default uses value
|
|
211
|
+
const instance = new actionClass();
|
|
212
|
+
if (instance.step?.uses) {
|
|
213
|
+
// Extract the action pattern (e.g., 'actions/checkout@v6')
|
|
214
|
+
registry.set(instance.step.uses, value);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// Constructor might require arguments, skip this action
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Package not installed or not available, skip version validation
|
|
227
|
+
}
|
|
228
|
+
return registry;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Validate action versions in a workflow against known source versions.
|
|
232
|
+
* Uses source version info embedded in the step by typed action classes,
|
|
233
|
+
* falling back to a registry lookup if not available.
|
|
234
|
+
*/
|
|
235
|
+
export const validateWorkflowVersions = (
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
237
|
+
workflow, registry) => {
|
|
238
|
+
const warnings = [];
|
|
239
|
+
const actionSteps = extractUsesFromWorkflow(workflow);
|
|
240
|
+
for (const actionStep of actionSteps) {
|
|
241
|
+
// Prefer embedded source version from typed action class
|
|
242
|
+
let sourceVersion = actionStep.sourceVersion;
|
|
243
|
+
const defaultUses = actionStep.defaultUses;
|
|
244
|
+
// Fall back to registry lookup if no embedded version
|
|
245
|
+
if (!sourceVersion && registry.size > 0) {
|
|
246
|
+
const pattern = getActionPattern(actionStep.uses);
|
|
247
|
+
sourceVersion = registry.get(pattern);
|
|
248
|
+
}
|
|
249
|
+
// Also try matching against defaultUses if available
|
|
250
|
+
if (!sourceVersion && defaultUses && registry.size > 0) {
|
|
251
|
+
sourceVersion = registry.get(defaultUses);
|
|
252
|
+
}
|
|
253
|
+
if (sourceVersion) {
|
|
254
|
+
const warning = validateActionVersion(actionStep.uses, sourceVersion);
|
|
255
|
+
if (warning) {
|
|
256
|
+
warnings.push(warning);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return warnings;
|
|
261
|
+
};
|
|
101
262
|
/**
|
|
102
263
|
* Creates the .github/workflows directory if it doesn't exist.
|
|
103
264
|
*/
|
|
@@ -118,14 +279,34 @@ export const generateWorkflowFiles = async (argv) => {
|
|
|
118
279
|
const config = getConfig() || {};
|
|
119
280
|
const workflowFilePaths = getWorkflowFilePaths() || [];
|
|
120
281
|
let workflowCount = 0;
|
|
282
|
+
const allWarnings = [];
|
|
283
|
+
// Build version registry for validation (if warnings are enabled)
|
|
284
|
+
const versionWarningsEnabled = config.actionsPackageOutdatedVersionWarnings !== false;
|
|
285
|
+
const registry = versionWarningsEnabled
|
|
286
|
+
? await buildActionVersionRegistry()
|
|
287
|
+
: new Map();
|
|
121
288
|
createWorkflowDirectory();
|
|
122
289
|
for (const filePath of workflowFilePaths) {
|
|
123
290
|
const workflows = await importWorkflowFile(filePath);
|
|
291
|
+
// Validate versions if enabled
|
|
292
|
+
if (versionWarningsEnabled) {
|
|
293
|
+
for (const workflowName in workflows) {
|
|
294
|
+
const workflow = workflows[workflowName];
|
|
295
|
+
if (workflow?.workflow) {
|
|
296
|
+
const warnings = validateWorkflowVersions(workflow.workflow, registry);
|
|
297
|
+
allWarnings.push(...warnings);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
124
301
|
workflowCount += writeWorkflowJSONToYamlFiles(workflows, relativePath(filePath), {
|
|
125
302
|
...argv,
|
|
126
303
|
...config,
|
|
127
304
|
});
|
|
128
305
|
}
|
|
129
306
|
console.log(`[github-actions-workflow-ts] Successfully generated ${workflowCount} workflow file(s)`);
|
|
307
|
+
// Log version warnings at the end
|
|
308
|
+
if (versionWarningsEnabled) {
|
|
309
|
+
logVersionWarnings(allWarnings);
|
|
310
|
+
}
|
|
130
311
|
};
|
|
131
312
|
//# sourceMappingURL=build.js.map
|
|
@@ -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;
|
|
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;AAGnC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GAGjB,MAAM,wBAAwB,CAAA;AAE/B;;;;GAIG;AACH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAO,EAAE;IACrD,IAAI,GAAG,KAA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E,CAAC;gBACrC,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;gBACxC,IAAI,QAAQ,EAAE,QAAQ,EAAE,CAAC;oBACvB,MAAM,QAAQ,GAAG,wBAAwB,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;oBACtE,WAAW,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAA;gBAC/B,CAAC;YACH,CAAC;QACH,CAAC;QAED,aAAa,IAAI,4BAA4B,CAC3C,SAAS,EACT,YAAY,CAAC,QAAQ,CAAC,EACtB;YACE,GAAG,IAAI;YACP,GAAG,MAAM;SACG,CACf,CAAA;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CACT,uDAAuD,aAAa,mBAAmB,CACxF,CAAA;IAED,kCAAkC;IAClC,IAAI,sBAAsB,EAAE,CAAC;QAC3B,kBAAkB,CAAC,WAAW,CAAC,CAAA;IACjC,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -2,5 +2,13 @@ export type WacConfig = {
|
|
|
2
2
|
refs?: boolean;
|
|
3
3
|
headerText?: string[];
|
|
4
4
|
dumpOptions?: Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Enable/disable version mismatch warnings for actions package.
|
|
7
|
+
* When true (default), warns when:
|
|
8
|
+
* - A pinned version is older than the version types were generated from
|
|
9
|
+
* - A non-semver ref (commit SHA, branch) is used
|
|
10
|
+
* Set to false to suppress these warnings.
|
|
11
|
+
*/
|
|
12
|
+
actionsPackageOutdatedVersionWarnings?: boolean;
|
|
5
13
|
};
|
|
6
14
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/types/build.ts"],"names":[],"mappings":"AAAA,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;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/types/build.ts"],"names":[],"mappings":"AAAA,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;;;;;;OAMG;IACH,qCAAqC,CAAC,EAAE,OAAO,CAAA;CAChD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a semver-like version string into its components.
|
|
3
|
+
* Returns null if the version doesn't match semver patterns.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseVersion(version: string): {
|
|
6
|
+
major: number;
|
|
7
|
+
minor: number;
|
|
8
|
+
patch: number;
|
|
9
|
+
} | null;
|
|
10
|
+
/**
|
|
11
|
+
* Compare two semver versions.
|
|
12
|
+
* Returns: positive if a > b, negative if a < b, 0 if equal
|
|
13
|
+
*/
|
|
14
|
+
export declare function compareSemver(a: {
|
|
15
|
+
major: number;
|
|
16
|
+
minor: number;
|
|
17
|
+
patch: number;
|
|
18
|
+
}, b: {
|
|
19
|
+
major: number;
|
|
20
|
+
minor: number;
|
|
21
|
+
patch: number;
|
|
22
|
+
}): number;
|
|
23
|
+
/**
|
|
24
|
+
* Extract the version part from a uses string.
|
|
25
|
+
* e.g., "actions/checkout@v6.0.1" -> "v6.0.1"
|
|
26
|
+
* "actions/checkout@abc123" -> "abc123"
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractVersionFromUses(uses: string): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a version string looks like a semver (vX, vX.Y, or vX.Y.Z).
|
|
31
|
+
*/
|
|
32
|
+
export declare function isSemverLike(version: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Result of version validation.
|
|
35
|
+
*/
|
|
36
|
+
export interface VersionWarning {
|
|
37
|
+
uses: string;
|
|
38
|
+
usedVersion: string;
|
|
39
|
+
sourceVersion: string;
|
|
40
|
+
message: string;
|
|
41
|
+
type: 'older-version' | 'non-semver-ref';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if a version string is a major-only version (e.g., "v4" not "v4.1.0").
|
|
45
|
+
*/
|
|
46
|
+
export declare function isMajorOnly(version: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Validate a uses string against a source version.
|
|
49
|
+
* Returns a warning object if there's a potential issue, null otherwise.
|
|
50
|
+
*/
|
|
51
|
+
export declare function validateActionVersion(uses: string, sourceVersion: string): VersionWarning | null;
|
|
52
|
+
/**
|
|
53
|
+
* Log version warnings to console.
|
|
54
|
+
*/
|
|
55
|
+
export declare function logVersionWarnings(warnings: VersionWarning[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Known action source versions registry.
|
|
58
|
+
* Maps action patterns to their source versions.
|
|
59
|
+
* This is populated by importing from @github-actions-workflow-ts/actions.
|
|
60
|
+
*/
|
|
61
|
+
export type ActionVersionRegistry = Map<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* Create an action pattern from owner/repo for lookup.
|
|
64
|
+
* e.g., "actions/checkout@v6" -> "actions/checkout@v6"
|
|
65
|
+
*/
|
|
66
|
+
export declare function getActionPattern(uses: string): string;
|
|
67
|
+
//# sourceMappingURL=version-warning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-warning.d.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AAC,CAAA;AAEvD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAerD"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/**
|
|
3
|
+
* Parse a semver-like version string into its components.
|
|
4
|
+
* Returns null if the version doesn't match semver patterns.
|
|
5
|
+
*/
|
|
6
|
+
export function parseVersion(version) {
|
|
7
|
+
// Match patterns like v1, v1.0, v1.0.0, 1, 1.0, 1.0.0
|
|
8
|
+
const match = version.match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?$/);
|
|
9
|
+
if (!match)
|
|
10
|
+
return null;
|
|
11
|
+
return {
|
|
12
|
+
major: parseInt(match[1], 10),
|
|
13
|
+
minor: match[2] !== undefined ? parseInt(match[2], 10) : 0,
|
|
14
|
+
patch: match[3] !== undefined ? parseInt(match[3], 10) : 0,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Compare two semver versions.
|
|
19
|
+
* Returns: positive if a > b, negative if a < b, 0 if equal
|
|
20
|
+
*/
|
|
21
|
+
export function compareSemver(a, b) {
|
|
22
|
+
if (a.major !== b.major)
|
|
23
|
+
return a.major - b.major;
|
|
24
|
+
if (a.minor !== b.minor)
|
|
25
|
+
return a.minor - b.minor;
|
|
26
|
+
return a.patch - b.patch;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract the version part from a uses string.
|
|
30
|
+
* e.g., "actions/checkout@v6.0.1" -> "v6.0.1"
|
|
31
|
+
* "actions/checkout@abc123" -> "abc123"
|
|
32
|
+
*/
|
|
33
|
+
export function extractVersionFromUses(uses) {
|
|
34
|
+
const match = uses.match(/@(.+)$/);
|
|
35
|
+
return match ? match[1] : null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if a version string looks like a semver (vX, vX.Y, or vX.Y.Z).
|
|
39
|
+
*/
|
|
40
|
+
export function isSemverLike(version) {
|
|
41
|
+
return parseVersion(version) !== null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if a version string is a major-only version (e.g., "v4" not "v4.1.0").
|
|
45
|
+
*/
|
|
46
|
+
export function isMajorOnly(version) {
|
|
47
|
+
// Match patterns like v1 or 1 (without minor/patch)
|
|
48
|
+
return /^v?\d+$/.test(version);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Validate a uses string against a source version.
|
|
52
|
+
* Returns a warning object if there's a potential issue, null otherwise.
|
|
53
|
+
*/
|
|
54
|
+
export function validateActionVersion(uses, sourceVersion) {
|
|
55
|
+
const usedVersion = extractVersionFromUses(uses);
|
|
56
|
+
if (!usedVersion)
|
|
57
|
+
return null;
|
|
58
|
+
// Check if used version is semver-like
|
|
59
|
+
const usedParsed = parseVersion(usedVersion);
|
|
60
|
+
if (!usedParsed) {
|
|
61
|
+
// Non-semver ref (commit SHA, branch name, etc.)
|
|
62
|
+
return {
|
|
63
|
+
uses,
|
|
64
|
+
usedVersion,
|
|
65
|
+
sourceVersion,
|
|
66
|
+
message: `Using non-semver ref "${usedVersion}". Types were generated from ${sourceVersion} and may not match.`,
|
|
67
|
+
type: 'non-semver-ref',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Compare with source version
|
|
71
|
+
const sourceParsed = parseVersion(sourceVersion);
|
|
72
|
+
if (!sourceParsed)
|
|
73
|
+
return null;
|
|
74
|
+
// If using major-only version (e.g., @v4), it resolves to latest, so no warning needed
|
|
75
|
+
// as long as it's the same major version
|
|
76
|
+
if (isMajorOnly(usedVersion) && usedParsed.major === sourceParsed.major) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
// Only compare if same major version
|
|
80
|
+
if (usedParsed.major !== sourceParsed.major) {
|
|
81
|
+
// Different major version - types were generated for a different major
|
|
82
|
+
return {
|
|
83
|
+
uses,
|
|
84
|
+
usedVersion,
|
|
85
|
+
sourceVersion,
|
|
86
|
+
message: `Using ${usedVersion} but types were generated from ${sourceVersion} (different major version). Types may not match.`,
|
|
87
|
+
type: 'older-version',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// Check if used version is older than source
|
|
91
|
+
if (compareSemver(usedParsed, sourceParsed) < 0) {
|
|
92
|
+
return {
|
|
93
|
+
uses,
|
|
94
|
+
usedVersion,
|
|
95
|
+
sourceVersion,
|
|
96
|
+
message: `Pinned to ${usedVersion} which is older than ${sourceVersion} (types source). Some inputs/outputs may not exist in ${usedVersion}.`,
|
|
97
|
+
type: 'older-version',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Log version warnings to console.
|
|
104
|
+
*/
|
|
105
|
+
export function logVersionWarnings(warnings) {
|
|
106
|
+
if (warnings.length === 0)
|
|
107
|
+
return;
|
|
108
|
+
console.log('\n[github-actions-workflow-ts] ⚠️ Version warnings detected:');
|
|
109
|
+
for (const warning of warnings) {
|
|
110
|
+
console.log(` • ${warning.uses}: ${warning.message}`);
|
|
111
|
+
}
|
|
112
|
+
console.log(' To suppress these warnings, set "actionsPackageOutdatedVersionWarnings": false in wac.config.json\n');
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create an action pattern from owner/repo for lookup.
|
|
116
|
+
* e.g., "actions/checkout@v6" -> "actions/checkout@v6"
|
|
117
|
+
*/
|
|
118
|
+
export function getActionPattern(uses) {
|
|
119
|
+
// Extract owner/repo@version pattern
|
|
120
|
+
const match = uses.match(/^([^@]+)@(.+)$/);
|
|
121
|
+
if (!match)
|
|
122
|
+
return uses;
|
|
123
|
+
const [, actionPath, version] = match;
|
|
124
|
+
const versionParsed = parseVersion(version);
|
|
125
|
+
if (versionParsed) {
|
|
126
|
+
// For semver, match against major version pattern
|
|
127
|
+
return `${actionPath}@v${versionParsed.major}`;
|
|
128
|
+
}
|
|
129
|
+
// For non-semver, return as-is (won't match registry)
|
|
130
|
+
return uses;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=version-warning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-warning.js","sourceRoot":"","sources":["../../src/validation/version-warning.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAe;IAEf,sDAAsD;IACtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAA;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC7B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3D,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,CAAkD,EAClD,CAAkD;IAElD,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAA;IACjD,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAA;IACjD,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAA;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,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package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github-actions-workflow-ts/cli",
|
|
3
|
-
"version": "2.0.1",
|
|
3
|
+
"version": "2.2.0-beta.1",
|
|
4
4
|
"description": "CLI to generate GitHub Actions YAML from TypeScript workflow files",
|
|
5
5
|
"author": "Emmanuel N Kyeyune",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"js-yaml": "^4.1.0",
|
|
35
35
|
"tsx": "^4.19.3",
|
|
36
36
|
"yargs": "^17.7.2",
|
|
37
|
-
"@github-actions-workflow-ts/lib": "2.0
|
|
37
|
+
"@github-actions-workflow-ts/lib": "2.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "^29.7.0",
|