create-adonisjs 3.0.0 → 3.2.0
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/build/bin/run.js
CHANGED
|
@@ -82,6 +82,31 @@ var CreateNewApp = class extends BaseCommand {
|
|
|
82
82
|
this.backendSourceDir = this.destination;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Adapts the downloaded starter kit for the detected package manager.
|
|
87
|
+
* - For pnpm monorepos: removes the workspaces field from package.json
|
|
88
|
+
* - For non-pnpm: removes pnpm-workspace.yaml if present
|
|
89
|
+
* - Removes packageManager field when it doesn't match the detected PM
|
|
90
|
+
*/
|
|
91
|
+
async #adaptForPackageManager() {
|
|
92
|
+
const pkgJsonPath = join(this.destination, "package.json");
|
|
93
|
+
const pkgJson = await readFile(pkgJsonPath, "utf-8").then(JSON.parse);
|
|
94
|
+
const pnpmWorkspacePath = join(this.destination, "pnpm-workspace.yaml");
|
|
95
|
+
let dirty = false;
|
|
96
|
+
if (this.packageManager === "pnpm") {
|
|
97
|
+
if (this.isMonorepo && pkgJson.workspaces) {
|
|
98
|
+
delete pkgJson.workspaces;
|
|
99
|
+
dirty = true;
|
|
100
|
+
}
|
|
101
|
+
} else if (existsSync(pnpmWorkspacePath)) {
|
|
102
|
+
await unlink(pnpmWorkspacePath);
|
|
103
|
+
}
|
|
104
|
+
if (pkgJson.packageManager && !pkgJson.packageManager.startsWith(this.packageManager)) {
|
|
105
|
+
delete pkgJson.packageManager;
|
|
106
|
+
dirty = true;
|
|
107
|
+
}
|
|
108
|
+
if (dirty) await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
109
|
+
}
|
|
85
110
|
/**
|
|
86
111
|
* Executes a bash command using execa with shared default options.
|
|
87
112
|
* Commands are run from the specified source directory with consistent
|
|
@@ -301,6 +326,7 @@ var CreateNewApp = class extends BaseCommand {
|
|
|
301
326
|
registry: false
|
|
302
327
|
});
|
|
303
328
|
await this.#inspectStarterKit();
|
|
329
|
+
await this.#adaptForPackageManager();
|
|
304
330
|
await this.#removeLockFile();
|
|
305
331
|
return `Downloaded "${this.kit}"`;
|
|
306
332
|
}).addIf(this.gitInit === true, "Initialize git repository", async () => {
|
package/build/index.js
CHANGED