@mehdad67/create-apitogo 0.1.26 → 0.1.28
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/templates/index.ts
CHANGED
|
@@ -25,6 +25,55 @@ const formatAppTitle = (appName: string) =>
|
|
|
25
25
|
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
26
26
|
.join(" ");
|
|
27
27
|
|
|
28
|
+
const resolveCoreApitogoPackageName = async (): Promise<string> => {
|
|
29
|
+
const createPackageJson = JSON.parse(
|
|
30
|
+
await fs.readFile(path.join(PACKAGE_ROOT, "package.json"), "utf8"),
|
|
31
|
+
) as { name: string };
|
|
32
|
+
return createPackageJson.name.replace("/create-apitogo", "/apitogo");
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const ensureRequiredApitogoModules = (
|
|
36
|
+
dependencies: Record<string, string>,
|
|
37
|
+
corePackageName: string,
|
|
38
|
+
version: string,
|
|
39
|
+
) => {
|
|
40
|
+
if (corePackageName.startsWith("@mehdad67/")) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const scope = corePackageName.slice(0, corePackageName.indexOf("/"));
|
|
45
|
+
const landing = `${scope}/apitogo-module-landing`;
|
|
46
|
+
const userPanel = `${scope}/apitogo-module-user-panel`;
|
|
47
|
+
|
|
48
|
+
if (!(landing in dependencies)) {
|
|
49
|
+
dependencies[landing] = version;
|
|
50
|
+
}
|
|
51
|
+
if (!(userPanel in dependencies)) {
|
|
52
|
+
dependencies[userPanel] = version;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const ensureSecondaryApitogoAliases = (
|
|
57
|
+
dependencies: Record<string, string>,
|
|
58
|
+
corePackageName: string,
|
|
59
|
+
version: string,
|
|
60
|
+
) => {
|
|
61
|
+
if (corePackageName.startsWith("@mehdad67/")) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const alias = (target: string) => `npm:${target}@${version}`;
|
|
66
|
+
const scope = corePackageName.slice(0, corePackageName.indexOf("/"));
|
|
67
|
+
|
|
68
|
+
dependencies["@mehdad67/apitogo"] = alias(corePackageName);
|
|
69
|
+
dependencies["@mehdad67/apitogo-module-landing"] = alias(
|
|
70
|
+
`${scope}/apitogo-module-landing`,
|
|
71
|
+
);
|
|
72
|
+
dependencies["@mehdad67/apitogo-module-user-panel"] = alias(
|
|
73
|
+
`${scope}/apitogo-module-user-panel`,
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
28
77
|
const parseWorkspaceCatalog = async (workspaceFile: string) => {
|
|
29
78
|
const content = await fs.readFile(workspaceFile, "utf8");
|
|
30
79
|
const catalog: Record<string, string> = {};
|
|
@@ -253,6 +302,8 @@ export const installTemplate = async ({
|
|
|
253
302
|
})
|
|
254
303
|
.catch(() => version);
|
|
255
304
|
|
|
305
|
+
const coreApitogoPackageName = await resolveCoreApitogoPackageName();
|
|
306
|
+
|
|
256
307
|
/** Create a package.json for the new project and write it to disk. */
|
|
257
308
|
// biome-ignore lint/suspicious/noExplicitAny: Allow any type
|
|
258
309
|
const packageJson: any = {
|
|
@@ -273,11 +324,24 @@ export const installTemplate = async ({
|
|
|
273
324
|
dependencies: {
|
|
274
325
|
react: ">=19.0.0",
|
|
275
326
|
"react-dom": ">=19.0.0",
|
|
276
|
-
|
|
327
|
+
[coreApitogoPackageName]: resolvedZudokuDependency,
|
|
277
328
|
},
|
|
278
329
|
devDependencies: {},
|
|
279
330
|
};
|
|
280
331
|
|
|
332
|
+
if (!resolvedZudokuDependency.startsWith("file:")) {
|
|
333
|
+
ensureRequiredApitogoModules(
|
|
334
|
+
packageJson.dependencies,
|
|
335
|
+
coreApitogoPackageName,
|
|
336
|
+
resolvedZudokuDependency,
|
|
337
|
+
);
|
|
338
|
+
ensureSecondaryApitogoAliases(
|
|
339
|
+
packageJson.dependencies,
|
|
340
|
+
coreApitogoPackageName,
|
|
341
|
+
resolvedZudokuDependency,
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
281
345
|
/**
|
|
282
346
|
* TypeScript projects will have type definitions and other devDependencies.
|
|
283
347
|
*/
|