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