@firestartr/cli 2.11.0-snapshot-importer-filter-fix-3 → 2.11.0-snapshot-feature-git-traceability-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/build/index.js
CHANGED
|
@@ -166259,12 +166259,19 @@ function addTraceability(context, src, content) {
|
|
|
166259
166259
|
}
|
|
166260
166260
|
function addTraceabilityStamp(context, content) {
|
|
166261
166261
|
const traceability = context.traceability || {};
|
|
166262
|
-
const
|
|
166263
|
-
|
|
166264
|
-
|
|
166265
|
-
|
|
166266
|
-
|
|
166267
|
-
|
|
166262
|
+
const stampLines = [
|
|
166263
|
+
'---',
|
|
166264
|
+
`# FEATURE_NAME: ${traceability.name}`,
|
|
166265
|
+
`# FEATURE_VERSION: ${traceability.version}`,
|
|
166266
|
+
`# FEATURE_URL: ${traceability.url}`,
|
|
166267
|
+
];
|
|
166268
|
+
if (traceability.sha) {
|
|
166269
|
+
stampLines.push(`# FEATURE_GIT_SHA: "${traceability.sha}"`);
|
|
166270
|
+
}
|
|
166271
|
+
if (Array.isArray(traceability.tags) && traceability.tags.length > 0) {
|
|
166272
|
+
stampLines.push(`# FEATURE_GIT_TAGS: ${JSON.stringify(traceability.tags)}`);
|
|
166273
|
+
}
|
|
166274
|
+
const stamp = `${stampLines.join('\n')}\n\n`;
|
|
166268
166275
|
const output = [];
|
|
166269
166276
|
let replaced = false;
|
|
166270
166277
|
for (const line of content.split(/\n/)) {
|
|
@@ -166433,6 +166440,7 @@ function buildExpectedOutput(config, renderDir) {
|
|
|
166433
166440
|
return {
|
|
166434
166441
|
files,
|
|
166435
166442
|
patches: config.patches || [],
|
|
166443
|
+
traceability: {},
|
|
166436
166444
|
};
|
|
166437
166445
|
}
|
|
166438
166446
|
/* ---------- Context-style API for a render temp dir ---------- */
|
|
@@ -166603,6 +166611,7 @@ function render(featurePath, featureRenderPath, entity, firestartrConfig = {}, f
|
|
|
166603
166611
|
// Not used anymore
|
|
166604
166612
|
// output.unpatches = context.config.unpatches
|
|
166605
166613
|
});
|
|
166614
|
+
output.traceability = context.traceability;
|
|
166606
166615
|
external_fs_default().writeFileSync(external_path_default().join(featureRenderPath, 'config.json'), JSON.stringify(context.config));
|
|
166607
166616
|
// write the output file
|
|
166608
166617
|
const configFile = external_path_default().join(featureRenderPath, 'output.json');
|
|
@@ -166834,6 +166843,7 @@ featureArgs = {}, repo = 'features', owner = 'prefapp') {
|
|
|
166834
166843
|
async function processFeature(featureName, reference, featureOwner, // -> cr
|
|
166835
166844
|
featureArgs = {}, repo = 'features', owner = 'prefapp') {
|
|
166836
166845
|
await downloadFeatureZip(repo, featureName, reference, owner);
|
|
166846
|
+
const commitInfo = await resolveFeatureCommit(owner, repo, reference);
|
|
166837
166847
|
featureArgs['traceability'] = {
|
|
166838
166848
|
version: reference,
|
|
166839
166849
|
owner,
|
|
@@ -166841,9 +166851,44 @@ featureArgs = {}, repo = 'features', owner = 'prefapp') {
|
|
|
166841
166851
|
name: featureName,
|
|
166842
166852
|
ref: reference,
|
|
166843
166853
|
url: `https://github.com/${owner}/${repo}/tree/${reference}/packages/${featureName}`,
|
|
166854
|
+
sha: commitInfo.sha,
|
|
166855
|
+
tags: commitInfo.tags,
|
|
166844
166856
|
};
|
|
166845
166857
|
return renderFeature(featureName, reference, owner, repo, featureOwner, '/tmp', featureArgs);
|
|
166846
166858
|
}
|
|
166859
|
+
async function resolveFeatureCommit(owner, repo, reference) {
|
|
166860
|
+
try {
|
|
166861
|
+
const octokit = await github["default"].getOctokitForOrg(owner, true);
|
|
166862
|
+
// Get the resolved commit SHA
|
|
166863
|
+
const { data: commit } = await octokit.rest.repos.getCommit({
|
|
166864
|
+
owner,
|
|
166865
|
+
repo,
|
|
166866
|
+
ref: reference,
|
|
166867
|
+
});
|
|
166868
|
+
const sha = commit.sha;
|
|
166869
|
+
// Get all tags pointing to this commit. `paginate` is all-or-nothing:
|
|
166870
|
+
// if listing fails, we still return the resolved SHA with an empty tag set.
|
|
166871
|
+
let tags = [];
|
|
166872
|
+
try {
|
|
166873
|
+
const allTags = await octokit.paginate(octokit.rest.repos.listTags, {
|
|
166874
|
+
owner,
|
|
166875
|
+
repo,
|
|
166876
|
+
per_page: 100,
|
|
166877
|
+
});
|
|
166878
|
+
tags = allTags
|
|
166879
|
+
.filter((t) => t.commit?.sha === sha)
|
|
166880
|
+
.map((t) => t.name);
|
|
166881
|
+
}
|
|
166882
|
+
catch (tagError) {
|
|
166883
|
+
features_preparer_src_logger.warn(`[features_preparer] Failed to list tags for ${owner}/${repo}@${reference}: ${tagError instanceof Error ? tagError.message : String(tagError)}`);
|
|
166884
|
+
}
|
|
166885
|
+
return { sha, tags };
|
|
166886
|
+
}
|
|
166887
|
+
catch (error) {
|
|
166888
|
+
features_preparer_src_logger.warn(`[features_preparer] Failed to resolve commit for ${owner}/${repo}@${reference}: ${error instanceof Error ? error.message : String(error)}`);
|
|
166889
|
+
return { sha: '', tags: [] };
|
|
166890
|
+
}
|
|
166891
|
+
}
|
|
166847
166892
|
async function prepareFeature(featureName, version, repo = 'features', owner = 'prefapp') {
|
|
166848
166893
|
await downloadFeatureZip(repo, featureName, version, owner);
|
|
166849
166894
|
}
|
|
@@ -166929,11 +166974,20 @@ async function utils_renderFeature(featureName, featureVersion, featureOutputObj
|
|
|
166929
166974
|
files.push({ path, userManaged, content, targetBranch });
|
|
166930
166975
|
}
|
|
166931
166976
|
const featName = catalog_common/* default.generic.normalizeName */.Z.generic.normalizeName(`${featureName}-${cr.spec.firestartr.tfStateKey}`);
|
|
166977
|
+
const traceability = featureOutputObject.traceability || {};
|
|
166932
166978
|
return {
|
|
166933
166979
|
kind: 'GithubRepositoryFeatureClaim',
|
|
166934
166980
|
version: '1.0.0',
|
|
166935
166981
|
name: featName,
|
|
166936
|
-
feature: {
|
|
166982
|
+
feature: {
|
|
166983
|
+
name: featureName,
|
|
166984
|
+
version: featureVersion,
|
|
166985
|
+
ref: traceability.ref,
|
|
166986
|
+
repo: traceability.repo,
|
|
166987
|
+
sha: traceability.sha,
|
|
166988
|
+
tags: traceability.tags,
|
|
166989
|
+
url: traceability.url,
|
|
166990
|
+
},
|
|
166937
166991
|
firestartr: { tfStateKey: cr.spec.firestartr.tfStateKey },
|
|
166938
166992
|
files,
|
|
166939
166993
|
claimRepoName,
|
|
@@ -170800,13 +170854,29 @@ class FeatureRepoChart extends BaseGithubChart {
|
|
|
170800
170854
|
template() {
|
|
170801
170855
|
const claim = this.get('claim');
|
|
170802
170856
|
const repositoryTarget = this.resolveRepositoryTarget();
|
|
170857
|
+
const annotations = {
|
|
170858
|
+
'firestartr.dev/external-name': claim.name,
|
|
170859
|
+
'firestartr.dev/feature-name': claim.feature.name,
|
|
170860
|
+
};
|
|
170861
|
+
if (claim.feature.sha) {
|
|
170862
|
+
annotations['firestartr.dev/feature-git-sha'] = claim.feature.sha;
|
|
170863
|
+
}
|
|
170864
|
+
if (claim.feature.tags?.length) {
|
|
170865
|
+
annotations['firestartr.dev/feature-git-tags'] = JSON.stringify(claim.feature.tags);
|
|
170866
|
+
}
|
|
170867
|
+
if (claim.feature.url) {
|
|
170868
|
+
annotations['firestartr.dev/feature-url'] = claim.feature.url;
|
|
170869
|
+
}
|
|
170870
|
+
if (claim.feature.ref) {
|
|
170871
|
+
annotations['firestartr.dev/feature-ref'] = claim.feature.ref;
|
|
170872
|
+
}
|
|
170873
|
+
if (claim.feature.repo) {
|
|
170874
|
+
annotations['firestartr.dev/feature-repo'] = claim.feature.repo;
|
|
170875
|
+
}
|
|
170803
170876
|
const cr = {
|
|
170804
170877
|
metadata: {
|
|
170805
170878
|
name: claim.name,
|
|
170806
|
-
annotations
|
|
170807
|
-
'firestartr.dev/external-name': claim.name,
|
|
170808
|
-
'firestartr.dev/feature-name': claim.feature.name,
|
|
170809
|
-
},
|
|
170879
|
+
annotations,
|
|
170810
170880
|
},
|
|
170811
170881
|
spec: {
|
|
170812
170882
|
context: claim.context,
|
|
@@ -170826,7 +170896,7 @@ class FeatureRepoChart extends BaseGithubChart {
|
|
|
170826
170896
|
},
|
|
170827
170897
|
},
|
|
170828
170898
|
};
|
|
170829
|
-
const
|
|
170899
|
+
const repoAnnotations = this.getAnnotationsFromRepo(this.get('repoCr'), [
|
|
170830
170900
|
'claim-ref',
|
|
170831
170901
|
'revision',
|
|
170832
170902
|
'sync-enabled',
|
|
@@ -170834,7 +170904,7 @@ class FeatureRepoChart extends BaseGithubChart {
|
|
|
170834
170904
|
]);
|
|
170835
170905
|
cr.metadata.annotations = {
|
|
170836
170906
|
...cr.metadata.annotations,
|
|
170837
|
-
...
|
|
170907
|
+
...repoAnnotations,
|
|
170838
170908
|
};
|
|
170839
170909
|
// We do this to remove undefined variables from the template
|
|
170840
170910
|
const crTemplate = JSON.parse(JSON.stringify(cr, null, 2));
|
|
@@ -713893,7 +713963,7 @@ const crsStatusSubcommand = {
|
|
|
713893
713963
|
};
|
|
713894
713964
|
|
|
713895
713965
|
;// CONCATENATED MODULE: ./package.json
|
|
713896
|
-
const package_namespaceObject = JSON.parse('{"i8":"2.11.0-snapshot-
|
|
713966
|
+
const package_namespaceObject = JSON.parse('{"i8":"2.11.0-snapshot-feature-git-traceability-1"}');
|
|
713897
713967
|
;// CONCATENATED MODULE: ../../package.json
|
|
713898
713968
|
const package_namespaceObject_1 = {"i8":"2.10.0"};
|
|
713899
713969
|
// EXTERNAL MODULE: ../../node_modules/semver/index.js
|
|
@@ -16,6 +16,9 @@ export interface IGithubRepositoryFeatureClaim extends IClaim {
|
|
|
16
16
|
version?: string;
|
|
17
17
|
ref?: string;
|
|
18
18
|
repo?: string;
|
|
19
|
+
sha?: string;
|
|
20
|
+
tags?: string[];
|
|
21
|
+
url?: string;
|
|
19
22
|
};
|
|
20
23
|
repositoryTarget: FirestartrGithubRepositoryFeatureSpecRepositoryTarget;
|
|
21
24
|
files: Array<IGithubRepositoryFeatureFileClaim>;
|
|
@@ -2,5 +2,9 @@ export declare function getFeatureConfigFromRef(featureName: string, featureRef:
|
|
|
2
2
|
featureArgs?: any, repo?: string, owner?: string): Promise<any>;
|
|
3
3
|
export declare function getFeatureConfig(featureName: string, version: string, featureOwner: any, // -> cr
|
|
4
4
|
featureArgs?: any, repo?: string, owner?: string): Promise<any>;
|
|
5
|
+
export declare function resolveFeatureCommit(owner: string, repo: string, reference: string): Promise<{
|
|
6
|
+
sha: string;
|
|
7
|
+
tags: string[];
|
|
8
|
+
}>;
|
|
5
9
|
export declare function prepareFeature(featureName: string, version: string, repo?: string, owner?: string): Promise<void>;
|
|
6
10
|
export declare function downloadFeatureZip(repo: string, featureName: string, reference: string, owner?: string): Promise<string>;
|
|
@@ -19,9 +19,20 @@ export interface ExpectedFile {
|
|
|
19
19
|
targetBranch: string;
|
|
20
20
|
userManaged: boolean;
|
|
21
21
|
}
|
|
22
|
+
export interface Traceability {
|
|
23
|
+
owner?: string;
|
|
24
|
+
repo?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
version?: string;
|
|
27
|
+
ref?: string;
|
|
28
|
+
url?: string;
|
|
29
|
+
sha?: string;
|
|
30
|
+
tags?: string[];
|
|
31
|
+
}
|
|
22
32
|
export interface ExpectedOutput {
|
|
23
33
|
files: ExpectedFile[];
|
|
24
34
|
patches: unknown[];
|
|
35
|
+
traceability?: Traceability;
|
|
25
36
|
}
|
|
26
37
|
export interface RenderTest {
|
|
27
38
|
name: string;
|