@kosdev-code/kos-codegen-core 0.1.0-next.792 → 0.1.0-next.797
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 +397 -0
- package/index.js.map +1 -1
- package/index.mjs +397 -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 +38 -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 +23 -0
- package/templates/polyglot-workspace/build/docker-build.sh.template +55 -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 +34 -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 +71 -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,296 @@ 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 hasUi = (options.type ?? "polyglot") !== "java";
|
|
549
|
+
const normalized = normalizeAllValues({ name: options.name });
|
|
550
|
+
const vars = {
|
|
551
|
+
...normalized,
|
|
552
|
+
hasUi,
|
|
553
|
+
keyset: options.keyset || "prod.kos",
|
|
554
|
+
appUiName: `${normalized.nameDashCase}-ui`,
|
|
555
|
+
nodeVersion: options.nodeVersion || process.version.replace(/^v/, ""),
|
|
556
|
+
jdkMajor: options.jdkMajor || "17",
|
|
557
|
+
mavenVersion: options.mavenVersion || "3.9.9"
|
|
558
|
+
};
|
|
559
|
+
generateFilesFromTemplates(
|
|
560
|
+
codegenFs,
|
|
561
|
+
path__namespace.join(templateDir, "root"),
|
|
562
|
+
".",
|
|
563
|
+
vars
|
|
564
|
+
);
|
|
565
|
+
generateFilesFromTemplates(
|
|
566
|
+
codegenFs,
|
|
567
|
+
path__namespace.join(templateDir, "build"),
|
|
568
|
+
"build",
|
|
569
|
+
vars
|
|
570
|
+
);
|
|
571
|
+
generateFilesFromTemplates(
|
|
572
|
+
codegenFs,
|
|
573
|
+
path__namespace.join(templateDir, "github"),
|
|
574
|
+
".github",
|
|
575
|
+
vars
|
|
576
|
+
);
|
|
577
|
+
generateFilesFromTemplates(
|
|
578
|
+
codegenFs,
|
|
579
|
+
path__namespace.join(templateDir, "java"),
|
|
580
|
+
"java",
|
|
581
|
+
vars
|
|
582
|
+
);
|
|
583
|
+
return { executablePaths: [...BUILD_SCRIPTS] };
|
|
584
|
+
}
|
|
585
|
+
const UI_PROJECT_DIRS = [
|
|
586
|
+
"apps",
|
|
587
|
+
"libs",
|
|
588
|
+
"plugins",
|
|
589
|
+
"splash",
|
|
590
|
+
"themes",
|
|
591
|
+
"content",
|
|
592
|
+
"translations"
|
|
593
|
+
];
|
|
594
|
+
function joinArtifactPath(outputPath, fileName) {
|
|
595
|
+
return `${outputPath.replace(/\/+$/, "")}/${fileName}`;
|
|
596
|
+
}
|
|
597
|
+
function discoverUiArtifacts(codegenFs) {
|
|
598
|
+
const artifacts = [];
|
|
599
|
+
for (const dir of UI_PROJECT_DIRS) {
|
|
600
|
+
for (const file of codegenFs.listFiles(`ui/${dir}`)) {
|
|
601
|
+
if (!file.endsWith("project.json")) continue;
|
|
602
|
+
const raw = codegenFs.read(file);
|
|
603
|
+
if (raw === null) continue;
|
|
604
|
+
let project;
|
|
605
|
+
try {
|
|
606
|
+
project = JSON.parse(raw);
|
|
607
|
+
} catch {
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
const name = project.name;
|
|
611
|
+
if (!name) continue;
|
|
612
|
+
const kabOptions = project.targets?.kab?.options;
|
|
613
|
+
if (kabOptions?.outputPath && kabOptions?.kabName) {
|
|
614
|
+
artifacts.push({
|
|
615
|
+
id: name,
|
|
616
|
+
filename: `ui/${joinArtifactPath(kabOptions.outputPath, kabOptions.kabName)}`
|
|
617
|
+
});
|
|
618
|
+
} else if (project.targets?.splash) {
|
|
619
|
+
artifacts.push({
|
|
620
|
+
id: name,
|
|
621
|
+
filename: `ui/dist/archives/packages/${name}/${name}.kab`,
|
|
622
|
+
layer: 1
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
for (const file of codegenFs.listFiles("ui/external")) {
|
|
628
|
+
if (!file.endsWith(".kab")) continue;
|
|
629
|
+
const base = file.slice(file.lastIndexOf("/") + 1, -".kab".length);
|
|
630
|
+
artifacts.push({ id: base, filename: file });
|
|
631
|
+
}
|
|
632
|
+
return artifacts;
|
|
633
|
+
}
|
|
634
|
+
function discoverJavaArtifacts(codegenFs) {
|
|
635
|
+
const aggregator = codegenFs.read("java/pom.xml");
|
|
636
|
+
if (aggregator === null) return [];
|
|
637
|
+
const artifacts = [];
|
|
638
|
+
for (const match of aggregator.matchAll(/<module>([^<]+)<\/module>/g)) {
|
|
639
|
+
const moduleDir = match[1];
|
|
640
|
+
const pom = codegenFs.read(`java/${moduleDir}/pom.xml`);
|
|
641
|
+
if (pom === null || !pom.includes("kos-kab-maven-plugin")) continue;
|
|
642
|
+
const withoutParent = pom.replace(/<parent>[\s\S]*?<\/parent>/, "");
|
|
643
|
+
const artifactId = withoutParent.match(
|
|
644
|
+
/<artifactId>([^<]+)<\/artifactId>/
|
|
645
|
+
)?.[1];
|
|
646
|
+
if (!artifactId) continue;
|
|
647
|
+
artifacts.push({
|
|
648
|
+
id: moduleDir,
|
|
649
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
650
|
+
filename: `java/${moduleDir}/target/${artifactId}-\${KOS_STD_VERSION_REGEX}.kab`
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
return artifacts;
|
|
654
|
+
}
|
|
655
|
+
function syncManifest(codegenFs, manifestPath, discovered, prune) {
|
|
656
|
+
const raw = codegenFs.read(manifestPath);
|
|
657
|
+
if (raw === null) return null;
|
|
658
|
+
const manifest = JSON.parse(raw);
|
|
659
|
+
const existing = manifest.artifacts ?? [];
|
|
660
|
+
const byFilename = new Map(discovered.map((d) => [d.filename, d]));
|
|
661
|
+
const kept = [];
|
|
662
|
+
const stale = [];
|
|
663
|
+
const pruned = [];
|
|
664
|
+
for (const entry of existing) {
|
|
665
|
+
if (byFilename.has(entry.filename)) {
|
|
666
|
+
kept.push(entry);
|
|
667
|
+
byFilename.delete(entry.filename);
|
|
668
|
+
} else if (prune) {
|
|
669
|
+
pruned.push(entry.id ?? entry.filename);
|
|
670
|
+
} else {
|
|
671
|
+
kept.push(entry);
|
|
672
|
+
stale.push(entry.id ?? entry.filename);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
const added = [];
|
|
676
|
+
for (const artifact of byFilename.values()) {
|
|
677
|
+
kept.push({
|
|
678
|
+
id: artifact.id,
|
|
679
|
+
filename: artifact.filename,
|
|
680
|
+
artifactstore: "kos-cdn",
|
|
681
|
+
marketplace: 1,
|
|
682
|
+
...artifact.layer !== void 0 ? { layer: artifact.layer } : {}
|
|
683
|
+
});
|
|
684
|
+
added.push(artifact.id);
|
|
685
|
+
}
|
|
686
|
+
if (added.length > 0 || pruned.length > 0) {
|
|
687
|
+
manifest.artifacts = kept;
|
|
688
|
+
codegenFs.write(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
689
|
+
}
|
|
690
|
+
return { added, stale, pruned };
|
|
691
|
+
}
|
|
692
|
+
function syncCiManifests(codegenFs, options = {}) {
|
|
693
|
+
const prune = options.prune ?? false;
|
|
694
|
+
const ui = discoverUiArtifacts(codegenFs);
|
|
695
|
+
const java = discoverJavaArtifacts(codegenFs);
|
|
696
|
+
const manifests = {};
|
|
697
|
+
const plan = [
|
|
698
|
+
[".github/build-ui.json", ui],
|
|
699
|
+
[".github/build-java.json", java],
|
|
700
|
+
[".github/build-release.json", [...ui, ...java]]
|
|
701
|
+
];
|
|
702
|
+
for (const [manifestPath, discovered] of plan) {
|
|
703
|
+
const result = syncManifest(codegenFs, manifestPath, discovered, prune);
|
|
704
|
+
if (result) {
|
|
705
|
+
manifests[manifestPath] = result;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return { manifests, discovered: { ui, java } };
|
|
709
|
+
}
|
|
710
|
+
function ensureJavaAggregatorPom(codegenFs, options) {
|
|
711
|
+
const pomPath = "java/pom.xml";
|
|
712
|
+
const existing = codegenFs.read(pomPath);
|
|
713
|
+
if (existing === null) {
|
|
714
|
+
codegenFs.write(
|
|
715
|
+
pomPath,
|
|
716
|
+
`<?xml version="1.0" encoding="UTF-8"?>
|
|
717
|
+
<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">
|
|
718
|
+
<modelVersion>4.0.0</modelVersion>
|
|
719
|
+
<groupId>${options.groupId}</groupId>
|
|
720
|
+
<artifactId>${options.artifactId}</artifactId>
|
|
721
|
+
<version>0.0.0-SNAPSHOT</version>
|
|
722
|
+
<packaging>pom</packaging>
|
|
723
|
+
<modules>
|
|
724
|
+
<module>${options.moduleName}</module>
|
|
725
|
+
</modules>
|
|
726
|
+
</project>
|
|
727
|
+
`
|
|
728
|
+
);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
if (existing.includes(`<module>${options.moduleName}</module>`)) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
codegenFs.write(
|
|
735
|
+
pomPath,
|
|
736
|
+
existing.replace(
|
|
737
|
+
"</modules>",
|
|
738
|
+
` <module>${options.moduleName}</module>
|
|
739
|
+
</modules>`
|
|
740
|
+
)
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
function finalizeArchetypeModule(codegenFs, options) {
|
|
744
|
+
const { moduleName, kosVersion, kabPluginVersion, apiInfoVersion } = options;
|
|
745
|
+
const notes = [];
|
|
746
|
+
const pomPath = `java/${moduleName}/pom.xml`;
|
|
747
|
+
let pom = codegenFs.read(pomPath);
|
|
748
|
+
if (pom === null) {
|
|
749
|
+
throw new Error(`Generated module pom not found: ${pomPath}`);
|
|
750
|
+
}
|
|
751
|
+
if (pom.includes("<kos.version>0.0.0-SNAPSHOT</kos.version>")) {
|
|
752
|
+
if (kosVersion) {
|
|
753
|
+
pom = pom.replace(
|
|
754
|
+
"<kos.version>0.0.0-SNAPSHOT</kos.version>",
|
|
755
|
+
`<kos.version>${kosVersion}</kos.version>`
|
|
756
|
+
);
|
|
757
|
+
} else {
|
|
758
|
+
notes.push(
|
|
759
|
+
"kos.version is 0.0.0-SNAPSHOT — set it to a released kos-bom version before building"
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
if (pom.includes("${kos-kab-maven-plugin.version}") && !pom.includes("<kos-kab-maven-plugin.version>")) {
|
|
764
|
+
if (kabPluginVersion) {
|
|
765
|
+
pom = pom.replace(
|
|
766
|
+
/(<kos\.version>[^<]*<\/kos\.version>)/,
|
|
767
|
+
`$1
|
|
768
|
+
<kos-kab-maven-plugin.version>${kabPluginVersion}</kos-kab-maven-plugin.version>`
|
|
769
|
+
);
|
|
770
|
+
} else {
|
|
771
|
+
notes.push(
|
|
772
|
+
"the ${kos-kab-maven-plugin.version} property is referenced but undefined — add it before building"
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
const unversionedApiInfo = /<artifactId>api-info<\/artifactId>(\s*)<\/dependency>/;
|
|
777
|
+
if (unversionedApiInfo.test(pom)) {
|
|
778
|
+
if (apiInfoVersion) {
|
|
779
|
+
pom = pom.replace(
|
|
780
|
+
unversionedApiInfo,
|
|
781
|
+
`<artifactId>api-info</artifactId>$1 <version>${apiInfoVersion}</version>$1</dependency>`
|
|
782
|
+
);
|
|
783
|
+
} else {
|
|
784
|
+
notes.push(
|
|
785
|
+
"api-info has no version and is not managed by the kos-bom — add one before building"
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
codegenFs.write(pomPath, pom);
|
|
790
|
+
const githubDir = `java/${moduleName}/github`;
|
|
791
|
+
if (codegenFs.exists(githubDir)) {
|
|
792
|
+
for (const file of codegenFs.listFiles(githubDir)) {
|
|
793
|
+
codegenFs.delete(file);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
const gitignore = codegenFs.read(`java/${moduleName}/gitignore`);
|
|
797
|
+
if (gitignore !== null) {
|
|
798
|
+
codegenFs.write(`java/${moduleName}/.gitignore`, gitignore);
|
|
799
|
+
codegenFs.delete(`java/${moduleName}/gitignore`);
|
|
800
|
+
}
|
|
801
|
+
return notes;
|
|
802
|
+
}
|
|
803
|
+
function addJavaArtifactToManifests(codegenFs, options) {
|
|
804
|
+
const { moduleName } = options;
|
|
805
|
+
for (const manifestPath of [
|
|
806
|
+
".github/build-java.json",
|
|
807
|
+
".github/build-release.json"
|
|
808
|
+
]) {
|
|
809
|
+
const raw = codegenFs.read(manifestPath);
|
|
810
|
+
if (raw === null) {
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
const manifest = JSON.parse(raw);
|
|
814
|
+
manifest.artifacts = manifest.artifacts ?? [];
|
|
815
|
+
if (manifest.artifacts.some(
|
|
816
|
+
(artifact) => artifact.id === moduleName
|
|
817
|
+
)) {
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
manifest.artifacts.push({
|
|
821
|
+
id: moduleName,
|
|
822
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
823
|
+
filename: `java/${moduleName}/target/${moduleName}-\${KOS_STD_VERSION_REGEX}.kab`,
|
|
824
|
+
artifactstore: "kos-cdn",
|
|
825
|
+
marketplace: 1
|
|
826
|
+
});
|
|
827
|
+
codegenFs.write(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
828
|
+
}
|
|
829
|
+
}
|
|
540
830
|
function normalizeOptions(codegenFs, options, projects) {
|
|
541
831
|
const toNormalize = {
|
|
542
832
|
name: options.name
|
|
@@ -582,6 +872,103 @@ function normalizeOptions(codegenFs, options, projects) {
|
|
|
582
872
|
template: ""
|
|
583
873
|
};
|
|
584
874
|
}
|
|
875
|
+
const UPDATE_RELEASE_VERSION_SCRIPT_PATH = "tools/scripts/update-release-version.mjs";
|
|
876
|
+
function buildKabTargets(options) {
|
|
877
|
+
const {
|
|
878
|
+
name,
|
|
879
|
+
archiveDir = "packages",
|
|
880
|
+
descriptorDir,
|
|
881
|
+
buildTarget = "build"
|
|
882
|
+
} = options;
|
|
883
|
+
const outputPath = `dist/archives/${archiveDir}/${name}/`;
|
|
884
|
+
const targets = {
|
|
885
|
+
kab: {
|
|
886
|
+
command: `node tools/scripts/kabtool.mjs build ${name} && node tools/scripts/kabtool.mjs list ${name} `,
|
|
887
|
+
options: {
|
|
888
|
+
outputPath,
|
|
889
|
+
zipName: "ui.zip",
|
|
890
|
+
kabName: `${name}.kab`
|
|
891
|
+
},
|
|
892
|
+
dependsOn: ["zip"]
|
|
893
|
+
},
|
|
894
|
+
zip: {
|
|
895
|
+
command: `node tools/scripts/archiver.js ${name}`,
|
|
896
|
+
options: {
|
|
897
|
+
outputPath,
|
|
898
|
+
zipName: "ui.zip"
|
|
899
|
+
},
|
|
900
|
+
dependsOn: descriptorDir ? [buildTarget, "descriptor"] : [buildTarget]
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
if (descriptorDir) {
|
|
904
|
+
targets.descriptor = {
|
|
905
|
+
command: `node tools/scripts/descriptor.mjs ${name}`,
|
|
906
|
+
options: {
|
|
907
|
+
outputPath: `dist/${descriptorDir}`,
|
|
908
|
+
fileName: "descriptor.json"
|
|
909
|
+
},
|
|
910
|
+
dependsOn: ["build"]
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
targets.version = {
|
|
914
|
+
command: `node ${UPDATE_RELEASE_VERSION_SCRIPT_PATH} ${name} {args.ver}`,
|
|
915
|
+
options: {},
|
|
916
|
+
dependsOn: []
|
|
917
|
+
};
|
|
918
|
+
return targets;
|
|
919
|
+
}
|
|
920
|
+
const UPDATE_RELEASE_VERSION_SCRIPT = `import devkit from "@nx/devkit";
|
|
921
|
+
import { resolve } from "path";
|
|
922
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
923
|
+
import prettier from "prettier";
|
|
924
|
+
|
|
925
|
+
// KOS artifact versioning: stamps the project's .kos.json "version" field
|
|
926
|
+
// (which kabtool bakes into the KAB). Never touches package.json.
|
|
927
|
+
// Driven by tag-based releases:
|
|
928
|
+
// nx run-many --target=version --args=--ver=$KOSBUILD_VERSION
|
|
929
|
+
|
|
930
|
+
const { readCachedProjectGraph } = devkit;
|
|
931
|
+
const [, , name, versionArg] = process.argv;
|
|
932
|
+
|
|
933
|
+
// "{args.ver}" arrives literally when the target runs without --args=--ver=<v>;
|
|
934
|
+
// treat that (or a missing arg) as "report current version, change nothing".
|
|
935
|
+
const version =
|
|
936
|
+
versionArg && !versionArg.startsWith("{args") ? versionArg : undefined;
|
|
937
|
+
|
|
938
|
+
if (!name) {
|
|
939
|
+
console.error("usage: update-release-version.mjs <project> <version>");
|
|
940
|
+
process.exit(1);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
const graph = readCachedProjectGraph();
|
|
944
|
+
const project = graph.nodes[name];
|
|
945
|
+
if (!project) {
|
|
946
|
+
console.error("Unknown project: " + name);
|
|
947
|
+
process.exit(1);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
const kosJsonPath = resolve(process.cwd(), project.data.root, ".kos.json");
|
|
951
|
+
let kosJson;
|
|
952
|
+
try {
|
|
953
|
+
kosJson = JSON.parse(readFileSync(kosJsonPath, "utf8"));
|
|
954
|
+
} catch {
|
|
955
|
+
console.error("Missing or invalid .kos.json: " + kosJsonPath);
|
|
956
|
+
process.exit(1);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
if (!version) {
|
|
960
|
+
console.log(name + ": " + kosJson.version + " (no --ver given; unchanged)");
|
|
961
|
+
process.exit(0);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
const prettierOptions = await prettier.resolveConfig(kosJsonPath);
|
|
965
|
+
const output = await prettier.format(
|
|
966
|
+
JSON.stringify({ ...kosJson, version }, null, 2),
|
|
967
|
+
{ ...prettierOptions, parser: "json" }
|
|
968
|
+
);
|
|
969
|
+
writeFileSync(kosJsonPath, output);
|
|
970
|
+
console.log(name + ": version -> " + version);
|
|
971
|
+
`;
|
|
585
972
|
function appendBarrelExport(codegenFs, indexPath, exportPath) {
|
|
586
973
|
const exportLine = `export * from '${exportPath}'`;
|
|
587
974
|
const content = codegenFs.read(indexPath) ?? "";
|
|
@@ -3006,6 +3393,8 @@ exports.LOCALIZED_PLUGIN_TYPES = LOCALIZED_PLUGIN_TYPES;
|
|
|
3006
3393
|
exports.PLUGIN_TYPES = PLUGIN_TYPES;
|
|
3007
3394
|
exports.PluginHandlerFactory = PluginHandlerFactory;
|
|
3008
3395
|
exports.TrackingFileSystem = TrackingFileSystem;
|
|
3396
|
+
exports.UPDATE_RELEASE_VERSION_SCRIPT = UPDATE_RELEASE_VERSION_SCRIPT;
|
|
3397
|
+
exports.UPDATE_RELEASE_VERSION_SCRIPT_PATH = UPDATE_RELEASE_VERSION_SCRIPT_PATH;
|
|
3009
3398
|
exports.ValidationError = ValidationError;
|
|
3010
3399
|
exports.addChildToModel = addChildToModel;
|
|
3011
3400
|
exports.addComputedToModel = addComputedToModel;
|
|
@@ -3013,17 +3402,23 @@ exports.addConfigPropertyToModel = addConfigPropertyToModel;
|
|
|
3013
3402
|
exports.addContainerSupportToModel = addContainerSupportToModel;
|
|
3014
3403
|
exports.addDependencyToModel = addDependencyToModel;
|
|
3015
3404
|
exports.addFutureToModel = addFutureToModel;
|
|
3405
|
+
exports.addJavaArtifactToManifests = addJavaArtifactToManifests;
|
|
3016
3406
|
exports.addKosModelConfiguration = addKosModelConfiguration;
|
|
3017
3407
|
exports.addModelEffectToModel = addModelEffectToModel;
|
|
3018
3408
|
exports.addPropertyToModel = addPropertyToModel;
|
|
3019
3409
|
exports.addServiceRequestToModel = addServiceRequestToModel;
|
|
3020
3410
|
exports.addTopicHandlerToModel = addTopicHandlerToModel;
|
|
3021
3411
|
exports.appendBarrelExport = appendBarrelExport;
|
|
3412
|
+
exports.buildKabTargets = buildKabTargets;
|
|
3022
3413
|
exports.camelCase = camelCase;
|
|
3023
3414
|
exports.constantCase = constantCase;
|
|
3024
3415
|
exports.dashCase = dashCase;
|
|
3025
3416
|
exports.describeModel = describeModel;
|
|
3417
|
+
exports.discoverJavaArtifacts = discoverJavaArtifacts;
|
|
3026
3418
|
exports.discoverProjects = discoverProjects;
|
|
3419
|
+
exports.discoverUiArtifacts = discoverUiArtifacts;
|
|
3420
|
+
exports.ensureJavaAggregatorPom = ensureJavaAggregatorPom;
|
|
3421
|
+
exports.finalizeArchetypeModule = finalizeArchetypeModule;
|
|
3027
3422
|
exports.findProjectByName = findProjectByName;
|
|
3028
3423
|
exports.findProjectForPath = findProjectForPath;
|
|
3029
3424
|
exports.formatFiles = formatFiles;
|
|
@@ -3035,6 +3430,7 @@ exports.generateFilesFromTemplates = generateFilesFromTemplates;
|
|
|
3035
3430
|
exports.generateHook = generateHook;
|
|
3036
3431
|
exports.generateInit = generateInit;
|
|
3037
3432
|
exports.generateModel = generateModel;
|
|
3433
|
+
exports.generatePolyglotWorkspace = generatePolyglotWorkspace;
|
|
3038
3434
|
exports.generateSplashProject = generateSplashProject;
|
|
3039
3435
|
exports.getCodegenLogger = getCodegenLogger;
|
|
3040
3436
|
exports.getCurrentDirectoryName = getCurrentDirectoryName;
|
|
@@ -3052,6 +3448,7 @@ exports.readJson = readJson;
|
|
|
3052
3448
|
exports.readNxJson = readNxJson;
|
|
3053
3449
|
exports.resolveModelFilePath = resolveModelFilePath;
|
|
3054
3450
|
exports.setCodegenLogger = setCodegenLogger;
|
|
3451
|
+
exports.syncCiManifests = syncCiManifests;
|
|
3055
3452
|
exports.updateJson = updateJson;
|
|
3056
3453
|
exports.updateModelIndex = updateModelIndex;
|
|
3057
3454
|
exports.validateModel = validateModel;
|