@kosdev-code/kos-codegen-core 0.1.0-next.792 → 0.1.0-next.796
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/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +395 -0
- package/index.js.map +1 -1
- package/index.mjs +395 -0
- package/index.mjs.map +1 -1
- package/lib/generators/ci-sync.d.ts +26 -0
- package/lib/generators/ci-sync.d.ts.map +1 -0
- package/lib/generators/generate-polyglot-workspace.d.ts +29 -0
- package/lib/generators/generate-polyglot-workspace.d.ts.map +1 -0
- package/lib/generators/index.d.ts +5 -0
- package/lib/generators/index.d.ts.map +1 -1
- package/lib/generators/java-workspace.d.ts +33 -0
- package/lib/generators/java-workspace.d.ts.map +1 -0
- package/lib/generators/kab-targets.d.ts +40 -0
- package/lib/generators/kab-targets.d.ts.map +1 -0
- package/lib/generators/release-version-script.d.ts +10 -0
- package/lib/generators/release-version-script.d.ts.map +1 -0
- package/package.json +2 -2
- package/templates/polyglot-workspace/build/build-java.sh.template +18 -0
- package/templates/polyglot-workspace/build/build-release.sh.template +11 -0
- package/templates/polyglot-workspace/build/build-ui.sh.template +16 -0
- package/templates/polyglot-workspace/build/docker-build.sh.template +49 -0
- package/templates/polyglot-workspace/build/jdkw.sh.template +93 -0
- package/templates/polyglot-workspace/build/nodew.sh.template +73 -0
- package/templates/polyglot-workspace/build/release_version_prebuild.sh.template +31 -0
- package/templates/polyglot-workspace/github/build-java.json.template +6 -0
- package/templates/polyglot-workspace/github/build-release.json.template +14 -0
- package/templates/polyglot-workspace/github/build-ui.json.template +13 -0
- package/templates/polyglot-workspace/github/workflows/develop-java.yml.template +35 -0
- package/templates/polyglot-workspace/github/workflows/develop-ui.yml.template +38 -0
- package/templates/polyglot-workspace/github/workflows/release.yml.template +37 -0
- package/templates/polyglot-workspace/java/README.md.template +36 -0
- package/templates/polyglot-workspace/root/.gitignore.template +5 -0
- package/templates/polyglot-workspace/root/README.md.template +69 -0
package/index.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export { setCodegenLogger, getCodegenLogger } from './lib/logger';
|
|
|
12
12
|
export { getCurrentDirectoryName, getProject, getKosProjectConfiguration, getKosModelConfiguration, getKosModelConfigProp, addKosModelConfiguration, } from './lib/kos-config';
|
|
13
13
|
export type { KosModelConfiguration, KosProjectConfiguration, } from './lib/kos-config';
|
|
14
14
|
export { getTemplateDir } from './lib/template-resolver';
|
|
15
|
-
export { generateSplashProject, generateInit, normalizeOptions, appendBarrelExport, updateModelIndex, generateHook, generateContext, generateContainerModel, generateCompanionModel, generateModel, addFutureToModel, addContainerSupportToModel, addModelEffectToModel, addDependencyToModel, addChildToModel, addTopicHandlerToModel, addConfigPropertyToModel, addServiceRequestToModel, addPropertyToModel, addComputedToModel, validateModel, describeModel, lookupSdkType, resolveModelFilePath, generateComponent, PLUGIN_TYPES, CONTRIBUTION_TYPE_MAP, LOCALIZED_PLUGIN_TYPES, KOS_JSON_PATHS, PluginHandlerFactory, BasePluginHandler, KosConfigBuilder, ValidationError, } from './lib/generators';
|
|
16
|
-
export type { SplashProjectOptions, KosInitOptions, KosBaseGeneratorOptions, NormalizedOptions, HookOptions, ContextOptions, ContainerModelOptions, CompanionModelOptions, ModelOptions, GenerateModelParams, AddFutureToModelOptions, NormalizedAddFutureToModelOptions, AddContainerSupportOptions, AddModelEffectOptions, AddDependencyOptions, AddChildOptions, ChildShape, AddTopicHandlerOptions, AddConfigPropertyOptions, AddServiceRequestOptions, AddPropertyOptions, AddComputedOptions, ValidateModelOptions, ValidationFinding, ValidationResult, DescribeModelOptions, DescribedMember, ModelDescription, ModelFileQuery, LookupSdkTypeOptions, SdkSymbolDeclaration, SdkTypeLookupResult, ComponentOptions, NormalizedComponentOptions, PluginConfiguration, PluginContribution, ExperienceConfig, PluginType, PluginHandler, } from './lib/generators';
|
|
15
|
+
export { generateSplashProject, generateInit, generatePolyglotWorkspace, ensureJavaAggregatorPom, finalizeArchetypeModule, addJavaArtifactToManifests, syncCiManifests, discoverUiArtifacts, discoverJavaArtifacts, buildKabTargets, UPDATE_RELEASE_VERSION_SCRIPT, UPDATE_RELEASE_VERSION_SCRIPT_PATH, normalizeOptions, appendBarrelExport, updateModelIndex, generateHook, generateContext, generateContainerModel, generateCompanionModel, generateModel, addFutureToModel, addContainerSupportToModel, addModelEffectToModel, addDependencyToModel, addChildToModel, addTopicHandlerToModel, addConfigPropertyToModel, addServiceRequestToModel, addPropertyToModel, addComputedToModel, validateModel, describeModel, lookupSdkType, resolveModelFilePath, generateComponent, PLUGIN_TYPES, CONTRIBUTION_TYPE_MAP, LOCALIZED_PLUGIN_TYPES, KOS_JSON_PATHS, PluginHandlerFactory, BasePluginHandler, KosConfigBuilder, ValidationError, } from './lib/generators';
|
|
16
|
+
export type { SplashProjectOptions, KosInitOptions, KabTargetsOptions, KabTargetDefinition, PolyglotWorkspaceOptions, PolyglotWorkspaceResult, EnsureJavaAggregatorOptions, FinalizeArchetypeModuleOptions, AddJavaArtifactOptions, CiSyncOptions, CiSyncResult, CiSyncManifestResult, DiscoveredArtifact, KosBaseGeneratorOptions, NormalizedOptions, HookOptions, ContextOptions, ContainerModelOptions, CompanionModelOptions, ModelOptions, GenerateModelParams, AddFutureToModelOptions, NormalizedAddFutureToModelOptions, AddContainerSupportOptions, AddModelEffectOptions, AddDependencyOptions, AddChildOptions, ChildShape, AddTopicHandlerOptions, AddConfigPropertyOptions, AddServiceRequestOptions, AddPropertyOptions, AddComputedOptions, ValidateModelOptions, ValidationFinding, ValidationResult, DescribeModelOptions, DescribedMember, ModelDescription, ModelFileQuery, LookupSdkTypeOptions, SdkSymbolDeclaration, SdkTypeLookupResult, ComponentOptions, NormalizedComponentOptions, PluginConfiguration, PluginContribution, ExperienceConfig, PluginType, PluginHandler, } from './lib/generators';
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","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AsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,iCAAiC,EACjC,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,aAAa,GACd,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/kos-codegen-core/src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGlE,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,GACX,MAAM,yBAAyB,C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GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,iCAAiC,EACjC,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,aAAa,GACd,MAAM,kBAAkB,CAAC"}
|
package/index.js
CHANGED
|
@@ -537,6 +537,294 @@ function generateInit(codegenFs, options) {
|
|
|
537
537
|
};
|
|
538
538
|
writeJson(codegenFs, "nx.json", nxConfig);
|
|
539
539
|
}
|
|
540
|
+
const BUILD_SCRIPTS = [
|
|
541
|
+
"build/build-ui.sh",
|
|
542
|
+
"build/build-java.sh",
|
|
543
|
+
"build/build-release.sh",
|
|
544
|
+
"build/release_version_prebuild.sh",
|
|
545
|
+
"build/docker-build.sh"
|
|
546
|
+
];
|
|
547
|
+
function generatePolyglotWorkspace(codegenFs, templateDir, options) {
|
|
548
|
+
const normalized = normalizeAllValues({ name: options.name });
|
|
549
|
+
const vars = {
|
|
550
|
+
...normalized,
|
|
551
|
+
keyset: options.keyset || "prod.kos",
|
|
552
|
+
appUiName: `${normalized.nameDashCase}-ui`,
|
|
553
|
+
nodeVersion: options.nodeVersion || process.version.replace(/^v/, ""),
|
|
554
|
+
jdkMajor: options.jdkMajor || "17",
|
|
555
|
+
mavenVersion: options.mavenVersion || "3.9.9"
|
|
556
|
+
};
|
|
557
|
+
generateFilesFromTemplates(
|
|
558
|
+
codegenFs,
|
|
559
|
+
path__namespace.join(templateDir, "root"),
|
|
560
|
+
".",
|
|
561
|
+
vars
|
|
562
|
+
);
|
|
563
|
+
generateFilesFromTemplates(
|
|
564
|
+
codegenFs,
|
|
565
|
+
path__namespace.join(templateDir, "build"),
|
|
566
|
+
"build",
|
|
567
|
+
vars
|
|
568
|
+
);
|
|
569
|
+
generateFilesFromTemplates(
|
|
570
|
+
codegenFs,
|
|
571
|
+
path__namespace.join(templateDir, "github"),
|
|
572
|
+
".github",
|
|
573
|
+
vars
|
|
574
|
+
);
|
|
575
|
+
generateFilesFromTemplates(
|
|
576
|
+
codegenFs,
|
|
577
|
+
path__namespace.join(templateDir, "java"),
|
|
578
|
+
"java",
|
|
579
|
+
vars
|
|
580
|
+
);
|
|
581
|
+
return { executablePaths: [...BUILD_SCRIPTS] };
|
|
582
|
+
}
|
|
583
|
+
const UI_PROJECT_DIRS = [
|
|
584
|
+
"apps",
|
|
585
|
+
"libs",
|
|
586
|
+
"plugins",
|
|
587
|
+
"splash",
|
|
588
|
+
"themes",
|
|
589
|
+
"content",
|
|
590
|
+
"translations"
|
|
591
|
+
];
|
|
592
|
+
function joinArtifactPath(outputPath, fileName) {
|
|
593
|
+
return `${outputPath.replace(/\/+$/, "")}/${fileName}`;
|
|
594
|
+
}
|
|
595
|
+
function discoverUiArtifacts(codegenFs) {
|
|
596
|
+
const artifacts = [];
|
|
597
|
+
for (const dir of UI_PROJECT_DIRS) {
|
|
598
|
+
for (const file of codegenFs.listFiles(`ui/${dir}`)) {
|
|
599
|
+
if (!file.endsWith("project.json")) continue;
|
|
600
|
+
const raw = codegenFs.read(file);
|
|
601
|
+
if (raw === null) continue;
|
|
602
|
+
let project;
|
|
603
|
+
try {
|
|
604
|
+
project = JSON.parse(raw);
|
|
605
|
+
} catch {
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
const name = project.name;
|
|
609
|
+
if (!name) continue;
|
|
610
|
+
const kabOptions = project.targets?.kab?.options;
|
|
611
|
+
if (kabOptions?.outputPath && kabOptions?.kabName) {
|
|
612
|
+
artifacts.push({
|
|
613
|
+
id: name,
|
|
614
|
+
filename: `ui/${joinArtifactPath(kabOptions.outputPath, kabOptions.kabName)}`
|
|
615
|
+
});
|
|
616
|
+
} else if (project.targets?.splash) {
|
|
617
|
+
artifacts.push({
|
|
618
|
+
id: name,
|
|
619
|
+
filename: `ui/dist/archives/packages/${name}/${name}.kab`,
|
|
620
|
+
layer: 1
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
for (const file of codegenFs.listFiles("ui/external")) {
|
|
626
|
+
if (!file.endsWith(".kab")) continue;
|
|
627
|
+
const base = file.slice(file.lastIndexOf("/") + 1, -".kab".length);
|
|
628
|
+
artifacts.push({ id: base, filename: file });
|
|
629
|
+
}
|
|
630
|
+
return artifacts;
|
|
631
|
+
}
|
|
632
|
+
function discoverJavaArtifacts(codegenFs) {
|
|
633
|
+
const aggregator = codegenFs.read("java/pom.xml");
|
|
634
|
+
if (aggregator === null) return [];
|
|
635
|
+
const artifacts = [];
|
|
636
|
+
for (const match of aggregator.matchAll(/<module>([^<]+)<\/module>/g)) {
|
|
637
|
+
const moduleDir = match[1];
|
|
638
|
+
const pom = codegenFs.read(`java/${moduleDir}/pom.xml`);
|
|
639
|
+
if (pom === null || !pom.includes("kos-kab-maven-plugin")) continue;
|
|
640
|
+
const withoutParent = pom.replace(/<parent>[\s\S]*?<\/parent>/, "");
|
|
641
|
+
const artifactId = withoutParent.match(
|
|
642
|
+
/<artifactId>([^<]+)<\/artifactId>/
|
|
643
|
+
)?.[1];
|
|
644
|
+
if (!artifactId) continue;
|
|
645
|
+
artifacts.push({
|
|
646
|
+
id: moduleDir,
|
|
647
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
648
|
+
filename: `java/${moduleDir}/target/${artifactId}-\${KOS_STD_VERSION_REGEX}.kab`
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
return artifacts;
|
|
652
|
+
}
|
|
653
|
+
function syncManifest(codegenFs, manifestPath, discovered, prune) {
|
|
654
|
+
const raw = codegenFs.read(manifestPath);
|
|
655
|
+
if (raw === null) return null;
|
|
656
|
+
const manifest = JSON.parse(raw);
|
|
657
|
+
const existing = manifest.artifacts ?? [];
|
|
658
|
+
const byFilename = new Map(discovered.map((d) => [d.filename, d]));
|
|
659
|
+
const kept = [];
|
|
660
|
+
const stale = [];
|
|
661
|
+
const pruned = [];
|
|
662
|
+
for (const entry of existing) {
|
|
663
|
+
if (byFilename.has(entry.filename)) {
|
|
664
|
+
kept.push(entry);
|
|
665
|
+
byFilename.delete(entry.filename);
|
|
666
|
+
} else if (prune) {
|
|
667
|
+
pruned.push(entry.id ?? entry.filename);
|
|
668
|
+
} else {
|
|
669
|
+
kept.push(entry);
|
|
670
|
+
stale.push(entry.id ?? entry.filename);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
const added = [];
|
|
674
|
+
for (const artifact of byFilename.values()) {
|
|
675
|
+
kept.push({
|
|
676
|
+
id: artifact.id,
|
|
677
|
+
filename: artifact.filename,
|
|
678
|
+
artifactstore: "kos-cdn",
|
|
679
|
+
marketplace: 1,
|
|
680
|
+
...artifact.layer !== void 0 ? { layer: artifact.layer } : {}
|
|
681
|
+
});
|
|
682
|
+
added.push(artifact.id);
|
|
683
|
+
}
|
|
684
|
+
if (added.length > 0 || pruned.length > 0) {
|
|
685
|
+
manifest.artifacts = kept;
|
|
686
|
+
codegenFs.write(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
687
|
+
}
|
|
688
|
+
return { added, stale, pruned };
|
|
689
|
+
}
|
|
690
|
+
function syncCiManifests(codegenFs, options = {}) {
|
|
691
|
+
const prune = options.prune ?? false;
|
|
692
|
+
const ui = discoverUiArtifacts(codegenFs);
|
|
693
|
+
const java = discoverJavaArtifacts(codegenFs);
|
|
694
|
+
const manifests = {};
|
|
695
|
+
const plan = [
|
|
696
|
+
[".github/build-ui.json", ui],
|
|
697
|
+
[".github/build-java.json", java],
|
|
698
|
+
[".github/build-release.json", [...ui, ...java]]
|
|
699
|
+
];
|
|
700
|
+
for (const [manifestPath, discovered] of plan) {
|
|
701
|
+
const result = syncManifest(codegenFs, manifestPath, discovered, prune);
|
|
702
|
+
if (result) {
|
|
703
|
+
manifests[manifestPath] = result;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return { manifests, discovered: { ui, java } };
|
|
707
|
+
}
|
|
708
|
+
function ensureJavaAggregatorPom(codegenFs, options) {
|
|
709
|
+
const pomPath = "java/pom.xml";
|
|
710
|
+
const existing = codegenFs.read(pomPath);
|
|
711
|
+
if (existing === null) {
|
|
712
|
+
codegenFs.write(
|
|
713
|
+
pomPath,
|
|
714
|
+
`<?xml version="1.0" encoding="UTF-8"?>
|
|
715
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
716
|
+
<modelVersion>4.0.0</modelVersion>
|
|
717
|
+
<groupId>${options.groupId}</groupId>
|
|
718
|
+
<artifactId>${options.artifactId}</artifactId>
|
|
719
|
+
<version>0.0.0-SNAPSHOT</version>
|
|
720
|
+
<packaging>pom</packaging>
|
|
721
|
+
<modules>
|
|
722
|
+
<module>${options.moduleName}</module>
|
|
723
|
+
</modules>
|
|
724
|
+
</project>
|
|
725
|
+
`
|
|
726
|
+
);
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
if (existing.includes(`<module>${options.moduleName}</module>`)) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
codegenFs.write(
|
|
733
|
+
pomPath,
|
|
734
|
+
existing.replace(
|
|
735
|
+
"</modules>",
|
|
736
|
+
` <module>${options.moduleName}</module>
|
|
737
|
+
</modules>`
|
|
738
|
+
)
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
function finalizeArchetypeModule(codegenFs, options) {
|
|
742
|
+
const { moduleName, kosVersion, kabPluginVersion, apiInfoVersion } = options;
|
|
743
|
+
const notes = [];
|
|
744
|
+
const pomPath = `java/${moduleName}/pom.xml`;
|
|
745
|
+
let pom = codegenFs.read(pomPath);
|
|
746
|
+
if (pom === null) {
|
|
747
|
+
throw new Error(`Generated module pom not found: ${pomPath}`);
|
|
748
|
+
}
|
|
749
|
+
if (pom.includes("<kos.version>0.0.0-SNAPSHOT</kos.version>")) {
|
|
750
|
+
if (kosVersion) {
|
|
751
|
+
pom = pom.replace(
|
|
752
|
+
"<kos.version>0.0.0-SNAPSHOT</kos.version>",
|
|
753
|
+
`<kos.version>${kosVersion}</kos.version>`
|
|
754
|
+
);
|
|
755
|
+
} else {
|
|
756
|
+
notes.push(
|
|
757
|
+
"kos.version is 0.0.0-SNAPSHOT — set it to a released kos-bom version before building"
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (pom.includes("${kos-kab-maven-plugin.version}") && !pom.includes("<kos-kab-maven-plugin.version>")) {
|
|
762
|
+
if (kabPluginVersion) {
|
|
763
|
+
pom = pom.replace(
|
|
764
|
+
/(<kos\.version>[^<]*<\/kos\.version>)/,
|
|
765
|
+
`$1
|
|
766
|
+
<kos-kab-maven-plugin.version>${kabPluginVersion}</kos-kab-maven-plugin.version>`
|
|
767
|
+
);
|
|
768
|
+
} else {
|
|
769
|
+
notes.push(
|
|
770
|
+
"the ${kos-kab-maven-plugin.version} property is referenced but undefined — add it before building"
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
const unversionedApiInfo = /<artifactId>api-info<\/artifactId>(\s*)<\/dependency>/;
|
|
775
|
+
if (unversionedApiInfo.test(pom)) {
|
|
776
|
+
if (apiInfoVersion) {
|
|
777
|
+
pom = pom.replace(
|
|
778
|
+
unversionedApiInfo,
|
|
779
|
+
`<artifactId>api-info</artifactId>$1 <version>${apiInfoVersion}</version>$1</dependency>`
|
|
780
|
+
);
|
|
781
|
+
} else {
|
|
782
|
+
notes.push(
|
|
783
|
+
"api-info has no version and is not managed by the kos-bom — add one before building"
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
codegenFs.write(pomPath, pom);
|
|
788
|
+
const githubDir = `java/${moduleName}/github`;
|
|
789
|
+
if (codegenFs.exists(githubDir)) {
|
|
790
|
+
for (const file of codegenFs.listFiles(githubDir)) {
|
|
791
|
+
codegenFs.delete(file);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
const gitignore = codegenFs.read(`java/${moduleName}/gitignore`);
|
|
795
|
+
if (gitignore !== null) {
|
|
796
|
+
codegenFs.write(`java/${moduleName}/.gitignore`, gitignore);
|
|
797
|
+
codegenFs.delete(`java/${moduleName}/gitignore`);
|
|
798
|
+
}
|
|
799
|
+
return notes;
|
|
800
|
+
}
|
|
801
|
+
function addJavaArtifactToManifests(codegenFs, options) {
|
|
802
|
+
const { moduleName } = options;
|
|
803
|
+
for (const manifestPath of [
|
|
804
|
+
".github/build-java.json",
|
|
805
|
+
".github/build-release.json"
|
|
806
|
+
]) {
|
|
807
|
+
const raw = codegenFs.read(manifestPath);
|
|
808
|
+
if (raw === null) {
|
|
809
|
+
continue;
|
|
810
|
+
}
|
|
811
|
+
const manifest = JSON.parse(raw);
|
|
812
|
+
manifest.artifacts = manifest.artifacts ?? [];
|
|
813
|
+
if (manifest.artifacts.some(
|
|
814
|
+
(artifact) => artifact.id === moduleName
|
|
815
|
+
)) {
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
manifest.artifacts.push({
|
|
819
|
+
id: moduleName,
|
|
820
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
821
|
+
filename: `java/${moduleName}/target/${moduleName}-\${KOS_STD_VERSION_REGEX}.kab`,
|
|
822
|
+
artifactstore: "kos-cdn",
|
|
823
|
+
marketplace: 1
|
|
824
|
+
});
|
|
825
|
+
codegenFs.write(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
826
|
+
}
|
|
827
|
+
}
|
|
540
828
|
function normalizeOptions(codegenFs, options, projects) {
|
|
541
829
|
const toNormalize = {
|
|
542
830
|
name: options.name
|
|
@@ -582,6 +870,103 @@ function normalizeOptions(codegenFs, options, projects) {
|
|
|
582
870
|
template: ""
|
|
583
871
|
};
|
|
584
872
|
}
|
|
873
|
+
const UPDATE_RELEASE_VERSION_SCRIPT_PATH = "tools/scripts/update-release-version.mjs";
|
|
874
|
+
function buildKabTargets(options) {
|
|
875
|
+
const {
|
|
876
|
+
name,
|
|
877
|
+
archiveDir = "packages",
|
|
878
|
+
descriptorDir,
|
|
879
|
+
buildTarget = "build"
|
|
880
|
+
} = options;
|
|
881
|
+
const outputPath = `dist/archives/${archiveDir}/${name}/`;
|
|
882
|
+
const targets = {
|
|
883
|
+
kab: {
|
|
884
|
+
command: `node tools/scripts/kabtool.mjs build ${name} && node tools/scripts/kabtool.mjs list ${name} `,
|
|
885
|
+
options: {
|
|
886
|
+
outputPath,
|
|
887
|
+
zipName: "ui.zip",
|
|
888
|
+
kabName: `${name}.kab`
|
|
889
|
+
},
|
|
890
|
+
dependsOn: ["zip"]
|
|
891
|
+
},
|
|
892
|
+
zip: {
|
|
893
|
+
command: `node tools/scripts/archiver.js ${name}`,
|
|
894
|
+
options: {
|
|
895
|
+
outputPath,
|
|
896
|
+
zipName: "ui.zip"
|
|
897
|
+
},
|
|
898
|
+
dependsOn: descriptorDir ? [buildTarget, "descriptor"] : [buildTarget]
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
if (descriptorDir) {
|
|
902
|
+
targets.descriptor = {
|
|
903
|
+
command: `node tools/scripts/descriptor.mjs ${name}`,
|
|
904
|
+
options: {
|
|
905
|
+
outputPath: `dist/${descriptorDir}`,
|
|
906
|
+
fileName: "descriptor.json"
|
|
907
|
+
},
|
|
908
|
+
dependsOn: ["build"]
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
targets.version = {
|
|
912
|
+
command: `node ${UPDATE_RELEASE_VERSION_SCRIPT_PATH} ${name} {args.ver}`,
|
|
913
|
+
options: {},
|
|
914
|
+
dependsOn: []
|
|
915
|
+
};
|
|
916
|
+
return targets;
|
|
917
|
+
}
|
|
918
|
+
const UPDATE_RELEASE_VERSION_SCRIPT = `import devkit from "@nx/devkit";
|
|
919
|
+
import { resolve } from "path";
|
|
920
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
921
|
+
import prettier from "prettier";
|
|
922
|
+
|
|
923
|
+
// KOS artifact versioning: stamps the project's .kos.json "version" field
|
|
924
|
+
// (which kabtool bakes into the KAB). Never touches package.json.
|
|
925
|
+
// Driven by tag-based releases:
|
|
926
|
+
// nx run-many --target=version --args=--ver=$KOSBUILD_VERSION
|
|
927
|
+
|
|
928
|
+
const { readCachedProjectGraph } = devkit;
|
|
929
|
+
const [, , name, versionArg] = process.argv;
|
|
930
|
+
|
|
931
|
+
// "{args.ver}" arrives literally when the target runs without --args=--ver=<v>;
|
|
932
|
+
// treat that (or a missing arg) as "report current version, change nothing".
|
|
933
|
+
const version =
|
|
934
|
+
versionArg && !versionArg.startsWith("{args") ? versionArg : undefined;
|
|
935
|
+
|
|
936
|
+
if (!name) {
|
|
937
|
+
console.error("usage: update-release-version.mjs <project> <version>");
|
|
938
|
+
process.exit(1);
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
const graph = readCachedProjectGraph();
|
|
942
|
+
const project = graph.nodes[name];
|
|
943
|
+
if (!project) {
|
|
944
|
+
console.error("Unknown project: " + name);
|
|
945
|
+
process.exit(1);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
const kosJsonPath = resolve(process.cwd(), project.data.root, ".kos.json");
|
|
949
|
+
let kosJson;
|
|
950
|
+
try {
|
|
951
|
+
kosJson = JSON.parse(readFileSync(kosJsonPath, "utf8"));
|
|
952
|
+
} catch {
|
|
953
|
+
console.error("Missing or invalid .kos.json: " + kosJsonPath);
|
|
954
|
+
process.exit(1);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
if (!version) {
|
|
958
|
+
console.log(name + ": " + kosJson.version + " (no --ver given; unchanged)");
|
|
959
|
+
process.exit(0);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
const prettierOptions = await prettier.resolveConfig(kosJsonPath);
|
|
963
|
+
const output = await prettier.format(
|
|
964
|
+
JSON.stringify({ ...kosJson, version }, null, 2),
|
|
965
|
+
{ ...prettierOptions, parser: "json" }
|
|
966
|
+
);
|
|
967
|
+
writeFileSync(kosJsonPath, output);
|
|
968
|
+
console.log(name + ": version -> " + version);
|
|
969
|
+
`;
|
|
585
970
|
function appendBarrelExport(codegenFs, indexPath, exportPath) {
|
|
586
971
|
const exportLine = `export * from '${exportPath}'`;
|
|
587
972
|
const content = codegenFs.read(indexPath) ?? "";
|
|
@@ -3006,6 +3391,8 @@ exports.LOCALIZED_PLUGIN_TYPES = LOCALIZED_PLUGIN_TYPES;
|
|
|
3006
3391
|
exports.PLUGIN_TYPES = PLUGIN_TYPES;
|
|
3007
3392
|
exports.PluginHandlerFactory = PluginHandlerFactory;
|
|
3008
3393
|
exports.TrackingFileSystem = TrackingFileSystem;
|
|
3394
|
+
exports.UPDATE_RELEASE_VERSION_SCRIPT = UPDATE_RELEASE_VERSION_SCRIPT;
|
|
3395
|
+
exports.UPDATE_RELEASE_VERSION_SCRIPT_PATH = UPDATE_RELEASE_VERSION_SCRIPT_PATH;
|
|
3009
3396
|
exports.ValidationError = ValidationError;
|
|
3010
3397
|
exports.addChildToModel = addChildToModel;
|
|
3011
3398
|
exports.addComputedToModel = addComputedToModel;
|
|
@@ -3013,17 +3400,23 @@ exports.addConfigPropertyToModel = addConfigPropertyToModel;
|
|
|
3013
3400
|
exports.addContainerSupportToModel = addContainerSupportToModel;
|
|
3014
3401
|
exports.addDependencyToModel = addDependencyToModel;
|
|
3015
3402
|
exports.addFutureToModel = addFutureToModel;
|
|
3403
|
+
exports.addJavaArtifactToManifests = addJavaArtifactToManifests;
|
|
3016
3404
|
exports.addKosModelConfiguration = addKosModelConfiguration;
|
|
3017
3405
|
exports.addModelEffectToModel = addModelEffectToModel;
|
|
3018
3406
|
exports.addPropertyToModel = addPropertyToModel;
|
|
3019
3407
|
exports.addServiceRequestToModel = addServiceRequestToModel;
|
|
3020
3408
|
exports.addTopicHandlerToModel = addTopicHandlerToModel;
|
|
3021
3409
|
exports.appendBarrelExport = appendBarrelExport;
|
|
3410
|
+
exports.buildKabTargets = buildKabTargets;
|
|
3022
3411
|
exports.camelCase = camelCase;
|
|
3023
3412
|
exports.constantCase = constantCase;
|
|
3024
3413
|
exports.dashCase = dashCase;
|
|
3025
3414
|
exports.describeModel = describeModel;
|
|
3415
|
+
exports.discoverJavaArtifacts = discoverJavaArtifacts;
|
|
3026
3416
|
exports.discoverProjects = discoverProjects;
|
|
3417
|
+
exports.discoverUiArtifacts = discoverUiArtifacts;
|
|
3418
|
+
exports.ensureJavaAggregatorPom = ensureJavaAggregatorPom;
|
|
3419
|
+
exports.finalizeArchetypeModule = finalizeArchetypeModule;
|
|
3027
3420
|
exports.findProjectByName = findProjectByName;
|
|
3028
3421
|
exports.findProjectForPath = findProjectForPath;
|
|
3029
3422
|
exports.formatFiles = formatFiles;
|
|
@@ -3035,6 +3428,7 @@ exports.generateFilesFromTemplates = generateFilesFromTemplates;
|
|
|
3035
3428
|
exports.generateHook = generateHook;
|
|
3036
3429
|
exports.generateInit = generateInit;
|
|
3037
3430
|
exports.generateModel = generateModel;
|
|
3431
|
+
exports.generatePolyglotWorkspace = generatePolyglotWorkspace;
|
|
3038
3432
|
exports.generateSplashProject = generateSplashProject;
|
|
3039
3433
|
exports.getCodegenLogger = getCodegenLogger;
|
|
3040
3434
|
exports.getCurrentDirectoryName = getCurrentDirectoryName;
|
|
@@ -3052,6 +3446,7 @@ exports.readJson = readJson;
|
|
|
3052
3446
|
exports.readNxJson = readNxJson;
|
|
3053
3447
|
exports.resolveModelFilePath = resolveModelFilePath;
|
|
3054
3448
|
exports.setCodegenLogger = setCodegenLogger;
|
|
3449
|
+
exports.syncCiManifests = syncCiManifests;
|
|
3055
3450
|
exports.updateJson = updateJson;
|
|
3056
3451
|
exports.updateModelIndex = updateModelIndex;
|
|
3057
3452
|
exports.validateModel = validateModel;
|