@ykdz/template 0.0.28 → 0.0.30
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/application.js
CHANGED
|
@@ -123,20 +123,13 @@ export async function validateBlueprintFile(filePath, runtime) {
|
|
|
123
123
|
}
|
|
124
124
|
return "Blueprint is valid";
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
function deriveExistingPackageScope(blueprint) {
|
|
127
127
|
const scopes = new Set();
|
|
128
|
-
for (const definition of
|
|
128
|
+
for (const definition of blueprint.packages) {
|
|
129
129
|
const match = definition.name.match(/^@([^/]+)\//);
|
|
130
130
|
if (!match?.[1]) {
|
|
131
131
|
throw new Error(`Package Addition requires a scoped Package Definition: ${definition.name}`);
|
|
132
132
|
}
|
|
133
|
-
const manifestPath = path.join(options.targetDir, definition.path, "package.json");
|
|
134
|
-
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
135
|
-
if (typeof manifest !== "object" ||
|
|
136
|
-
manifest === null ||
|
|
137
|
-
manifest.name !== definition.name) {
|
|
138
|
-
throw new Error(`Package Addition requires manifest truth for ${definition.path}: expected name ${definition.name}`);
|
|
139
|
-
}
|
|
140
133
|
scopes.add(match[1]);
|
|
141
134
|
}
|
|
142
135
|
if (scopes.size !== 1) {
|
|
@@ -231,10 +224,7 @@ export async function runAddPackage(options, runtime) {
|
|
|
231
224
|
const definition = builtInPresetRegistry.require(options.preset);
|
|
232
225
|
const context = createGenerationContext({
|
|
233
226
|
targetDir: runtime.cwd,
|
|
234
|
-
scope:
|
|
235
|
-
targetDir: runtime.cwd,
|
|
236
|
-
blueprint,
|
|
237
|
-
}),
|
|
227
|
+
scope: deriveExistingPackageScope(blueprint),
|
|
238
228
|
toolchain: {
|
|
239
229
|
nodeLtsMajor: toolchain.nodeLtsMajor.value,
|
|
240
230
|
packageManagerPin: toolchain.packageManagerPin.value,
|
|
@@ -397,7 +397,14 @@ function readExistingPackageAdditionState(options) {
|
|
|
397
397
|
if (contribution === undefined) {
|
|
398
398
|
throw new Error(`Generation Record cannot reproduce Package Definition ${expectedDefinition.name} at ${expectedDefinition.path}`);
|
|
399
399
|
}
|
|
400
|
-
|
|
400
|
+
return contribution;
|
|
401
|
+
});
|
|
402
|
+
for (const packagePath of new Set(options.manifestTruthPackagePaths ?? [])) {
|
|
403
|
+
const expectedDefinition = options.blueprint.packages.find((definition) => definition.path === packagePath);
|
|
404
|
+
if (expectedDefinition === undefined) {
|
|
405
|
+
throw new Error(`Package Addition requires manifest truth for unknown Package Path ${packagePath}`);
|
|
406
|
+
}
|
|
407
|
+
const manifestPath = path.join(options.context.targetDir, packagePath, "package.json");
|
|
401
408
|
let manifest;
|
|
402
409
|
try {
|
|
403
410
|
manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
@@ -409,8 +416,7 @@ function readExistingPackageAdditionState(options) {
|
|
|
409
416
|
throw new Error(`Package Addition requires manifest truth for ${expectedDefinition.path}: expected name ${expectedDefinition.name}`);
|
|
410
417
|
}
|
|
411
418
|
manifestTruthByPackagePath.set(expectedDefinition.path, manifest);
|
|
412
|
-
|
|
413
|
-
});
|
|
419
|
+
}
|
|
414
420
|
const reconstructedCheckFacts = uniqueEnvironmentNeeds(contributions.flatMap((contribution) => contribution.environmentNeeds)).map(checkEnvironmentNeedFact);
|
|
415
421
|
const reconstructedDeploymentFacts = uniqueEnvironmentNeeds(contributions.flatMap((contribution) => contribution.deploymentEnvironmentNeeds ?? [])).map(deploymentEnvironmentNeedFact);
|
|
416
422
|
const persistedCheckFacts = persistedEnvironmentNeeds.check.map(checkEnvironmentNeedFact);
|
|
@@ -993,7 +999,19 @@ export function planGeneratedRepositoryPackageAddition(options) {
|
|
|
993
999
|
: {}),
|
|
994
1000
|
};
|
|
995
1001
|
assertProjectBlueprintV2(blueprint);
|
|
996
|
-
const
|
|
1002
|
+
const manifestTruthPackagePaths = requestedPackageLinkIntents.length === 0
|
|
1003
|
+
? []
|
|
1004
|
+
: [
|
|
1005
|
+
...(options.blueprint.packageLinkIntents ?? []).flatMap((intent) => [
|
|
1006
|
+
intent.consumerPackagePath,
|
|
1007
|
+
intent.providerPackagePath,
|
|
1008
|
+
]),
|
|
1009
|
+
...requestedPackageLinkIntents.map((intent) => intent.consumerPackagePath),
|
|
1010
|
+
];
|
|
1011
|
+
const existing = readExistingPackageAdditionState({
|
|
1012
|
+
...options,
|
|
1013
|
+
manifestTruthPackagePaths,
|
|
1014
|
+
});
|
|
997
1015
|
const generationRecord = {
|
|
998
1016
|
...existing.generationRecord,
|
|
999
1017
|
packages: [
|