@donut-games/cli 0.1.1 → 0.1.2
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/donut.js +41 -6
- package/dist/donut.js.map +1 -1
- package/dist/index.js +41 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/donut.js
CHANGED
|
@@ -115,9 +115,43 @@ async function collectFilesRecursively(rootDirectory) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// ../cli/dist/commands/init.js
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
async function resolveEngineVersions() {
|
|
119
|
+
const candidatePaths = [];
|
|
120
|
+
try {
|
|
121
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
122
|
+
const engineManifestPath = nodeRequire.resolve("@donut-games/engine/package.json");
|
|
123
|
+
candidatePaths.push(engineManifestPath);
|
|
124
|
+
const manifest = await fileSystemExtra2.readJson(engineManifestPath);
|
|
125
|
+
return extractVersionsFromManifest(manifest);
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
const thisModuleDirectory = path2.dirname(fileURLToPath(import.meta.url));
|
|
129
|
+
let walkingDirectory = thisModuleDirectory;
|
|
130
|
+
for (let walkDepth = 0; walkDepth < 8; walkDepth += 1) {
|
|
131
|
+
const candidate = path2.join(walkingDirectory, "packages", "donut-engine", "package.json");
|
|
132
|
+
candidatePaths.push(candidate);
|
|
133
|
+
if (await fileSystemExtra2.pathExists(candidate)) {
|
|
134
|
+
const manifest = await fileSystemExtra2.readJson(candidate);
|
|
135
|
+
return extractVersionsFromManifest(manifest);
|
|
136
|
+
}
|
|
137
|
+
const parentDirectory = path2.dirname(walkingDirectory);
|
|
138
|
+
if (parentDirectory === walkingDirectory) {
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
walkingDirectory = parentDirectory;
|
|
142
|
+
}
|
|
143
|
+
throw new Error(`Unable to resolve @donut-games/engine version metadata. Checked:
|
|
144
|
+
${candidatePaths.join("\n ")}`);
|
|
145
|
+
}
|
|
146
|
+
function extractVersionsFromManifest(manifest) {
|
|
147
|
+
const peerDependencies = manifest.peerDependencies ?? {};
|
|
148
|
+
const stripRange = (range) => range.replace(/^[\^~>=<\s]+/, "");
|
|
149
|
+
return {
|
|
150
|
+
donutEngineVersion: manifest.version,
|
|
151
|
+
pixiVersion: stripRange(peerDependencies["pixi.js"] ?? "8.0.0"),
|
|
152
|
+
threeVersion: stripRange(peerDependencies["three"] ?? "0.160.0")
|
|
153
|
+
};
|
|
154
|
+
}
|
|
121
155
|
async function initializeProject(options) {
|
|
122
156
|
const { projectName, rendererTarget } = options;
|
|
123
157
|
const log = options.log ?? ((message) => console.log(message));
|
|
@@ -131,12 +165,13 @@ async function initializeProject(options) {
|
|
|
131
165
|
await fileSystemExtra2.ensureDir(absoluteDirectory);
|
|
132
166
|
log(chalk.cyan(`Scaffolding "${projectName}" (${rendererTarget}) at ${absoluteDirectory}`));
|
|
133
167
|
const templateSourceDirectory = options.templateDirectory ?? await resolveTemplateDirectory();
|
|
168
|
+
const engineVersions = await resolveEngineVersions();
|
|
134
169
|
const templateTokens = {
|
|
135
170
|
projectName,
|
|
136
171
|
rendererTarget,
|
|
137
|
-
donutEngineVersion:
|
|
138
|
-
pixiVersion:
|
|
139
|
-
threeVersion:
|
|
172
|
+
donutEngineVersion: engineVersions.donutEngineVersion,
|
|
173
|
+
pixiVersion: engineVersions.pixiVersion,
|
|
174
|
+
threeVersion: engineVersions.threeVersion
|
|
140
175
|
};
|
|
141
176
|
const copyResult = await copyTemplate({
|
|
142
177
|
sourceDirectory: templateSourceDirectory,
|